diff --git a/packages/engine/Source/Shaders/Builtin/Functions/modelToWindowCoordinates.glsl b/packages/engine/Source/Shaders/Builtin/Functions/modelToWindowCoordinates.glsl index 0244f84d4a4..f6af20d7bac 100644 --- a/packages/engine/Source/Shaders/Builtin/Functions/modelToWindowCoordinates.glsl +++ b/packages/engine/Source/Shaders/Builtin/Functions/modelToWindowCoordinates.glsl @@ -30,7 +30,8 @@ */ vec4 czm_modelToWindowCoordinates(vec4 position) { - vec4 q = czm_modelViewProjection * position; // clip coordinates + vec4 positionEC = czm_modelView * position; + q = czm_projection * positionEC; q.xyz /= q.w; // normalized device coordinates q.xyz = (czm_viewportTransformation * vec4(q.xyz, 1.0)).xyz; // window coordinates return q; diff --git a/packages/engine/Source/Shaders/DepthPlaneVS.glsl b/packages/engine/Source/Shaders/DepthPlaneVS.glsl index b5204ec2f53..01898473b9b 100644 --- a/packages/engine/Source/Shaders/DepthPlaneVS.glsl +++ b/packages/engine/Source/Shaders/DepthPlaneVS.glsl @@ -5,7 +5,7 @@ out vec4 positionEC; void main() { positionEC = czm_modelView * position; - gl_Position = czm_modelViewProjection * position; - + vec4 positionEC = czm_modelView * position; + gl_Position = czm_projection * positionEC; czm_vertexLogDepth(); } diff --git a/packages/engine/Source/Shaders/EllipsoidVS.glsl b/packages/engine/Source/Shaders/EllipsoidVS.glsl index 118b0e721cf..5ef44bd4cb1 100644 --- a/packages/engine/Source/Shaders/EllipsoidVS.glsl +++ b/packages/engine/Source/Shaders/EllipsoidVS.glsl @@ -13,8 +13,8 @@ void main() vec4 p = vec4(u_radii * position, 1.0); v_positionEC = (czm_modelView * p).xyz; // position in eye coordinates - gl_Position = czm_modelViewProjection * p; // position in clip coordinates - + vec4 positionEC = czm_modelView * position; + gl_Position = czm_projection * positionEC; // With multi-frustum, when the ellipsoid primitive is positioned on the intersection of two frustums // and close to terrain, the terrain (writes depth) in the closest frustum can overwrite part of the // ellipsoid (does not write depth) that was rendered in the farther frustum. diff --git a/packages/engine/Source/Shaders/GlobeVS.glsl b/packages/engine/Source/Shaders/GlobeVS.glsl index 13fd7946027..358fcfeeb8d 100644 --- a/packages/engine/Source/Shaders/GlobeVS.glsl +++ b/packages/engine/Source/Shaders/GlobeVS.glsl @@ -114,7 +114,8 @@ vec4 getPositionMorphingMode(vec3 position, float height, vec2 textureCoordinate float yPositionFraction = get2DYPositionFraction(textureCoordinates); vec4 position2DWC = vec4(height, mix(u_tileRectangle.st, u_tileRectangle.pq, vec2(textureCoordinates.x, yPositionFraction)), 1.0); vec4 morphPosition = czm_columbusViewMorph(position2DWC, vec4(position3DWC, 1.0), czm_morphTime); - return czm_modelViewProjection * morphPosition; + vec4 positionEC = czm_modelView * position; + return czm_projection * positionEC; } #ifdef QUANTIZATION_BITS12 diff --git a/packages/engine/Source/Shaders/SkyAtmosphereVS.glsl b/packages/engine/Source/Shaders/SkyAtmosphereVS.glsl index 8ed97f1a097..0696ecff084 100644 --- a/packages/engine/Source/Shaders/SkyAtmosphereVS.glsl +++ b/packages/engine/Source/Shaders/SkyAtmosphereVS.glsl @@ -27,5 +27,6 @@ void main(void) #endif v_outerPositionWC = positionWC.xyz; - gl_Position = czm_modelViewProjection * position; + vec4 positionEC = czm_modelView * position; + gl_Position = czm_projection * positionEC; } diff --git a/packages/engine/Specs/Scene/MultifrustumSpec.js b/packages/engine/Specs/Scene/MultifrustumSpec.js index f981a3de284..7bce4075976 100644 --- a/packages/engine/Specs/Scene/MultifrustumSpec.js +++ b/packages/engine/Specs/Scene/MultifrustumSpec.js @@ -237,7 +237,7 @@ describe( vs += "in vec4 position;"; vs += "void main()"; vs += "{"; - vs += " gl_Position = czm_modelViewProjection * position;"; + vs += " vec4 positionEC = czm_modelView * positiong; l_Position = czm_projection * positionEC;"; vs += closestFrustum ? " gl_Position.z = clamp(gl_Position.z, gl_DepthRange.near, gl_DepthRange.far);" : "";