diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2014-08-18 21:14:51 +0400 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2014-08-18 21:14:51 +0400 |
commit | b07ea2fc15ac5593442570f0bcb67c84b620b203 (patch) | |
tree | 1102173b5e85f8781547e8b2c68a81e6a223fa09 /source/blender | |
parent | e1eb2e99f78b6fe66a8a16d1f4a7b0b90e364315 (diff) |
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
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/gpu/intern/gpu_material.c | 6 | ||||
-rw-r--r-- | source/blender/gpu/shaders/gpu_shader_material.glsl | 32 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_texture_types.h | 1 |
3 files changed, 38 insertions, 1 deletions
diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index 1750d3142d9..81dcd9cf450 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -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; diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index fb364018282..fe0c7c2b715 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -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); diff --git a/source/blender/makesdna/DNA_texture_types.h b/source/blender/makesdna/DNA_texture_types.h index 059a12bae8b..d256cfb2e85 100644 --- a/source/blender/makesdna/DNA_texture_types.h +++ b/source/blender/makesdna/DNA_texture_types.h @@ -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 |