Application prototype #14

Merged
glen merged 101 commits from app-proto into main 2024-10-21 23:38:28 +00:00
Showing only changes of commit abe231126d - Show all commits

View File

@ -191,19 +191,44 @@ void main() {
// composite the sphere fragments
vec3 color = vec3(0.);
int layer = layer_cnt - 1;
TaggedDepth hit;
for (; layer >= layer_threshold; --layer) {
// shade the current fragment
hit = top_hits[layer];
Fragment frag = sphere_shading(
TaggedDepth hit = top_hits[layer];
Fragment frag_next = sphere_shading(
sphere_list[hit.id],
hit.depth * dir,
hit.dimming * color_list[hit.id]
);
float highlight = highlight_list[hit.id];
float highlight_next = highlight_list[hit.id];
--layer;
for (; layer >= layer_threshold; --layer) {
// load the current fragment
Fragment frag = frag_next;
float highlight = highlight_next;
// shade the next fragment
hit = top_hits[layer];
frag_next = sphere_shading(
sphere_list[hit.id],
hit.depth * dir,
hit.dimming * color_list[hit.id]
);
highlight_next = highlight_list[hit.id];
// highlight intersections
float ixn_dist = intersection_dist(frag, frag_next);
float max_highlight = max(highlight, highlight_next);
float ixn_highlight = 0.5 * max_highlight * (1. - smoothstep(2./3.*ixn_threshold, 1.5*ixn_threshold, ixn_dist));
frag.color = mix(frag.color, vec4(1.), ixn_highlight);
frag_next.color = mix(frag_next.color, vec4(1.), ixn_highlight);
// highlight cusps
float cusp_cos = abs(dot(dir, frag.normal));
float cusp_threshold = 2.*sqrt(ixn_threshold * sphere_list[hit.id].lt.s);
float cusp_highlight = highlight * (1. - smoothstep(2./3.*cusp_threshold, 1.5*cusp_threshold, cusp_cos));
frag.color = mix(frag.color, vec4(1.), cusp_highlight);
// composite the current fragment
color = mix(color, frag.color.rgb, frag.color.a);
}
color = mix(color, frag_next.color.rgb, frag_next.color.a);
outColor = vec4(sRGB(color), 1.);
}