Răsfoiți Sursa

added pass layer for high level sorting

Nicolas Cannasse 6 ani în urmă
părinte
comite
fff2e976b9
2 a modificat fișierele cu 4 adăugiri și 3 ștergeri
  1. 1 0
      h3d/mat/Pass.hx
  2. 3 3
      h3d/scene/Renderer.hx

+ 1 - 0
h3d/mat/Pass.hx

@@ -42,6 +42,7 @@ class Pass implements hxd.impl.Serializable {
 	@:bits(bits) public var blendAlphaOp : Operation;
 	@:bits(bits) public var wireframe : Bool;
 	public var colorMask : Int;
+	public var layer : Int = 0;
 
 	@:s public var stencil : Stencil;
 

+ 3 - 3
h3d/scene/Renderer.hx

@@ -28,7 +28,7 @@ class Renderer extends hxd.impl.AnyProps {
 	var hasSetTarget = false;
 
 	public var effects : Array<h3d.impl.RendererFX> = [];
-	
+
 	public var renderMode : RenderMode = Default;
 
 	public function new() {
@@ -90,9 +90,9 @@ class Renderer extends hxd.impl.AnyProps {
 			p.depth = z / w;
 		}
 		if( frontToBack )
-			passes.sort(function(p1, p2) return p1.depth > p2.depth ? 1 : -1);
+			passes.sort(function(p1, p2) return p1.layer == p2.layer ? (p1.depth > p2.depth ? 1 : -1) : p1.layer - p2.layer);
 		else
-			passes.sort(function(p1, p2) return p1.depth > p2.depth ? -1 : 1);
+			passes.sort(function(p1, p2) return p1.layer == p2.layer ? (p1.depth > p2.depth ? -1 : 1) : p1.layer - p2.layer);
 	}
 
 	inline function clear( ?color, ?depth, ?stencil ) {