Workbench: Fix xray normal not being normalized.
authorClément Foucault <foucault.clem@gmail.com>
Sat, 9 Jun 2018 10:29:21 +0000 (12:29 +0200)
committerClément Foucault <foucault.clem@gmail.com>
Sat, 9 Jun 2018 10:44:56 +0000 (12:44 +0200)
source/blender/draw/engines/workbench/shaders/workbench_forward_transparent_accum_frag.glsl

index 4c03446..e954aa5 100644 (file)
@@ -42,24 +42,26 @@ void main()
        vec2 uv_viewport = gl_FragCoord.xy * invertedViewportSize;
        vec3 I_vs = view_vector_from_screen_uv(uv_viewport, viewvecs, ProjectionMatrix);
 
+       vec3 nor = normalize(normal_viewport);
+
 #ifdef V3D_LIGHTING_MATCAP
        bool flipped = world_data.matcap_orientation != 0;
-       vec2 matcap_uv = matcap_uv_compute(I_vs, normal_viewport, flipped);
+       vec2 matcap_uv = matcap_uv_compute(I_vs, nor, flipped);
        diffuse_light = texture(matcapImage, matcap_uv).rgb;
 #endif
 
 #ifdef V3D_SHADING_SPECULAR_HIGHLIGHT
-       vec3 specular_color = get_world_specular_lights(world_data, vec4(material_data.specular_color.rgb, material_data.roughness), normal_viewport, I_vs;
+       vec3 specular_color = get_world_specular_lights(world_data, vec4(material_data.specular_color.rgb, material_data.roughness), nor, I_vs;
 #else
        vec3 specular_color = vec3(0.0);
 #endif
 
 #ifdef V3D_LIGHTING_STUDIO
 #  ifdef STUDIOLIGHT_ORIENTATION_CAMERA
-       diffuse_light = get_camera_diffuse_light(world_data, normal_viewport);
+       diffuse_light = get_camera_diffuse_light(world_data, nor);
 #  endif
 #  ifdef STUDIOLIGHT_ORIENTATION_WORLD
-       vec3 normal_world = normalWorldMatrix * normal_viewport;
+       vec3 normal_world = normalWorldMatrix * nor;
        diffuse_light = get_world_diffuse_light(world_data, normal_world);
 #  endif
 #endif