Ray-caster: remove hard-coded test construction
This commit is contained in:
parent
cbec31f5df
commit
bf140efaf7
2 changed files with 11 additions and 33 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue