diff --git a/app-proto/inversive-display/src/inversive.frag b/app-proto/inversive-display/src/inversive.frag index db1a3c0..51bc0ff 100644 --- a/app-proto/inversive-display/src/inversive.frag +++ b/app-proto/inversive-display/src/inversive.frag @@ -40,7 +40,7 @@ uniform vec2 radius; uniform float opacity; uniform float highlight; uniform int layer_threshold; -uniform bool use_test_construction; +uniform bool test_mode; // light and camera const float focal_slope = 0.3; @@ -134,40 +134,18 @@ void main() { vec2 scr = (2.*gl_FragCoord.xy - resolution) / shortdim; vec3 dir = vec3(focal_slope * scr, -1.); - // initialize two spheres - vecInv sphere_list_internal [SPHERE_MAX]; - vec3 color_list_internal [SPHERE_MAX]; - if (use_test_construction) { - /* DEBUG */ - // spheres 0 and 1 are identical in the test construction hard-coded - // here and the construction passed in through uniforms. sphere 2 has - // a different radius in the construction; we can use that to show that - // the switch is working - sphere_list_internal[0] = sphere(vec3(0.5, 0.5, -5. + ctrl.x), radius.x); - sphere_list_internal[1] = sphere(vec3(-0.5, -0.5, -5. + ctrl.y), radius.y); - sphere_list_internal[2] = sphere(vec3(-0.5, 0.5, -5.), 0.5); - color_list_internal[0] = vec3(1., 0.25, 0.); - color_list_internal[1] = vec3(0., 0.25, 1.); - color_list_internal[2] = vec3(0.25, 0., 1.0); - } else { - for (int i = 0; i < sphere_cnt; ++i) { - sphere_list_internal[i] = sphere_list[i]; - color_list_internal[i] = color_list[i]; - } - } - // cast rays through the spheres vec2 depth_pairs [SPHERE_MAX]; taggedFrag frags [2*SPHERE_MAX]; int frag_cnt = 0; for (int i = 0; i < sphere_cnt; ++i) { - vec2 hit_depths = sphere_cast(sphere_list_internal[i], dir); + vec2 hit_depths = sphere_cast(sphere_list[i], dir); if (!isnan(hit_depths[0])) { - frags[frag_cnt] = sphere_shading(sphere_list_internal[i], hit_depths[0] * dir, color_list_internal[i], i); + frags[frag_cnt] = sphere_shading(sphere_list[i], hit_depths[0] * dir, color_list[i], i); ++frag_cnt; } if (!isnan(hit_depths[1])) { - frags[frag_cnt] = sphere_shading(sphere_list_internal[i], hit_depths[1] * dir, color_list_internal[i], i); + frags[frag_cnt] = sphere_shading(sphere_list[i], hit_depths[1] * dir, color_list[i], i); ++frag_cnt; } } @@ -202,7 +180,7 @@ void main() { // cusps float cusp_cos = abs(dot(dir, frag0.normal)); - float cusp_threshold = 2.*sqrt(ixn_threshold * sphere_list_internal[frag0.id].lt.s); + float cusp_threshold = 2.*sqrt(ixn_threshold * sphere_list[frag0.id].lt.s); float cusp_highlight = highlight * (1. - smoothstep(2./3.*cusp_threshold, 1.5*cusp_threshold, cusp_cos)); frags[i].color = mix(frags[i].color, vec4(1.), cusp_highlight); } diff --git a/app-proto/inversive-display/src/main.rs b/app-proto/inversive-display/src/main.rs index 5a9b875..a5bfedc 100644 --- a/app-proto/inversive-display/src/main.rs +++ b/app-proto/inversive-display/src/main.rs @@ -97,7 +97,7 @@ fn main() { let opacity = create_signal(0.5); let highlight = create_signal(0.2); let layer_threshold = create_signal(0.0); - let use_test_construction = create_signal(false); + let debug_mode = create_signal(false); // display let display = create_node_ref(); @@ -186,7 +186,7 @@ fn main() { let opacity_loc = ctx.get_uniform_location(&program, "opacity"); let highlight_loc = ctx.get_uniform_location(&program, "highlight"); let layer_threshold_loc = ctx.get_uniform_location(&program, "layer_threshold"); - let use_test_construction_loc = ctx.get_uniform_location(&program, "use_test_construction"); + let debug_mode_loc = ctx.get_uniform_location(&program, "debug_mode"); // create a vertex array and bind it to the graphics context let vertex_array = ctx.create_vertex_array().unwrap(); @@ -244,7 +244,7 @@ fn main() { ctx.uniform1f(opacity_loc.as_ref(), opacity.get() as f32); ctx.uniform1f(highlight_loc.as_ref(), highlight.get() as f32); ctx.uniform1i(layer_threshold_loc.as_ref(), layer_threshold.get() as i32); - ctx.uniform1i(use_test_construction_loc.as_ref(), use_test_construction.get() as i32); + ctx.uniform1i(debug_mode_loc.as_ref(), debug_mode.get() as i32); // draw the scene ctx.draw_arrays(WebGl2RenderingContext::TRIANGLES, 0, VERTEX_CNT as i32); @@ -329,11 +329,11 @@ fn main() { ) } div(class="control") { - label(for="use-test-construction") { "Use test values" } + label(for="debug-mode") { "Debug mode" } input( type="checkbox", - id="use-test-construction", - bind:checked=use_test_construction + id="debug-mode", + bind:checked=debug_mode ) } }