Browse Source

changed FixedColor

ncannasse 8 years ago
parent
commit
28a5f182fc
2 changed files with 28 additions and 12 deletions
  1. 21 1
      h3d/pass/HardwarePick.hx
  2. 7 11
      h3d/shader/FixedColor.hx

+ 21 - 1
h3d/pass/HardwarePick.hx

@@ -1,11 +1,31 @@
 package h3d.pass;
 
+private class FixedColor extends hxsl.Shader {
+
+	static var SRC = {
+		@param var colorID : Vec4;
+		@param var viewport : Vec4;
+		var output : {
+			position : Vec4,
+			pickPosition : Vec4,
+			colorID : Vec4
+		};
+		function vertex() {
+			output.pickPosition = (output.position + vec4(viewport.xy, 0., 0.) * output.position.w) * vec4(viewport.zw, 1., 1.);
+		}
+		function fragment() {
+			output.colorID = colorID;
+		}
+	}
+
+}
+
 class HardwarePick extends Default {
 
 	public var pickX : Float;
 	public var pickY : Float;
 
-	var fixedColor = new h3d.shader.FixedColor();
+	var fixedColor = new FixedColor();
 	var colorID : Int;
 	var texOut : h3d.mat.Texture;
 	var material : h3d.mat.Pass;

+ 7 - 11
h3d/shader/FixedColor.hx

@@ -3,19 +3,15 @@ package h3d.shader;
 class FixedColor extends hxsl.Shader {
 
 	static var SRC = {
-		@param var colorID : Vec4;
-		@param var viewport : Vec4;
-		var output : {
-			position : Vec4,
-			pickPosition : Vec4,
-			colorID : Vec4
-		};
-		function vertex() {
-			output.pickPosition = (output.position + vec4(viewport.xy, 0., 0.) * output.position.w) * vec4(viewport.zw, 1., 1.);
-		}
+		@param var color : Vec4;
 		function fragment() {
-			output.colorID = colorID;
+			output.color = color;
 		}
 	}
 
+	public function new( color = 0, alpha = 1. ) {
+		super();
+		color.loadColor(color,alpha);
+	}
+
 }