Skip to content
Snippets Groups Projects
Commit 4304f8b2 authored by Katharina Krämer's avatar Katharina Krämer
Browse files

[#94] added plane to scene

parent 44a4faf3
No related branches found
No related tags found
1 merge request!77Resolve "SAF-R Module"
Pipeline #27199 passed
...@@ -89,7 +89,7 @@ bool rayIntersect(const vec3 origin, const vec3 dir, out float t0, const int id) ...@@ -89,7 +89,7 @@ bool rayIntersect(const vec3 origin, const vec3 dir, out float t0, const int id)
Intersection sceneIntersect(const vec3 rayOrigin, const vec3 rayDirection) { Intersection sceneIntersect(const vec3 rayOrigin, const vec3 rayDirection) {
//distance if spheres will be rendered //distance if spheres will be rendered
float min_d = 100000; // lets start with something big float min_d = 1.0 / 0.0; // lets start with something big
Intersection intersection; Intersection intersection;
intersection.hit = false; intersection.hit = false;
...@@ -109,6 +109,19 @@ Intersection sceneIntersect(const vec3 rayOrigin, const vec3 rayDirection) { ...@@ -109,6 +109,19 @@ Intersection sceneIntersect(const vec3 rayOrigin, const vec3 rayDirection) {
} }
} }
} }
float checkerboard_dist = min_d;
if (abs(rayDirection.y)>1e-3) {
float d = -(rayOrigin.y + 4) / rayDirection.y; // the checkerboard plane has equation y = -4
vec3 pt = rayOrigin + rayDirection * d;
if (d > 0 && abs(pt.x) < 10 && pt.z<-10 && pt.z>-30 && d < min_d) {
checkerboard_dist = d;
intersection.hit = true;
intersection.pos = pt;
intersection.N = vec3(0, 1, 0);
intersection.material = inSpheres[1].material;
}
}
return intersection; return intersection;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment