Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/overlay/shaders/edit_mesh_vert.glsl
| Show All 20 Lines | |||||
| #endif | #endif | ||||
| bool test_occlusion() | bool test_occlusion() | ||||
| { | { | ||||
| vec3 ndc = (gl_Position.xyz / gl_Position.w) * 0.5 + 0.5; | vec3 ndc = (gl_Position.xyz / gl_Position.w) * 0.5 + 0.5; | ||||
| return ndc.z > texture(depthTex, ndc.xy).r; | return ndc.z > texture(depthTex, ndc.xy).r; | ||||
| } | } | ||||
| bool test_occlusion_gather() | |||||
| { | |||||
| vec3 ndc = (gl_Position.xyz / gl_Position.w) * 0.5 + 0.5; | |||||
| vec4 depths; | |||||
| #ifdef GPU_ARB_texture_gather | |||||
| depths = textureGather(depthTex, ndc.xy); | |||||
| #else | |||||
| vec3 ofs = vec3(0.5, 0.5, -0.5) * sizeViewportInv.xyy; | |||||
| depths.x = textureLod(depthTex, ndc.xy - ofs.xz, 0.0).r; | |||||
| depths.y = textureLod(depthTex, ndc.xy + ofs.xy, 0.0).r; | |||||
| depths.z = textureLod(depthTex, ndc.xy + ofs.xz, 0.0).r; | |||||
| depths.w = textureLod(depthTex, ndc.xy - ofs.xy, 0.0).r; | |||||
| #endif | |||||
| return all(greaterThan(vec4(ndc.z), depths)); | |||||
| } | |||||
| vec3 non_linear_blend_color(vec3 col1, vec3 col2, float fac) | vec3 non_linear_blend_color(vec3 col1, vec3 col2, float fac) | ||||
| { | { | ||||
| col1 = pow(col1, vec3(1.0 / 2.2)); | col1 = pow(col1, vec3(1.0 / 2.2)); | ||||
| col2 = pow(col2, vec3(1.0 / 2.2)); | col2 = pow(col2, vec3(1.0 / 2.2)); | ||||
| vec3 col = mix(col1, col2, fac); | vec3 col = mix(col1, col2, fac); | ||||
| return pow(col, vec3(2.2)); | return pow(col, vec3(2.2)); | ||||
| } | } | ||||
| Show All 12 Lines | #if defined(VERT) | ||||
| /* Make selected and active vertex always on top. */ | /* Make selected and active vertex always on top. */ | ||||
| if ((data.x & VERT_SELECTED) != 0) { | if ((data.x & VERT_SELECTED) != 0) { | ||||
| gl_Position.z -= 1e-7; | gl_Position.z -= 1e-7; | ||||
| } | } | ||||
| if ((data.x & VERT_ACTIVE) != 0) { | if ((data.x & VERT_ACTIVE) != 0) { | ||||
| gl_Position.z -= 1e-7; | gl_Position.z -= 1e-7; | ||||
| } | } | ||||
| bool occluded = test_occlusion(); | bool occluded = test_occlusion_gather(); | ||||
| #elif defined(EDGE) | #elif defined(EDGE) | ||||
| # ifdef FLAT | # ifdef FLAT | ||||
| finalColor = EDIT_MESH_edge_color_inner(m_data.y); | finalColor = EDIT_MESH_edge_color_inner(m_data.y); | ||||
| selectOveride = 1; | selectOveride = 1; | ||||
| # else | # else | ||||
| finalColor = EDIT_MESH_edge_vertex_color(m_data.y); | finalColor = EDIT_MESH_edge_vertex_color(m_data.y); | ||||
| selectOveride = (m_data.y & EDGE_SELECTED); | selectOveride = (m_data.y & EDGE_SELECTED); | ||||
| # endif | # endif | ||||
| float crease = float(m_data.z) / 255.0; | float crease = float(m_data.z) / 255.0; | ||||
| float bweight = float(m_data.w) / 255.0; | float bweight = float(m_data.w) / 255.0; | ||||
| finalColorOuter = EDIT_MESH_edge_color_outer(m_data.y, m_data.x, crease, bweight); | finalColorOuter = EDIT_MESH_edge_color_outer(m_data.y, m_data.x, crease, bweight); | ||||
| bool occluded = false; /* Done in fragment shader */ | bool occluded = false; /* Done in fragment shader */ | ||||
| #elif defined(FACE) | #elif defined(FACE) | ||||
| finalColor = EDIT_MESH_face_color(m_data.x); | finalColor = EDIT_MESH_face_color(m_data.x); | ||||
| bool occluded = true; | bool occluded = true; | ||||
| #elif defined(FACEDOT) | #elif defined(FACEDOT) | ||||
| finalColor = EDIT_MESH_facedot_color(norAndFlag.w); | finalColor = EDIT_MESH_facedot_color(norAndFlag.w); | ||||
| /* Bias Facedot Z position in clipspace. */ | |||||
| gl_Position.z -= 0.00035; | |||||
| gl_PointSize = sizeFaceDot; | gl_PointSize = sizeFaceDot; | ||||
| bool occluded = test_occlusion(); | bool occluded = test_occlusion_gather(); | ||||
| #endif | #endif | ||||
| finalColor.a *= (occluded) ? alpha : 1.0; | finalColor.a *= (occluded) ? alpha : 1.0; | ||||
| #if !defined(FACE) | #if !defined(FACE) | ||||
| /* Facing based color blend */ | /* Facing based color blend */ | ||||
| vec3 vpos = point_world_to_view(world_pos); | vec3 vpos = point_world_to_view(world_pos); | ||||
| Show All 13 Lines | |||||