Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2018-06-09 13:28:22 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-06-09 13:44:56 +0300
commit337aab59e97412e45f331cd8ec035dd54d87c71c (patch)
treee242b9907d9d3a09fc3d852418f4aabfb0b8a20a /source/blender/draw/engines/workbench/shaders/workbench_forward_transparent_accum_frag.glsl
parenta1b42b79b316608a60e811458e7854266ce6ea5f (diff)
Workbench: Matcaps: Fix matcap under perspective.
This fixes the problem that matcaps have when using a very larg FOV in perspective view. This was because it was stupidly using the normal direction which can not aligned with the view vector under perspective. So to workaround this problem we don't use the normal as is, but compute how much it's facing the camera. This changes how matcaps looks in perspective because they now always use the full range of the matcap (which is expected).
Diffstat (limited to 'source/blender/draw/engines/workbench/shaders/workbench_forward_transparent_accum_frag.glsl')
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_forward_transparent_accum_frag.glsl4
1 files changed, 3 insertions, 1 deletions
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 b26bc396283..4c034460bd3 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
@@ -43,7 +43,9 @@ void main()
vec3 I_vs = view_vector_from_screen_uv(uv_viewport, viewvecs, ProjectionMatrix);
#ifdef V3D_LIGHTING_MATCAP
- diffuse_light = texture(matcapImage, normal_viewport.xy / 2.0 + 0.5).rgb;
+ bool flipped = world_data.matcap_orientation != 0;
+ vec2 matcap_uv = matcap_uv_compute(I_vs, normal_viewport, flipped);
+ diffuse_light = texture(matcapImage, matcap_uv).rgb;
#endif
#ifdef V3D_SHADING_SPECULAR_HIGHLIGHT