diff options
author | Jeroen Bakker <j.bakker@atmind.nl> | 2019-08-27 09:42:50 +0300 |
---|---|---|
committer | Jeroen Bakker <j.bakker@atmind.nl> | 2019-08-27 09:56:56 +0300 |
commit | 66700196074ad168f3322f2766846a0a07f7a00f (patch) | |
tree | f3f90a971ad58a78c7618c18e9ac693974c7ee99 /source/blender/draw/engines/workbench/shaders | |
parent | bc51250c1fbfe8309e42a4a0b6257e93939346a7 (diff) |
Workbench: Specular Highlighting for MatCaps
With Blender 2.80 we introduced a more flexible matcap system. One
change we did was to multiply the matcap with the base color that was
shaded. As matcaps contains diffuse and specular lighting in a single
texture this lead to rendering artifacts. Artists were complaining that
everything looked to metalic.
We now support a separate `diffuse` and `specular` pass for matcaps.
`shaded_color = diffuse_light * base_color + specular_light`
For matcaps to support this feature they need to be multilayer openexr
files with 2 renderpasses (named `diffuse` and `specular`). In the future
we can change this to first pass/second pass in stead of this naming
convention.
Reviewed By: fclem, brecht
Differential Revision: https://developer.blender.org/D5335
Diffstat (limited to 'source/blender/draw/engines/workbench/shaders')
2 files changed, 20 insertions, 6 deletions
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_deferred_composite_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_deferred_composite_frag.glsl index a1f80440404..fd4cea4279a 100644 --- a/source/blender/draw/engines/workbench/shaders/workbench_deferred_composite_frag.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_deferred_composite_frag.glsl @@ -5,7 +5,8 @@ uniform sampler2D materialBuffer; uniform sampler2D normalBuffer; /* normalBuffer contains viewport normals */ uniform sampler2D cavityBuffer; -uniform sampler2D matcapImage; +uniform sampler2D matcapDiffuseImage; +uniform sampler2D matcapSpecularImage; uniform vec2 invertedViewportSize; uniform vec4 viewvecs[3]; @@ -55,8 +56,15 @@ void main() normal_viewport = (metallic > 0.0) ? normal_viewport : -normal_viewport; bool flipped = world_data.matcap_orientation != 0; vec2 matcap_uv = matcap_uv_compute(I_vs, normal_viewport, flipped); - vec3 matcap = textureLod(matcapImage, matcap_uv, 0.0).rgb; - vec3 shaded_color = matcap * base_color; + vec3 matcap_diffuse = textureLod(matcapDiffuseImage, matcap_uv, 0.0).rgb; + +# ifdef V3D_SHADING_SPECULAR_HIGHLIGHT + vec3 matcap_specular = textureLod(matcapSpecularImage, matcap_uv, 0.0).rgb; +# else + vec3 matcap_specular = vec3(0.0); +# endif + + vec3 shaded_color = matcap_diffuse * base_color + matcap_specular; #elif defined(V3D_LIGHTING_STUDIO) diff --git a/source/blender/draw/engines/workbench/shaders/workbench_forward_transparent_accum_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_forward_transparent_accum_frag.glsl index c78b2182d04..3333dfeff38 100644 --- a/source/blender/draw/engines/workbench/shaders/workbench_forward_transparent_accum_frag.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_forward_transparent_accum_frag.glsl @@ -27,7 +27,8 @@ in vec2 uv_interp; in vec3 vertexColor; #endif #ifdef V3D_LIGHTING_MATCAP -uniform sampler2D matcapImage; +uniform sampler2D matcapDiffuseImage; +uniform sampler2D matcapSpecularImage; #endif layout(std140) uniform world_block @@ -68,8 +69,13 @@ void main() #elif defined(V3D_LIGHTING_MATCAP) bool flipped = world_data.matcap_orientation != 0; vec2 matcap_uv = matcap_uv_compute(I_vs, nor, flipped); - vec3 matcap = textureLod(matcapImage, matcap_uv, 0.0).rgb; - vec3 shaded_color = matcap * diffuse_color.rgb; + vec3 matcap_diffuse = textureLod(matcapDiffuseImage, matcap_uv, 0.0).rgb; +# ifdef V3D_SHADING_SPECULAR_HIGHLIGHT + vec3 matcap_specular = textureLod(matcapSpecularImage, matcap_uv, 0.0).rgb; +# else + vec3 matcap_specular = vec3(0.0); +# endif + vec3 shaded_color = matcap_diffuse * diffuse_color.rgb + matcap_specular; #elif defined(V3D_LIGHTING_STUDIO) vec3 shaded_color = get_world_lighting( |