Material Texture blend modes Screen, Overlay and Multiply didn't respect
the alpha for textures... an error I could trace back to 2004 even.

Obviously the fix should be done, but it might change the appearance of
renders somewhat. Will keep an eye open if this is worth ugly 
version-patching.

Now: image textures with alpha, will only apply the blend modes
respecting the alpha values.
This commit is contained in:
Ton Roosendaal
2012-12-21 10:15:12 +00:00
parent ba868f1c50
commit eb219852a8
2 changed files with 6 additions and 6 deletions

View File

@@ -811,7 +811,7 @@ void mtex_rgb_mul(vec3 outcol, vec3 texcol, float fact, float facg, out vec3 inc
float facm; float facm;
fact *= facg; fact *= facg;
facm = 1.0-facg; facm = 1.0-fact;
incol = (facm + fact*texcol)*outcol; incol = (facm + fact*texcol)*outcol;
} }
@@ -821,7 +821,7 @@ void mtex_rgb_screen(vec3 outcol, vec3 texcol, float fact, float facg, out vec3
float facm; float facm;
fact *= facg; fact *= facg;
facm = 1.0-facg; facm = 1.0-fact;
incol = vec3(1.0) - (vec3(facm) + fact*(vec3(1.0) - texcol))*(vec3(1.0) - outcol); incol = vec3(1.0) - (vec3(facm) + fact*(vec3(1.0) - texcol))*(vec3(1.0) - outcol);
} }
@@ -831,7 +831,7 @@ void mtex_rgb_overlay(vec3 outcol, vec3 texcol, float fact, float facg, out vec3
float facm; float facm;
fact *= facg; fact *= facg;
facm = 1.0-facg; facm = 1.0-fact;
if(outcol.r < 0.5) if(outcol.r < 0.5)
incol.r = outcol.r*(facm + 2.0*fact*texcol.r); incol.r = outcol.r*(facm + 2.0*fact*texcol.r);

View File

@@ -1339,7 +1339,7 @@ void texture_rgb_blend(float in[3], const float tex[3], const float out[3], floa
case MTEX_MUL: case MTEX_MUL:
fact*= facg; fact*= facg;
facm= 1.0f-facg; facm= 1.0f-fact;
in[0]= (facm+fact*tex[0])*out[0]; in[0]= (facm+fact*tex[0])*out[0];
in[1]= (facm+fact*tex[1])*out[1]; in[1]= (facm+fact*tex[1])*out[1];
in[2]= (facm+fact*tex[2])*out[2]; in[2]= (facm+fact*tex[2])*out[2];
@@ -1347,7 +1347,7 @@ void texture_rgb_blend(float in[3], const float tex[3], const float out[3], floa
case MTEX_SCREEN: case MTEX_SCREEN:
fact*= facg; fact*= facg;
facm= 1.0f-facg; facm= 1.0f-fact;
in[0]= 1.0f - (facm+fact*(1.0f-tex[0])) * (1.0f-out[0]); in[0]= 1.0f - (facm+fact*(1.0f-tex[0])) * (1.0f-out[0]);
in[1]= 1.0f - (facm+fact*(1.0f-tex[1])) * (1.0f-out[1]); in[1]= 1.0f - (facm+fact*(1.0f-tex[1])) * (1.0f-out[1]);
in[2]= 1.0f - (facm+fact*(1.0f-tex[2])) * (1.0f-out[2]); in[2]= 1.0f - (facm+fact*(1.0f-tex[2])) * (1.0f-out[2]);
@@ -1355,7 +1355,7 @@ void texture_rgb_blend(float in[3], const float tex[3], const float out[3], floa
case MTEX_OVERLAY: case MTEX_OVERLAY:
fact*= facg; fact*= facg;
facm= 1.0f-facg; facm= 1.0f-fact;
if (out[0] < 0.5f) if (out[0] < 0.5f)
in[0] = out[0] * (facm + 2.0f*fact*tex[0]); in[0] = out[0] * (facm + 2.0f*fact*tex[0]);