Ray-caster: correct hit detection

This commit is contained in:
Aaron Fenyes 2024-08-28 01:59:46 -07:00
parent 3d7ee98dd6
commit e80adf831d

View File

@ -141,11 +141,11 @@ void main() {
int frag_cnt = 0;
for (int i = 0; i < sphere_cnt; ++i) {
vec2 hit_depths = sphere_cast(sphere_list[i], dir);
if (!isnan(hit_depths[0])) {
if (hit_depths[0] > 0.) {
frags[frag_cnt] = sphere_shading(sphere_list[i], hit_depths[0] * dir, color_list[i], i);
++frag_cnt;
}
if (!isnan(hit_depths[1])) {
if (hit_depths[1] > 0.) {
frags[frag_cnt] = sphere_shading(sphere_list[i], hit_depths[1] * dir, color_list[i], i);
++frag_cnt;
}