Browse Source

Decal: don't update shaders during sync even when culled

trethaller 4 years ago
parent
commit
8c15fb81e0
1 changed files with 11 additions and 15 deletions
  1. 11 15
      h3d/scene/pbr/Decal.hx

+ 11 - 15
h3d/scene/pbr/Decal.hx

@@ -6,20 +6,16 @@ class Decal extends Mesh {
 		super(primitive, material, parent);
 	}
 
-	override function sync( ctx : RenderContext ) {
-		super.sync(ctx);
-
-		var shader = material.mainPass.getShader(h3d.shader.pbr.VolumeDecal.DecalPBR);
-		if( shader != null )
-			syncDecalPBR(shader);
-	}
-
-	function syncDecalPBR( shader : h3d.shader.pbr.VolumeDecal.DecalPBR ) {
-		var absPos = getAbsPos();
-		shader.normal.set(absPos._31, absPos._32, absPos._33); // up
-		shader.tangent.set(absPos._21, absPos._22, absPos._23); // right
+	override function emit( ctx : RenderContext ) {
+		super.emit(ctx);
+
+		if(ctx.visibleFlag) {
+			var shader = material.mainPass.getShader(h3d.shader.pbr.VolumeDecal.DecalPBR);
+			if( shader != null ) {
+				var absPos = getAbsPos();
+				shader.normal.set(absPos._31, absPos._32, absPos._33); // up
+				shader.tangent.set(absPos._21, absPos._22, absPos._23); // right
+			}
+		}
 	}
-
-
-
 }