Skip to content

Commit a8da33d

Browse files
author
pp123pp
committed
sceneBuffer更改为MSAA
1 parent 14d8277 commit a8da33d

13 files changed

+47
-240
lines changed

src/Material/MeshNormalGlsl3Material.ts

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/Material/TileMaterial.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ class TileMaterial extends ShaderMaterial {
150150
this.vertexShader = vertexShader;
151151
this.fragmentShader = fragmentShader;
152152
this.defines.TEXTURE_UNITS = shaderSetOptions.numberOfDayTextures;
153-
this.glslVersion = GLSL3;
153+
// this.glslVersion = GLSL3;
154154
this.defines.APPLY_GAMMA = '';
155155

156156
// this.side = DoubleSide;
@@ -273,10 +273,6 @@ class TileMaterial extends ShaderMaterial {
273273
#include <common>
274274
#include <packing>
275275
#include <logdepthbuf_pars_fragment>
276-
277-
layout(location = 0) out vec4 gColor;
278-
layout(location = 1) out vec4 gDepth;
279-
layout(location = 2) out vec4 gNormal;
280276
281277
in vec3 v_textureCoordinates;
282278
in vec2 vHighPrecisionZW;
@@ -390,18 +386,13 @@ class TileMaterial extends ShaderMaterial {
390386
391387
void main(void){
392388
#include <logdepthbuf_fragment>
393-
394-
float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
395-
396389
397-
gColor = computeDayColor(u_initialColor, clamp(v_textureCoordinates, 0.0, 1.0));
398-
gDepth = packDepthToRGBA( fragCoordZ );
399-
gNormal = vec4(1.0);
390+
gl_FragColor = computeDayColor(u_initialColor, clamp(v_textureCoordinates, 0.0, 1.0));
400391
401392
#if defined( TONE_MAPPING )
402-
gColor.rgb = toneMapping( gColor.rgb );
393+
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
403394
#endif
404-
gColor = linearToOutputTexel( gColor );
395+
gl_FragColor = linearToOutputTexel( gl_FragColor );
405396
}
406397
`;
407398

src/Material/materials.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { MeshNormalGlsl3Material } from './MeshNormalGlsl3Material';
1+
export { TileMaterial } from './TileMaterial';

src/Scene/Camera.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@ import { getTimestamp } from '@/Core/getTimestamp';
1717
import { HeadingPitchRange } from '@/Core/HeadingPitchRange';
1818
import { HeadingPitchRoll } from '@/Core/HeadingPitchRoll';
1919
import { IntersectionTests } from '@/Core/IntersectionTests';
20-
import { MapMode2D } from '@/Core/MapMode2D';
2120
import { Ray } from '@/Core/Ray';
2221
import { Rectangle } from '@/Core/Rectangle';
2322
import { SceneMode } from '@/Core/SceneMode';
2423
import { Transforms } from '@/Core/Transforms';
25-
import { MathUtils, Matrix4, Raycaster, Vector2, Vector3 } from 'three';
24+
import { MathUtils, Matrix4, Raycaster, Vector2 } from 'three';
2625
import { OrthographicFrustumCamera } from './OrthographicFrustumCamera';
2726
import { PerspectiveFrustumCamera, PerspectiveFrustumCameraParameters } from './PerspectiveFrustumCamera';
2827
import { Scene } from './Scene';

src/Scene/Context.ts

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Cartesian2 } from '@/Core/Cartesian2';
2-
import { FloatType, NearestFilter, Texture, WebGLMultipleRenderTargets } from 'three';
2+
import { RGBFormat, Texture, WebGLMultisampleRenderTarget } from 'three';
33
import { generateUUID } from 'three/src/math/MathUtils';
44
import { ContextLimits } from './ContextLimits';
55
import { Scene } from './Scene';
@@ -9,7 +9,7 @@ class Context {
99
public cache: any;
1010
protected _id: string;
1111
drawingBufferHeight: Cartesian2;
12-
sceneFrameBuffer: WebGLMultipleRenderTargets;
12+
sceneFrameBuffer: WebGLMultisampleRenderTarget;
1313
constructor (scene: Scene) {
1414
this.scene = scene;
1515

@@ -19,28 +19,11 @@ class Context {
1919

2020
this.drawingBufferHeight = new Cartesian2();
2121

22-
// this.webglMultipleRenderTarget = new WebGLMultipleRenderTargets
23-
2422
const bufferSize = scene.drawingBufferSize;
2523

26-
// 保存场景的渲染结果,这里输出三和buffer,color, depth, normal
27-
const sceneFrameBuffer = new WebGLMultipleRenderTargets(bufferSize.width, bufferSize.height, 3);
28-
29-
for (let i = 0, il = sceneFrameBuffer.texture.length; i < il; i++) {
30-
sceneFrameBuffer.texture[i].minFilter = NearestFilter;
31-
sceneFrameBuffer.texture[i].magFilter = NearestFilter;
32-
sceneFrameBuffer.texture[i].type = FloatType;
33-
}
34-
35-
// debugger;
36-
// sceneFrameBuffer.texture[0].encoding = scene.renderer.outputEncoding;
37-
38-
sceneFrameBuffer.texture[0].name = 'color';
39-
sceneFrameBuffer.texture[1].name = 'depth';
40-
sceneFrameBuffer.texture[2].name = 'normal';
41-
42-
// (sceneFrameBuffer.texture as any).isTexture = true;
43-
// (sceneFrameBuffer.texture as any).encoding = scene.renderer.outputEncoding;
24+
const sceneFrameBuffer = new WebGLMultisampleRenderTarget(bufferSize.width, bufferSize.height, {
25+
format: RGBFormat
26+
});
4427

4528
this.sceneFrameBuffer = sceneFrameBuffer;
4629

src/Scene/EffectComposerCollection.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { RGBShiftMaterial } from '@/Material/Pass/RGBShiftMaterial';
2-
import { ShaderPass } from '@/Renderer/ShaderPass';
32
import { EffectComposer } from 'three/examples/jsm/postprocessing/EffectComposer';
43
import { RenderPass } from 'three/examples/jsm/postprocessing/RenderPass';
4+
import { ShaderPass } from 'three/examples/jsm/postprocessing/ShaderPass';
55
import { Scene } from './Scene';
66

77
class EffectComposerCollection {
@@ -17,7 +17,7 @@ class EffectComposerCollection {
1717

1818
const effect2 = new ShaderPass(new RGBShiftMaterial());
1919
effect2.uniforms.amount.value = 0.0015;
20-
this.mainEffectComposer.addPass(effect2);
20+
// this.mainEffectComposer.addPass(effect2);
2121
}
2222

2323
setSize (container: Element): void {

src/Scene/PerspectiveFrustumCamera.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import { Cartesian2 } from '@/Core/Cartesian2';
21
import { Cartesian3 } from '@/Core/Cartesian3';
32
import { Cartographic } from '@/Core/Cartographic';
4-
import { CesiumMath } from '@/Core/CesiumMath';
53
import { CesiumMatrix4 } from '@/Core/CesiumMatrix4';
64
import { CesiumQuaternion } from '@/Core/CesiumQuaternion';
75
import { CullingVolume } from '@/Core/CullingVolume';
@@ -10,7 +8,6 @@ import { defined } from '@/Core/defined';
108
import { DeveloperError } from '@/Core/DeveloperError';
119
import { GeographicProjection } from '@/Core/GeographicProjection';
1210
import { PerspectiveOffCenterFrustum } from '@/Core/PerspectiveOffCenterFrustum';
13-
import { Ray } from '@/Core/Ray';
1411
import { SceneMode } from '@/Core/SceneMode';
1512
import { Frustum, MathUtils, Matrix4, PerspectiveCamera, Quaternion, Vector3 } from 'three';
1613
import { Scene } from './Scene';

src/Scene/Scene.ts

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,31 @@
11

2+
import { Cartesian2 } from '@/Core/Cartesian2';
3+
import { Cartesian3 } from '@/Core/Cartesian3';
4+
import { defined } from '@/Core/defined';
5+
import { RequestScheduler } from '@/Core/RequestScheduler';
6+
import { TweenCollection } from '@/Core/TweenCollection';
7+
import * as THREE from 'three';
8+
import { GLSL3, LinearToneMapping, Mesh, Raycaster, ShaderMaterial, SphereBufferGeometry, sRGBEncoding, Vector2 } from 'three';
9+
import { CesiumColor } from '../Core/CesiumColor';
210
import { incrementWrap } from '../Core/CesiumMath';
311
import { defaultValue } from '../Core/defaultValue';
412
import { Event } from '../Core/Event';
13+
import { GeographicProjection } from '../Core/GeographicProjection';
514
import { SceneMode } from '../Core/SceneMode';
6-
import * as THREE from 'three';
7-
import { ACESFilmicToneMapping, GLSL3, LinearToneMapping, Mesh, Raycaster, ShaderMaterial, SphereBufferGeometry, sRGBEncoding, Vector2, WebGLRenderer, WebGLRendererParameters } from 'three';
15+
import { ComputeEngine } from '../Renderer/ComputeEngine';
816
import { Camera } from './Camera';
9-
// import { Camera } from './CameraCopy';
1017
import { Context } from './Context';
18+
import { EffectComposerCollection } from './EffectComposerCollection';
1119
import { FrameState, PassesInterface } from './FrameState';
12-
import { RenderStateParameters } from './MapRenderer';
13-
14-
import { Pass } from './../Renderer/Pass';
15-
import { PerspectiveFrustumCamera } from './PerspectiveFrustumCamera';
16-
import { CesiumColor } from '../Core/CesiumColor';
17-
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls';
18-
import { GeographicProjection } from '../Core/GeographicProjection';
1920
import { Globe } from './Globe';
20-
import { ComputeEngine } from '../Renderer/ComputeEngine';
21-
import { ComputeCommand } from '../Renderer/ComputeCommand';
22-
import { PrimitiveCollection } from './PrimitiveCollection';
23-
import { defined } from '@/Core/defined';
2421
import { ImageryLayerCollection } from './ImageryLayerCollection';
22+
import { MapRenderer, RenderStateParameters } from './MapRenderer';
23+
import { PerspectiveFrustumCamera } from './PerspectiveFrustumCamera';
24+
import { Picking } from './Picking';
25+
import { PrimitiveCollection } from './PrimitiveCollection';
2526
import { RenderCollection } from './RenderCollection';
26-
import { RequestScheduler } from '@/Core/RequestScheduler';
2727
import { ScreenSpaceCameraController } from './ScreenSpaceCameraController';
28-
import { TweenCollection } from '@/Core/TweenCollection';
29-
import { Cartesian2 } from '@/Core/Cartesian2';
30-
import { Cartesian3 } from '@/Core/Cartesian3';
31-
import { EffectComposerCollection } from './EffectComposerCollection';
32-
import { PickDepth } from './PickDepth';
33-
import { Picking } from './Picking';
3428
import { SkyBox } from './SkyBox';
35-
import { MapRenderer } from '@/Renderer/MapRenderer';
36-
37-
const raycaster = new Raycaster();
38-
const mouse = new Vector2();
39-
40-
const pickEarth = new Mesh(new SphereBufferGeometry(6378137, 32, 32));
4129

4230
interface SceneOptions {
4331
renderState?: RenderStateParameters;

src/Shader/BackgroundGlsl3Shader.ts

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/Shader/CubeGlsl3Shader.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,9 @@ import { fragmentIn, varyingExp, vertexOut } from './ShaderReplace';
44

55
const cube = ShaderLib.cube;
66

7-
// console.log(ShaderChunk.envmap_fragment);
7+
console.log(ShaderLib.cube.fragmentShader);
88

99
const fragmentShader = `
10-
layout(location = 0) out vec4 gColor;
11-
layout(location = 1) out vec4 gDepth;
12-
layout(location = 2) out vec4 gNormal;
1310
1411
#include <envmap_common_pars_fragment>
1512
uniform float opacity;
@@ -19,14 +16,10 @@ varying vec3 vWorldDirection;
1916
void main() {
2017
vec3 vReflect = vWorldDirection;
2118
${envmap_fragment}
22-
gColor = envColor;
23-
gColor.a *= opacity;
24-
gNormal = vec4( 1.0);
25-
gDepth = vec4(1.0);
26-
#if defined( TONE_MAPPING )
27-
gColor.rgb = toneMapping( gColor.rgb );
28-
#endif
29-
gColor = linearToOutputTexel( gColor );
19+
gl_FragColor = envColor;
20+
gl_FragColor.a *= opacity;
21+
#include <tonemapping_fragment>
22+
#include <encodings_fragment>
3023
3124
}`;
3225
cube.vertexShader = cube.vertexShader.replace(varyingExp, vertexOut);

src/Shader/DotScreenPass.ts

Lines changed: 0 additions & 48 deletions
This file was deleted.

src/Shader/MeshNormalGlsl3Shader.ts

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)