Page MenuHome
Paste P1053

(An Untitled Masterwork)
ActivePublic

Authored by Jeroen Bakker (jbakker) on Jul 26 2019, 3:33 PM.
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 fd4cea4279a..8036b4babed 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
@@ -32,7 +32,11 @@ void main()
#ifndef MATDATA_PASS_ENABLED
base_color = materialSingleColor;
+# ifdef V3D_SHADING_SPECULAR_HIGHLIGHT
+ metallic = 1.0;
+# else
metallic = 0.0;
+# endif
roughness = 0.5;
#else
vec4 material_data = texelFetch(materialBuffer, texel, 0);
@@ -53,7 +57,7 @@ void main()
#elif defined(V3D_LIGHTING_MATCAP)
/* When using matcaps, the metallic is the backface sign. */
- normal_viewport = (metallic > 0.0) ? normal_viewport : -normal_viewport;
+ normal_viewport = (roughness > 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_diffuse = textureLod(matcapDiffuseImage, matcap_uv, 0.0).rgb;
@@ -64,7 +68,7 @@ void main()
vec3 matcap_specular = vec3(0.0);
# endif
- vec3 shaded_color = matcap_diffuse * base_color + matcap_specular;
+ vec3 shaded_color = matcap_diffuse * base_color + (metallic * matcap_specular);
#elif defined(V3D_LIGHTING_STUDIO)
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_prepass_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_prepass_frag.glsl
index c673b2484de..b629a8ef709 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_prepass_frag.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_prepass_frag.glsl
@@ -52,9 +52,9 @@ void main()
# endif
# ifdef V3D_LIGHTING_MATCAP
- /* Encode front facing in metallic channel. */
- metallic = float(gl_FrontFacing);
- roughness = 0.0;
+ /* Encode front facing in roughness channel. */
+ metallic = materialMetallic;
+ roughness = float(gl_FrontFacing);
# else
metallic = materialMetallic;
roughness = materialRoughness;