Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/overlay/shaders/paint_wire_vert.glsl
- This file was moved from source/blender/draw/modes/shaders/paint_wire_vert.glsl.
| uniform bool useSelect; | |||||
| in vec3 pos; | in vec3 pos; | ||||
| in vec4 nor; /* flag stored in w */ | in vec4 nor; /* flag stored in w */ | ||||
| flat out vec4 finalColor; | flat out vec4 finalColor; | ||||
| void main() | void main() | ||||
| { | { | ||||
| #ifdef USE_SELECT | GPU_INTEL_VERTEX_SHADER_WORKAROUND | ||||
| bool is_select = (nor.w > 0.0); | |||||
| bool is_hidden = (nor.w < 0.0); | bool is_select = (nor.w > 0.0) && useSelect; | ||||
| #else | bool is_hidden = (nor.w < 0.0) && useSelect; | ||||
| bool is_select = false; | |||||
| bool is_hidden = false; | |||||
| #endif | |||||
| vec3 world_pos = point_object_to_world(pos); | vec3 world_pos = point_object_to_world(pos); | ||||
| gl_Position = point_world_to_ndc(world_pos); | gl_Position = point_world_to_ndc(world_pos); | ||||
| /* Add offset in Z to avoid zfighting and render selected wires on top. */ | /* Add offset in Z to avoid zfighting and render selected wires on top. */ | ||||
| /* TODO scale this bias using znear and zfar range. */ | /* TODO scale this bias using znear and zfar range. */ | ||||
| gl_Position.z -= (is_select ? 2e-4 : 1e-4); | gl_Position.z -= (is_select ? 2e-4 : 1e-4); | ||||
| if (is_hidden) { | if (is_hidden) { | ||||
| gl_Position = vec4(-2.0, -2.0, -2.0, 1.0); | gl_Position = vec4(-2.0, -2.0, -2.0, 1.0); | ||||
| } | } | ||||
| #ifdef VERTEX_MODE | const vec4 colSel = vec4(1.0); | ||||
| vec4 colSel = colorEdgeSelect; | |||||
| colSel.rgb = clamp(colSel.rgb - 0.2, 0.0, 1.0); | |||||
| #else | |||||
| const vec4 colSel = vec4(1.0, 1.0, 1.0, 1.0); | |||||
| #endif | |||||
| #ifdef USE_SELECT | |||||
| finalColor = (is_select) ? colSel : colorWire; | finalColor = (is_select) ? colSel : colorWire; | ||||
| finalColor.a = nor.w; | |||||
| #else | |||||
| # ifdef VERTEX_MODE | |||||
| finalColor.xyz = colorWire.xyz; | |||||
| finalColor.a = 1.0; | |||||
| # else | |||||
| /* Weight paint needs a light color to contrasts with dark weights. */ | |||||
| finalColor = vec4(1, 1, 1, 0.2); | |||||
| # endif | |||||
| #endif | |||||
| /* Needed for Radeon (TM) RX 480 Graphics. */ | /* Weight paint needs a light color to contrasts with dark weights. */ | ||||
| #if defined(GPU_ATI) | if (!useSelect) { | ||||
| gl_PointSize = sizeVertex * 2.0; | finalColor = vec4(1.0, 1.0, 1.0, 0.3); | ||||
| #endif | } | ||||
| #ifdef USE_WORLD_CLIP_PLANES | #ifdef USE_WORLD_CLIP_PLANES | ||||
| world_clip_planes_calc_clip_distance(world_pos); | world_clip_planes_calc_clip_distance(world_pos); | ||||
| #endif | #endif | ||||
| } | } | ||||