File tree 5 files changed +12
-11
lines changed
5 files changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -228,6 +228,9 @@ define([
228
228
precision highp float;\n\
229
229
#else\n\
230
230
precision mediump float;\n\
231
+ #endif\n\n\
232
+ #ifdef GL_EXT_frag_depth\n\
233
+ #extension GL_EXT_frag_depth : enable\n\
231
234
#endif\n\n' ;
232
235
}
233
236
Original file line number Diff line number Diff line change 1853
1853
function modifyFsShaderForDepth ( shader ) {
1854
1854
shader = ShaderSource . replaceMain ( shader , 'czm_main' ) ;
1855
1855
shader +=
1856
- 'varying float v_inverse_depth; \n' +
1856
+ 'varying float v_inverse_depth;\n' +
1857
1857
'void main() \n' +
1858
1858
'{ \n' +
1859
1859
' czm_main(); \n' +
1866
1866
function modifyVertexShaderForDepth ( shader ) {
1867
1867
shader = ShaderSource . replaceMain ( shader , 'gltf_morph_main' ) ;
1868
1868
shader +=
1869
- 'varying float v_inverse_depth; \n' +
1869
+ 'varying float v_inverse_depth;\n' +
1870
1870
'void main() \n' +
1871
1871
'{ \n' +
1872
1872
' 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' +
1874
1874
'} \n' ;
1875
1875
1876
1876
return shader ;
Original file line number Diff line number Diff line change 1
- #ifdef GL_EXT_frag_depth
2
- #extension GL_EXT_frag_depth : enable
3
- #endif
4
1
void czm_logDepth(float w)
5
2
{
6
3
#ifdef GL_EXT_frag_depth
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ uniform vec4 u_highlightColor;
8
8
varying vec4 v_color;
9
9
#endif
10
10
11
- varying float v_inverse_depth ;
11
+ varying float v_depth ;
12
12
13
13
void main(void )
14
14
{
@@ -18,5 +18,5 @@ void main(void)
18
18
gl_FragColor = v_color;
19
19
#endif
20
20
// czm_writeDepthClampedToFarPlane();
21
- czm_logDepth(v_inverse_depth );
21
+ czm_logDepth(1 . / v_depth );
22
22
}
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ uniform float u_globeMinimumAltitude;
19
19
#ifndef VECTOR_TILE
20
20
varying vec4 v_color;
21
21
#endif
22
- varying float v_inverse_depth ;
22
+ varying float v_depth ;
23
23
24
24
void main()
25
25
{
@@ -37,7 +37,8 @@ void main()
37
37
// extrudeDirection is zero for the top layer
38
38
position = position + vec4 (extrudeDirection * delta, 0.0 );
39
39
#endif
40
- gl_Position = czm_depthClampFarPlane(czm_modelViewProjectionRelativeToEye * position);
40
+ vec4 positionEC = czm_modelViewProjectionRelativeToEye * position;
41
+ gl_Position = czm_depthClampFarPlane(positionEC);
41
42
#endif
42
- v_inverse_depth = 1 . / gl_Position .w;
43
+ v_depth = gl_Position .w;
43
44
}
You can’t perform that action at this time.
0 commit comments