11 ray_dist =
planeT(ray, vec3(0, 0, 1), 1);
14 if (abs(hit_p.x) <= 0.5 && hit_p.y >= -0.5 && hit_p.y <= 0.5) {
17 h.normal = vec3(0, 0, -1);
19 h.emission = vec3(5.0);
26 if (abs(hit_p.x) <= 1.0 && hit_p.y >= -1.0 && hit_p.y <= 1.0) {
29 h.normal = vec3(0, 0, 1);
46 h.normal = vec3(0, 0, 1);
47 h.geom_normal = vec3(0, 0, 1);
57 ray_dist =
planeT(ray, vec3(0, 0, 1), 1);
60 if (abs(hit_p.x) <= 0.5 && hit_p.y >= -0.5 && hit_p.y <= 0.5) {
63 h.normal = vec3(0, 0, -1);
64 h.geom_normal = h.normal;
66 h.emission = vec3(5.0);
73 if (abs(hit_p.x) <= 1.0 && hit_p.y >= -1.0 && hit_p.y <= 1.0) {
76 h.normal = vec3(0, 0, 1);
77 h.geom_normal = h.normal;
87 if (abs(hit_p.x) <= 1.0 && hit_p.y >= -1.0 && hit_p.y <= 1.0) {
90 h.normal = vec3(0, 0, -1);
91 h.geom_normal = h.normal;
101 if (abs(hit_p.x) <= 1.0 && hit_p.z >= -1.0 && hit_p.z <= 1.0) {
104 h.normal = vec3(0, -1, 0);
105 h.geom_normal = h.normal;
107 h.emission = vec3(0);
113 if (ray_dist < h.t) {
115 if (hit_p.y >= -1.0 && hit_p.y <= 1.0 && hit_p.z >= -1.0 && hit_p.z <= 1.0) {
118 h.normal = vec3(1, 0, 0);
119 h.geom_normal = h.normal;
121 h.emission = vec3(0);
127 if (ray_dist < h.t) {
129 if (hit_p.y >= -1.0 && hit_p.y <= 1.0 && hit_p.z >= -1.0 && hit_p.z <= 1.0) {
132 h.normal = vec3(-1, 0, 0);
133 h.geom_normal = h.normal;
135 h.emission = vec3(0);
140 const vec3 sphere_left_center = vec3(0.20, -0.3, -0.65);
141 ray_dist =
sphereT(ray, sphere_left_center, 0.35);
142 if (ray_dist < h.t) {
145 h.normal = normalize(h.pos - sphere_left_center);
146 h.geom_normal = h.normal;
148 h.emission = vec3(0);
155 ray_dist =
boxT(ray,vec3(-0.50, 0.4, -0.6), vec3(0.30, 0.30, 0.30), -10.0, 30.0, box_normal);
159 h.normal = box_normal;
160 h.geom_normal = h.normal;
162 h.emission = vec3(0);
168 const vec3 sphere_right_center = vec3(0.1, -0.0, -0.20);
169 ray_dist =
sphereT(ray, sphere_right_center, 0.30);
170 if (ray_dist < h.t) {
173 h.normal = normalize(h.pos - sphere_right_center);
174 h.geom_normal = h.normal;
176 h.emission = vec3(0);
bool intersects_cornell(const Ray ray, out Hit h)
Tests ray intersection with a described scene.
Definition cornell_scene.glsl:43
float planeT(Ray ray, vec3 normal, float offset)
Definition intersection.glsl:3
float planeT_Y(Ray ray, float offset)
Specific Y-axis plane, with only offset.
Definition intersection.glsl:26
float sphereT(Ray ray, vec3 center, float radius)
Definition intersection.glsl:54
float boxT(Ray ray, vec3 center, vec3 half_size, float pitch, float yaw, out vec3 out_normal)
Definition intersection.glsl:87
float planeT_X(Ray ray, float offset)
Specific X-axis plane, with only offset.
Definition intersection.glsl:19