Răsfoiți Sursa

simplify Vector.setColor (subject to alpha confusion)

ncannasse 8 ani în urmă
părinte
comite
47c281916d
2 a modificat fișierele cu 7 adăugiri și 7 ștergeri
  1. 5 6
      h3d/Vector.hx
  2. 2 1
      h3d/shader/FixedColor.hx

+ 5 - 6
h3d/Vector.hx

@@ -184,12 +184,11 @@ class Vector {
 	inline function set_b(v) return z = v;
 	inline function set_a(v) return w = v;
 
-	public inline function setColor( c : Int, scale : Float = 1.0 ) {
-		var s = scale / 255;
-		r = ((c >> 16) & 0xFF) * s;
-		g = ((c >> 8) & 0xFF) * s;
-		b = (c & 0xFF) * s;
-		a = (c >>> 24) * s;
+	public inline function setColor( c : Int ) {
+		r = ((c >> 16) & 0xFF) / 255;
+		g = ((c >> 8) & 0xFF) / 255;
+		b = (c & 0xFF) / 255;
+		a = (c >>> 24) / 255;
 	}
 
 	public function makeColor( hue : Float, saturation : Float = 1., brightness : Float = 0.5 ) {

+ 2 - 1
h3d/shader/FixedColor.hx

@@ -12,7 +12,8 @@ class FixedColor extends hxsl.Shader {
 
 	public function new( color = 0, alpha = 1. ) {
 		super();
-		this.color.setColor(color,alpha);
+		this.color.setColor(color);
+		this.color.w = alpha;
 	}
 
 }