diff options
author | Kevin Dietrich <kevin.dietrich@mailoo.org> | 2014-04-28 19:38:34 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2014-04-29 16:03:09 +0400 |
commit | 1dcf95684929806e80e3d0b514c8690cd757b1bd (patch) | |
tree | 2d5c4cc6a3c73996ec99e8f2c068dd92f3bc839a /source/blender/gpu | |
parent | 4ff3ebf45c8b7fe6911fb40d43384dc04d7a132b (diff) |
Fix for wrong behavior of 'darken' blend mode with factor.
The formula was not consistent across Blender and behaved strangely, now it is
a simple linear blend between color1 and min(color1, color2).
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D489
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/shaders/gpu_shader_material.glsl | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index 7edb5ec153a..4452d4e06c3 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -944,12 +944,9 @@ void mtex_rgb_dark(vec3 outcol, vec3 texcol, float fact, float facg, out vec3 in fact *= facg; facm = 1.0-fact; - col= texcol.r + ((1.0 -texcol.r)*facm); - if(col < outcol.r) incol.r = col; else incol.r = outcol.r; - col= texcol.g + ((1.0 -texcol.g)*facm); - if(col < outcol.g) incol.g = col; else incol.g = outcol.g; - col= texcol.b + ((1.0 -texcol.b)*facm); - if(col < outcol.b) incol.b = col; else incol.b = outcol.b; + incol.r = min(outcol.r, texcol.r) * fact + outcol.r * facm; + incol.g = min(outcol.g, texcol.g) * fact + outcol.g * facm; + incol.b = min(outcol.b, texcol.b) * fact + outcol.b * facm; } void mtex_rgb_light(vec3 outcol, vec3 texcol, float fact, float facg, out vec3 incol) @@ -1078,8 +1075,7 @@ void mtex_value_dark(float outcol, float texcol, float fact, float facg, out flo float facm; mtex_value_vars(fact, facg, facm); - float col = fact*texcol; - if(col < outcol) incol = col; else incol = outcol; + incol = facm*outcol + fact*min(outcol, texcol); } void mtex_value_light(float outcol, float texcol, float fact, float facg, out float incol) |