diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2018-12-10 20:30:37 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2018-12-10 21:02:17 +0300 |
commit | 8e37eb10a1899dc6cf54b68880bba6fa5812c93f (patch) | |
tree | 1823cf70cb878522f06d29ec1d265f879a205865 /source/blender | |
parent | 834bf357c8d4e2c6fdaa8c0004d5e0921222c1c0 (diff) |
Edit Mesh: Make "fresnel effect" not transparent but mix between 2 colors
Alpha blending is causing too many issues.
Revert back to something simpler.
Diffstat (limited to 'source/blender')
6 files changed, 12 insertions, 2 deletions
diff --git a/source/blender/draw/intern/draw_common.c b/source/blender/draw/intern/draw_common.c index 4d33e6ed802..09134f139a7 100644 --- a/source/blender/draw/intern/draw_common.c +++ b/source/blender/draw/intern/draw_common.c @@ -87,6 +87,10 @@ void DRW_globals_update(void) UI_GetThemeColor4fv(TH_FACE_DOT, ts.colorFaceDot); UI_GetThemeColor4fv(TH_BACK, ts.colorBackground); + /* Custom median color to slightly affect the edit mesh colors. */ + interp_v4_v4v4(ts.colorEditMeshMiddle, ts.colorVertexSelect, ts.colorWireEdit, 0.35f); + copy_v3_fl(ts.colorEditMeshMiddle, dot_v3v3(ts.colorEditMeshMiddle, (float[3]){0.3333f, 0.3333f, 0.3333f})); /* Desaturate */ + #ifdef WITH_FREESTYLE UI_GetThemeColor4fv(TH_FREESTYLE_EDGE_MARK, ts.colorEdgeFreestyle); UI_GetThemeColor4fv(TH_FREESTYLE_FACE_MARK, ts.colorFaceFreestyle); diff --git a/source/blender/draw/intern/draw_common.h b/source/blender/draw/intern/draw_common.h index f9e9d2adba3..fc9641b06ee 100644 --- a/source/blender/draw/intern/draw_common.h +++ b/source/blender/draw/intern/draw_common.h @@ -80,6 +80,7 @@ typedef struct GlobalsUboStorage { float colorLampNoAlpha[4]; float colorBackground[4]; + float colorEditMeshMiddle[4]; float colorHandleFree[4]; float colorHandleAuto[4]; diff --git a/source/blender/draw/modes/edit_mesh_mode.c b/source/blender/draw/modes/edit_mesh_mode.c index a7ae8ebde12..7dc3f3af3e6 100644 --- a/source/blender/draw/modes/edit_mesh_mode.c +++ b/source/blender/draw/modes/edit_mesh_mode.c @@ -360,12 +360,14 @@ static DRWPass *edit_mesh_create_overlay_pass( DRW_shgroup_uniform_vec2(*r_lverts_shgrp, "viewportSize", DRW_viewport_size_get(), 1); DRW_shgroup_uniform_float(*r_lverts_shgrp, "edgeScale", edge_width_scale, 1); DRW_shgroup_state_enable(*r_lverts_shgrp, DRW_STATE_WRITE_DEPTH); + DRW_shgroup_state_disable(*r_lverts_shgrp, DRW_STATE_BLEND); *r_verts_shgrp = DRW_shgroup_create(e_data.overlay_vert_sh, pass); DRW_shgroup_uniform_block(*r_verts_shgrp, "globalsBlock", globals_ubo); DRW_shgroup_uniform_vec2(*r_verts_shgrp, "viewportSize", DRW_viewport_size_get(), 1); DRW_shgroup_uniform_float(*r_verts_shgrp, "edgeScale", edge_width_scale, 1); DRW_shgroup_state_enable(*r_verts_shgrp, DRW_STATE_WRITE_DEPTH); + DRW_shgroup_state_disable(*r_verts_shgrp, DRW_STATE_BLEND); } if ((tsettings->selectmode & SCE_SELECT_FACE) != 0) { diff --git a/source/blender/draw/modes/shaders/common_globals_lib.glsl b/source/blender/draw/modes/shaders/common_globals_lib.glsl index 69ba304ca24..520b368bbc2 100644 --- a/source/blender/draw/modes/shaders/common_globals_lib.glsl +++ b/source/blender/draw/modes/shaders/common_globals_lib.glsl @@ -36,6 +36,7 @@ layout(std140) uniform globalsBlock { vec4 colorLampNoAlpha; vec4 colorBackground; + vec4 colorEditMeshMiddle; vec4 colorHandleFree; vec4 colorHandleAuto; diff --git a/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl b/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl index 8d7a653c2fe..0d5c76ad790 100644 --- a/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl +++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl @@ -144,7 +144,7 @@ void main() #endif #ifdef VERTEX_FACING - FragColor.a *= 1.0 - abs(facing) * 0.4; + FragColor.rgb = mix(colorEditMeshMiddle.rgb, FragColor.rgb, 1.0 - abs(facing) * 0.4); #endif /* don't write depth if not opaque */ diff --git a/source/blender/draw/modes/shaders/edit_mesh_overlay_points_vert.glsl b/source/blender/draw/modes/shaders/edit_mesh_overlay_points_vert.glsl index 3886213ce49..245cbab92d5 100644 --- a/source/blender/draw/modes/shaders/edit_mesh_overlay_points_vert.glsl +++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_points_vert.glsl @@ -38,8 +38,10 @@ void main() ? normalize(vPos.xyz) : vec3(0.0, 0.0, 1.0); float facing = dot(view_vec, view_normal); + facing = 1.0 - abs(facing) * 0.4; - finalColor.a *= 1.0 - abs(facing) * 0.4; + finalColor = mix(colorEditMeshMiddle, finalColor, facing); + finalColor.a = 1.0; #endif if ((data.x & VERTEX_EXISTS) == 0) { |