Fix T41456: soft light texture blend mode zero effect

Soft light and Linear light blend modes weren't implemented in glsl

Reviewers: psy-fi

Maniphest Tasks: T41456

Differential Revision: https://developer.blender.org/D744
This commit is contained in:
Antonis Ryakiotakis 2014-08-18 19:14:51 +02:00
parent e1eb2e99f7
commit b07ea2fc15
Notes: blender-bot 2023-02-14 10:12:59 +01:00
Referenced by issue #41456, soft light texture blend mode zero effect
3 changed files with 38 additions and 1 deletions

View File

@ -944,6 +944,12 @@ static void texture_rgb_blend(GPUMaterial *mat, GPUNodeLink *tex, GPUNodeLink *o
case MTEX_BLEND_COLOR:
GPU_link(mat, "mtex_rgb_color", out, tex, fact, facg, in);
break;
case MTEX_SOFT_LIGHT:
GPU_link(mat, "mtex_rgb_soft", out, tex, fact, facg, in);
break;
case MTEX_LIN_LIGHT:
GPU_link(mat, "mtex_rgb_linear", out, tex, fact, facg, in);
break;
default:
GPU_link(mat, "set_rgb_zero", &in);
break;

View File

@ -1012,6 +1012,38 @@ void mtex_rgb_color(vec3 outcol, vec3 texcol, float fact, float facg, out vec3 i
incol.rgb = col.rgb;
}
void mtex_rgb_soft(vec3 outcol, vec3 texcol, float fact, float facg, out vec3 incol)
{
float facm;
fact *= facg;
facm = 1.0-fact;
vec3 one = vec3(1.0);
vec3 scr = one - (one - texcol)*(one - outcol);
incol = facm*outcol + fact*((one - texcol)*outcol*texcol + outcol*scr);
}
void mtex_rgb_linear(vec3 outcol, vec3 texcol, float fact, float facg, out vec3 incol)
{
fact *= facg;
if(texcol.r > 0.5)
incol.r = outcol.r + fact*(2.0*(texcol.r - 0.5));
else
incol.r = outcol.r + fact*(2.0*(texcol.r) - 1.0);
if(texcol.g > 0.5)
incol.g = outcol.g + fact*(2.0*(texcol.g - 0.5));
else
incol.g = outcol.g + fact*(2.0*(texcol.g) - 1.0);
if(texcol.b > 0.5)
incol.b = outcol.b + fact*(2.0*(texcol.b - 0.5));
else
incol.b = outcol.b + fact*(2.0*(texcol.b) - 1.0);
}
void mtex_value_vars(inout float fact, float facg, out float facm)
{
fact *= abs(facg);

View File

@ -501,7 +501,6 @@ typedef struct ColorMapping {
#define MTEX_BLEND_SAT 11
#define MTEX_BLEND_VAL 12
#define MTEX_BLEND_COLOR 13
/* free for use */
#define MTEX_SOFT_LIGHT 15
#define MTEX_LIN_LIGHT 16