浏览代码

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

trethaller 4 年之前
父节点
当前提交
8c15fb81e0
共有 1 个文件被更改,包括 11 次插入15 次删除
  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
+			}
+		}
 	}
-
-
-
 }