2
0
ncannasse 11 жил өмнө
parent
commit
6c46222e39

+ 3 - 2
h3d/mat/MeshMaterial.hx

@@ -172,8 +172,9 @@ private class MeshShader extends h3d.impl.Shader {
 				ruv.z = depthTexture.get(tuv).rgb.dot([1,1/255,1/(255*255)]);
 				ruv.w = 1;
 				var wpos = ruv * screenToLocal;
-				var coord = wpos.xyz / wpos.w;
-				out = tex.get(coord.xy * uvScaleRatio + 0.5);
+				var coord = uvScaleRatio * (wpos.xy / wpos.w) + 0.5;
+				kill( min(min(coord.x, coord.y), min(1 - coord.x, 1 - coord.y)) );
+				out = tex.get(coord.xy);
 			} else {
 				var c = tex.get(tuv.xy,type=isDXT1 ? 1 : isDXT5 ? 2 : 0);
 				if( fog != null ) c.a *= talpha;

+ 27 - 0
h3d/scene/VolumeDecal.hx

@@ -0,0 +1,27 @@
+package h3d.scene;
+
+class VolumeDecal extends h3d.scene.Mesh {
+
+	static var prim : h3d.prim.Polygon = null;
+	static function getVolumePrim() {
+		if( prim != null ) return prim;
+		prim = new h3d.prim.Cube();
+		prim.translate( -0.5, -0.5, -0.5);
+		prim.addNormals();
+		prim.addUVs();
+		return prim;
+	}
+	
+	public function new(texture, ?parent) {
+		super(getVolumePrim(), new h3d.mat.MeshMaterial(texture), parent);
+		material.depthWrite = false;
+	}
+	
+	override function sync( ctx : RenderContext ) {
+		// should be done in decals pass
+//		infos.screenToLocal.multiply(ctx.camera.getInverseViewProj(), getInvPos());
+//		material.volumeDecal = infos;
+		super.sync(ctx);
+	}
+	
+}