Overlay: Wireframe: Fix Edges not being culled correctly
This commit is contained in:
parent
1e480840a2
commit
37cd7b25dc
|
@ -1215,7 +1215,7 @@ GPUShader *OVERLAY_shader_wireframe_select(void)
|
|||
datatoc_gpu_shader_common_obinfos_lib_glsl,
|
||||
datatoc_wireframe_vert_glsl,
|
||||
NULL},
|
||||
.frag = (const char *[]){datatoc_gpu_shader_depth_only_frag_glsl, NULL},
|
||||
.frag = (const char *[]){datatoc_wireframe_frag_glsl, NULL},
|
||||
.defs = (const char *[]){sh_cfg->def, "#define SELECT_EDGES\n", NULL},
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,14 +1,25 @@
|
|||
|
||||
in vec3 finalColor;
|
||||
flat in vec2 edgeStart;
|
||||
|
||||
#ifndef SELECT_EDGES
|
||||
in vec3 finalColor;
|
||||
noperspective in vec2 edgePos;
|
||||
|
||||
layout(location = 0) out vec4 fragColor;
|
||||
layout(location = 1) out vec4 lineOutput;
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
/* Needed only because of wireframe slider.
|
||||
* If we could get rid of it would be nice because of performance drain of discard. */
|
||||
if (edgeStart.r == -1.0) {
|
||||
discard;
|
||||
}
|
||||
|
||||
#ifndef SELECT_EDGES
|
||||
lineOutput = pack_line_data(gl_FragCoord.xy, edgeStart, edgePos);
|
||||
fragColor.rgb = finalColor;
|
||||
fragColor.a = 1.0;
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -9,9 +9,10 @@ in vec3 pos;
|
|||
in vec3 nor;
|
||||
in float wd; /* wiredata */
|
||||
|
||||
flat out vec2 edgeStart;
|
||||
|
||||
#ifndef SELECT_EDGES
|
||||
out vec3 finalColor;
|
||||
flat out vec2 edgeStart;
|
||||
noperspective out vec2 edgePos;
|
||||
#endif
|
||||
|
||||
|
@ -103,14 +104,12 @@ void main()
|
|||
vec3 wpos = point_object_to_world(pos);
|
||||
gl_Position = point_world_to_ndc(wpos);
|
||||
|
||||
if (get_edge_sharpness(wd) < 0.0) {
|
||||
/* Discard primitive by placing any of the verts at the camera origin. */
|
||||
gl_Position = vec4(0.0, 0.0, -3e36, 0.0);
|
||||
}
|
||||
|
||||
/* Convert to screen position [0..sizeVp]. */
|
||||
edgeStart = ((gl_Position.xy / gl_Position.w) * 0.5 + 0.5) * sizeViewport.xy;
|
||||
|
||||
#ifndef SELECT_EDGES
|
||||
/* Convert to screen position [0..sizeVp]. */
|
||||
edgePos = edgeStart = ((gl_Position.xy / gl_Position.w) * 0.5 + 0.5) * sizeViewport.xy;
|
||||
edgePos = edgeStart;
|
||||
|
||||
vec3 rim_col, wire_col;
|
||||
if (isObjectColor || isRandomColor) {
|
||||
|
@ -129,6 +128,11 @@ void main()
|
|||
finalColor = mix(final_rim_col, final_front_col, facing);
|
||||
#endif
|
||||
|
||||
/* Cull flat edges below threshold. */
|
||||
if (get_edge_sharpness(wd) < 0.0) {
|
||||
edgeStart = vec2(-1.0);
|
||||
}
|
||||
|
||||
#ifdef USE_WORLD_CLIP_PLANES
|
||||
world_clip_planes_calc_clip_distance(wpos);
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue