diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-02-24 02:00:10 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-02-24 02:00:35 +0300 |
commit | abb73649129564596e88c095261f7c915d2f30c7 (patch) | |
tree | 108a47f2b145420757feaccbe2cf88acd5db034a /source/blender/draw | |
parent | 24ea6b713d7db459327cf2c62e8d596eebf74d59 (diff) |
Overlay: Edit Mode: Fix wireframes being brighter because of linear blend
Diffstat (limited to 'source/blender/draw')
-rw-r--r-- | source/blender/draw/engines/overlay/shaders/edit_mesh_vert.glsl | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/source/blender/draw/engines/overlay/shaders/edit_mesh_vert.glsl b/source/blender/draw/engines/overlay/shaders/edit_mesh_vert.glsl index 8759ef80888..768b0596d17 100644 --- a/source/blender/draw/engines/overlay/shaders/edit_mesh_vert.glsl +++ b/source/blender/draw/engines/overlay/shaders/edit_mesh_vert.glsl @@ -26,6 +26,14 @@ bool test_occlusion() return ndc.z > texture(depthTex, ndc.xy).r; } +vec3 non_linear_blend_color(vec3 col1, vec3 col2, float fac) +{ + col1 = pow(col1, vec3(1.0 / 2.2)); + col2 = pow(col2, vec3(1.0 / 2.2)); + vec3 col = mix(col1, col2, fac); + return pow(col, vec3(2.2)); +} + void main() { GPU_INTEL_VERTEX_SHADER_WORKAROUND @@ -88,7 +96,8 @@ void main() float facing = dot(view_vec, view_normal); facing = 1.0 - abs(facing) * 0.2; - finalColor.rgb = mix(colorEditMeshMiddle.rgb, finalColor.rgb, facing); + /* Do interpolation in a non-linear space to have a better visual result. */ + finalColor.rgb = non_linear_blend_color(colorEditMeshMiddle.rgb, finalColor.rgb, facing); #endif #ifdef USE_WORLD_CLIP_PLANES |