فهرست منبع

fixes to colorMatrix alpha handling

ncannasse 8 سال پیش
والد
کامیت
41bea45278
2فایلهای تغییر یافته به همراه4 افزوده شده و 4 حذف شده
  1. 3 1
      h3d/pass/ColorMatrix.hx
  2. 1 3
      h3d/shader/ColorMatrix.hx

+ 3 - 1
h3d/pass/ColorMatrix.hx

@@ -19,7 +19,9 @@ class ColorMatrixShader extends h3d.shader.ScreenShader {
 		@param var maskChannel : Vec4;
 
 		function apply( color : Vec4, mat : Mat4 ) : Vec4 {
-			return useAlpha ? color * mat : vec4(color.rgb * matrix.mat3x4(), (color * matrix).a);
+			// by default we ignore alpha since it's not accurate 
+			// in a render target because of alpha blending
+			return useAlpha ? color * mat : vec4(color.rgb, 1.) * mat;
 		}
 
 		function fragment() {

+ 1 - 3
h3d/shader/ColorMatrix.hx

@@ -8,9 +8,7 @@ class ColorMatrix extends hxsl.Shader {
 		@param var matrix : Mat4;
 
 		function fragment() {
-			var rgb = pixelColor.rgb * matrix.mat3x4();
-			pixelColor.a = (pixelColor * matrix).a;
-			pixelColor.rgb = rgb;
+			pixelColor = vec4( (vec4(pixelColor.rgb,1.) * matrix).rgb, (pixelColor * matrix).a);
 		}
 
 	};