瀏覽代碼

Fixed VolumetricLightScattering post-process to use a custom vertex shader instead of the depth vertex shader.

Julien MOREAU-MATHIS 6 年之前
父節點
當前提交
61c298f4e6

+ 1 - 1
src/PostProcesses/volumetricLightScatteringPostProcess.ts

@@ -212,7 +212,7 @@ export class VolumetricLightScatteringPostProcess extends PostProcess {
         if (this._cachedDefines !== join) {
             this._cachedDefines = join;
             this._volumetricLightScatteringPass = mesh.getScene().getEngine().createEffect(
-                { vertexElement: "depth", fragmentElement: "volumetricLightScatteringPass" },
+                "volumetricLightScatteringPass",
                 attribs,
                 ["world", "mBones", "viewProjection", "diffuseMatrix"],
                 ["diffuseSampler"],

+ 0 - 1
src/Shaders/volumetricLightScatteringPass.fragment.fx

@@ -17,4 +17,3 @@ void main(void)
 
 	gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
 }
-

+ 45 - 0
src/Shaders/volumetricLightScatteringPass.vertex.fx

@@ -0,0 +1,45 @@
+// Attribute
+attribute vec3 position;
+#include<bonesDeclaration>
+
+#include<morphTargetsVertexGlobalDeclaration>
+#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
+
+// Uniform
+#include<instancesDeclaration>
+
+uniform mat4 viewProjection;
+uniform vec2 depthValues;
+
+#if defined(ALPHATEST) || defined(NEED_UV)
+varying vec2 vUV;
+uniform mat4 diffuseMatrix;
+#ifdef UV1
+attribute vec2 uv;
+#endif
+#ifdef UV2
+attribute vec2 uv2;
+#endif
+#endif
+
+void main(void)
+{
+    vec3 positionUpdated = position;
+#if (defined(ALPHATEST) || defined(NEED_UV)) && defined(UV1)
+    vec2 uvUpdated = uv;
+#endif
+#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
+
+#include<instancesVertex>
+
+#include<bonesVertex>
+
+#if defined(ALPHATEST) || defined(BASIC_RENDER)
+#ifdef UV1
+	vUV = vec2(diffuseMatrix * vec4(uvUpdated, 1.0, 0.0));
+#endif
+#ifdef UV2
+	vUV = vec2(diffuseMatrix * vec4(uv2, 1.0, 0.0));
+#endif
+#endif
+}