Skip to content

Commit 417c3f9

Browse files
fixed some artifacts
1 parent 9f7c4d8 commit 417c3f9

File tree

5 files changed

+12
-11
lines changed

5 files changed

+12
-11
lines changed

Source/Renderer/ShaderSource.js

+3
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,9 @@ define([
228228
precision highp float;\n\
229229
#else\n\
230230
precision mediump float;\n\
231+
#endif\n\n\
232+
#ifdef GL_EXT_frag_depth\n\
233+
#extension GL_EXT_frag_depth : enable\n\
231234
#endif\n\n';
232235
}
233236

Source/Scene/Model.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1853,7 +1853,7 @@
18531853
function modifyFsShaderForDepth(shader) {
18541854
shader = ShaderSource.replaceMain(shader, 'czm_main');
18551855
shader +=
1856-
'varying float v_inverse_depth; \n' +
1856+
'varying float v_inverse_depth;\n' +
18571857
'void main() \n' +
18581858
'{ \n' +
18591859
' czm_main(); \n' +
@@ -1866,11 +1866,11 @@
18661866
function modifyVertexShaderForDepth(shader) {
18671867
shader = ShaderSource.replaceMain(shader, 'gltf_morph_main');
18681868
shader +=
1869-
'varying float v_inverse_depth; \n' +
1869+
'varying float v_inverse_depth;\n' +
18701870
'void main() \n' +
18711871
'{ \n' +
18721872
' gltf_morph_main(); \n' +
1873-
' v_inverse_depth = 1. / gl_Position.w; \n' +
1873+
' v_inverse_depth = 1. / ((u_projectionMatrix * u_modelViewMatrix * vec4(a_position,1.0)).w); \n' +
18741874
'} \n';
18751875

18761876
return shader;

Source/Shaders/Builtin/Functions/logDepth.glsl

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#ifdef GL_EXT_frag_depth
2-
#extension GL_EXT_frag_depth : enable
3-
#endif
41
void czm_logDepth(float w)
52
{
63
#ifdef GL_EXT_frag_depth

Source/Shaders/ShadowVolumeFS.glsl

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ uniform vec4 u_highlightColor;
88
varying vec4 v_color;
99
#endif
1010

11-
varying float v_inverse_depth;
11+
varying float v_depth;
1212

1313
void main(void)
1414
{
@@ -18,5 +18,5 @@ void main(void)
1818
gl_FragColor = v_color;
1919
#endif
2020
//czm_writeDepthClampedToFarPlane();
21-
czm_logDepth(v_inverse_depth);
21+
czm_logDepth(1. / v_depth);
2222
}

Source/Shaders/ShadowVolumeVS.glsl

+4-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ uniform float u_globeMinimumAltitude;
1919
#ifndef VECTOR_TILE
2020
varying vec4 v_color;
2121
#endif
22-
varying float v_inverse_depth;
22+
varying float v_depth;
2323

2424
void main()
2525
{
@@ -37,7 +37,8 @@ void main()
3737
//extrudeDirection is zero for the top layer
3838
position = position + vec4(extrudeDirection * delta, 0.0);
3939
#endif
40-
gl_Position = czm_depthClampFarPlane(czm_modelViewProjectionRelativeToEye * position);
40+
vec4 positionEC = czm_modelViewProjectionRelativeToEye * position;
41+
gl_Position = czm_depthClampFarPlane(positionEC);
4142
#endif
42-
v_inverse_depth = 1. / gl_Position.w;
43+
v_depth = gl_Position.w;
4344
}

0 commit comments

Comments
 (0)