diff options
author | Gaia Clary <gaia.clary@machinimatrix.org> | 2018-11-23 00:03:35 +0300 |
---|---|---|
committer | Gaia Clary <gaia.clary@machinimatrix.org> | 2018-11-23 00:03:35 +0300 |
commit | 5df55e184ec2965af9387519e3051ab109a27437 (patch) | |
tree | fc5acd02e57f4d11cf518fe6b523c45631748a40 /source/blender/gpu/shaders | |
parent | 76a18d555ce6a2af319b40a8131845f9123f7d31 (diff) | |
parent | 3fb77591f4d7cd31cfc4410b18d9d5e9ad135394 (diff) |
Merge remote-tracking branch 'origin/blender2.8' into collada2.8
Diffstat (limited to 'source/blender/gpu/shaders')
-rw-r--r-- | source/blender/gpu/shaders/gpu_shader_material.glsl | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index ae6ea7eefa2..6c7c8f24f51 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -141,26 +141,16 @@ void linearrgb_to_srgb(vec4 col_from, out vec4 col_to) col_to.a = col_from.a; } -void color_to_normal(vec3 color, out vec3 normal) -{ - normal.x = 2.0 * ((color.r) - 0.5); - normal.y = -2.0 * ((color.g) - 0.5); - normal.z = 2.0 * ((color.b) - 0.5); -} - void color_to_normal_new_shading(vec3 color, out vec3 normal) { - normal.x = 2.0 * ((color.r) - 0.5); - normal.y = 2.0 * ((color.g) - 0.5); - normal.z = 2.0 * ((color.b) - 0.5); + normal = vec3(2.0) * color - vec3(1.0); } void color_to_blender_normal_new_shading(vec3 color, out vec3 normal) { - normal.x = 2.0 * ((color.r) - 0.5); - normal.y = -2.0 * ((color.g) - 0.5); - normal.z = -2.0 * ((color.b) - 0.5); + normal = vec3(2.0, -2.0, -2.0) * color - vec3(1.0); } + #ifndef M_PI #define M_PI 3.14159265358979323846 #endif @@ -812,6 +802,19 @@ void mix_linear(float fac, vec4 col1, vec4 col2, out vec4 outcol) outcol = col1 + fac * (2.0 * (col2 - vec4(0.5))); } +void valtorgb_opti_constant(float fac, float edge, vec4 color1, vec4 color2, out vec4 outcol, out float outalpha) +{ + outcol = (fac > edge) ? color2 : color1; + outalpha = outcol.a; +} + +void valtorgb_opti_linear(float fac, vec2 mulbias, vec4 color1, vec4 color2, out vec4 outcol, out float outalpha) +{ + fac = clamp(fac * mulbias.x + mulbias.y, 0.0, 1.0); + outcol = mix(color1, color2, fac); + outalpha = outcol.a; +} + void valtorgb(float fac, sampler1DArray colormap, float layer, out vec4 outcol, out float outalpha) { outcol = texture(colormap, vec2(fac, layer)); |