Browse Source

Fix crash with Slides when renderer do not use velocity buffer

TothBenoit 3 months ago
parent
commit
b4e307aebe
2 changed files with 3 additions and 1 deletions
  1. 1 0
      h3d/scene/pbr/Renderer.hx
  2. 2 1
      h3d/shader/pbr/Slides.hx

+ 1 - 0
h3d/scene/pbr/Renderer.hx

@@ -711,6 +711,7 @@ class Renderer extends h3d.scene.Renderer {
 			slides.shader.shadowMapCube = shadowMap;
 			slides.shader.shadowIsCube = shadowMap.flags.has(Cube);
 			slides.shader.shadowMapChannel = R;
+			slides.shader.HAS_VELOCITY = textures.velocity != null;
 			slides.shader.velocity = textures.velocity;
 			pbrProps.isScreen = true;
 			slides.render();

+ 2 - 1
h3d/shader/pbr/Slides.hx

@@ -32,6 +32,7 @@ class Slides extends ScreenShader {
 		@param var velocity : Sampler2D;
 		@const var shadowIsCube : Bool;
 		@const var smode : Int;
+		@const var HAS_VELOCITY : Bool;
 
 		function getColor(x:Float,y:Float) : Vec3 {
 			var color : Vec3;
@@ -61,7 +62,7 @@ class Slides extends ScreenShader {
 						color = shadowMapCube.get(dir).xxx;
 					} else
 						color = shadowMap.get(uv).xxx;
-				} else {
+				} else if (HAS_VELOCITY) {
 					color = packNormal(velocity.get(input.uv).xyz * 100.0).xyz;
 				}
 			}