Ray-caster: add a third test sphere

This helps confirm that the generalized depth-sorting is working.
This commit is contained in:
Aaron Fenyes 2024-08-25 16:41:31 -07:00
parent c18cac642b
commit 206a2df480
2 changed files with 6 additions and 4 deletions

View File

@ -121,7 +121,7 @@ vec2 sphere_cast(vecInv v, vec3 dir) {
} }
void main() { void main() {
const int sphere_cnt = 2; const int sphere_cnt = 3;
vec2 scr = (2.*gl_FragCoord.xy - resolution) / shortdim; vec2 scr = (2.*gl_FragCoord.xy - resolution) / shortdim;
vec3 dir = vec3(focal_slope * scr, -1.); vec3 dir = vec3(focal_slope * scr, -1.);
@ -130,9 +130,11 @@ void main() {
vecInv sphere_list [sphere_cnt]; vecInv sphere_list [sphere_cnt];
sphere_list[0] = sphere(vec3(0.5, 0.5, -5. + ctrl.x), radius.x); sphere_list[0] = sphere(vec3(0.5, 0.5, -5. + ctrl.x), radius.x);
sphere_list[1] = sphere(vec3(-0.5, -0.5, -5. + ctrl.y), radius.y); sphere_list[1] = sphere(vec3(-0.5, -0.5, -5. + ctrl.y), radius.y);
sphere_list[2] = sphere(vec3(-0.5, 0.5, -5.), 0.75);
vec3 color_list [sphere_cnt]; vec3 color_list [sphere_cnt];
color_list[0] = vec3(1., 0.214, 0.); color_list[0] = vec3(1., 0.25, 0.);
color_list[1] = vec3(0., 0.214, 1.); color_list[1] = vec3(0., 0.25, 1.);
color_list[2] = vec3(0.25, 0., 1.0);
// cast rays through the spheres // cast rays through the spheres
vec2 depth_pairs [sphere_cnt]; vec2 depth_pairs [sphere_cnt];

View File

@ -211,7 +211,7 @@ fn main() {
) )
input( input(
type="range", type="range",
max=3.0, max=5.0,
step=1.0, step=1.0,
bind:valueAsNumber=layer_threshold bind:valueAsNumber=layer_threshold
) )