From 95c5e60a27987a0620fdff210d505fc4d5a6d3f6 Mon Sep 17 00:00:00 2001 From: Jeshurun Hembd Date: Wed, 24 May 2023 01:25:24 -0400 Subject: [PATCH] Enable standard derivatives extension in demodernizeShader --- packages/engine/Source/Renderer/demodernizeShader.js | 3 +++ packages/engine/Source/Scene/Cesium3DTileBatchTable.js | 3 --- packages/engine/Source/Shaders/BillboardCollectionFS.glsl | 4 ---- .../Source/Shaders/Builtin/Functions/writeLogDepth.glsl | 3 --- .../Source/Shaders/Materials/ElevationContourMaterial.glsl | 4 ---- packages/engine/Source/Shaders/Materials/GridMaterial.glsl | 4 ---- .../Source/Shaders/Materials/PolylineArrowMaterial.glsl | 4 ---- packages/engine/Source/Shaders/Model/ModelFS.glsl | 6 ------ 8 files changed, 3 insertions(+), 28 deletions(-) diff --git a/packages/engine/Source/Renderer/demodernizeShader.js b/packages/engine/Source/Renderer/demodernizeShader.js index ac984761ed07..85446533efab 100644 --- a/packages/engine/Source/Renderer/demodernizeShader.js +++ b/packages/engine/Source/Renderer/demodernizeShader.js @@ -56,6 +56,9 @@ function demodernizeShader(input, isFragmentShader) { // Replace gl_FragDepth with gl_FragDepthEXT. output = output.replaceAll(/gl_FragDepth/g, `gl_FragDepthEXT`); } + + // Enable the OES_standard_derivatives extension + output = `#ifdef GL_OES_standard_derivatives\n#extension GL_OES_standard_derivatives : enable\n#endif\n${output}`; } else { // Replace the in with attribute. output = output.replaceAll(/(in)\s+(vec\d|mat\d|float)/g, `attribute $2`); diff --git a/packages/engine/Source/Scene/Cesium3DTileBatchTable.js b/packages/engine/Source/Scene/Cesium3DTileBatchTable.js index 6631d6c19622..b9a678cdd8c5 100644 --- a/packages/engine/Source/Scene/Cesium3DTileBatchTable.js +++ b/packages/engine/Source/Scene/Cesium3DTileBatchTable.js @@ -1050,9 +1050,6 @@ function getLogDepthPolygonOffsetFragmentShaderProgram(context, shaderProgram) { fs.defines = defined(fs.defines) ? fs.defines.slice(0) : []; fs.defines.push("POLYGON_OFFSET"); - fs.sources.unshift( - "#ifdef GL_OES_standard_derivatives\n#extension GL_OES_standard_derivatives : enable\n#endif\n" - ); shader = context.shaderCache.createDerivedShaderProgram( shaderProgram, "zBackfaceLogDepth", diff --git a/packages/engine/Source/Shaders/BillboardCollectionFS.glsl b/packages/engine/Source/Shaders/BillboardCollectionFS.glsl index 916731d92779..d4c72d2c3bbd 100644 --- a/packages/engine/Source/Shaders/BillboardCollectionFS.glsl +++ b/packages/engine/Source/Shaders/BillboardCollectionFS.glsl @@ -1,7 +1,3 @@ -#ifdef GL_OES_standard_derivatives -#extension GL_OES_standard_derivatives : enable -#endif - uniform sampler2D u_atlas; #ifdef VECTOR_TILE diff --git a/packages/engine/Source/Shaders/Builtin/Functions/writeLogDepth.glsl b/packages/engine/Source/Shaders/Builtin/Functions/writeLogDepth.glsl index d0501b072459..36a745469d37 100644 --- a/packages/engine/Source/Shaders/Builtin/Functions/writeLogDepth.glsl +++ b/packages/engine/Source/Shaders/Builtin/Functions/writeLogDepth.glsl @@ -3,9 +3,6 @@ in float v_depthFromNearPlusOne; #ifdef POLYGON_OFFSET uniform vec2 u_polygonOffset; -#ifdef GL_OES_standard_derivatives -#extension GL_OES_standard_derivatives : enable -#endif #endif #endif diff --git a/packages/engine/Source/Shaders/Materials/ElevationContourMaterial.glsl b/packages/engine/Source/Shaders/Materials/ElevationContourMaterial.glsl index 23c50dea533a..ca96ba108291 100644 --- a/packages/engine/Source/Shaders/Materials/ElevationContourMaterial.glsl +++ b/packages/engine/Source/Shaders/Materials/ElevationContourMaterial.glsl @@ -1,7 +1,3 @@ -#ifdef GL_OES_standard_derivatives - #extension GL_OES_standard_derivatives : enable -#endif - uniform vec4 color; uniform float spacing; uniform float width; diff --git a/packages/engine/Source/Shaders/Materials/GridMaterial.glsl b/packages/engine/Source/Shaders/Materials/GridMaterial.glsl index a56f6e74e834..de0bde489182 100644 --- a/packages/engine/Source/Shaders/Materials/GridMaterial.glsl +++ b/packages/engine/Source/Shaders/Materials/GridMaterial.glsl @@ -1,7 +1,3 @@ -#ifdef GL_OES_standard_derivatives - #extension GL_OES_standard_derivatives : enable -#endif - uniform vec4 color; uniform float cellAlpha; uniform vec2 lineCount; diff --git a/packages/engine/Source/Shaders/Materials/PolylineArrowMaterial.glsl b/packages/engine/Source/Shaders/Materials/PolylineArrowMaterial.glsl index 760ac458021b..30740251ac5a 100644 --- a/packages/engine/Source/Shaders/Materials/PolylineArrowMaterial.glsl +++ b/packages/engine/Source/Shaders/Materials/PolylineArrowMaterial.glsl @@ -1,7 +1,3 @@ -#ifdef GL_OES_standard_derivatives -#extension GL_OES_standard_derivatives : enable -#endif - uniform vec4 color; float getPointOnLine(vec2 p0, vec2 p1, float x) diff --git a/packages/engine/Source/Shaders/Model/ModelFS.glsl b/packages/engine/Source/Shaders/Model/ModelFS.glsl index a7cde6064978..f56da251646a 100644 --- a/packages/engine/Source/Shaders/Model/ModelFS.glsl +++ b/packages/engine/Source/Shaders/Model/ModelFS.glsl @@ -1,9 +1,3 @@ -#if defined(HAS_NORMALS) && !defined(HAS_TANGENTS) && !defined(LIGHTING_UNLIT) - #ifdef GL_OES_standard_derivatives - #extension GL_OES_standard_derivatives : enable - #endif -#endif - czm_modelMaterial defaultModelMaterial() { czm_modelMaterial material;