Make the following changes to Program 16.10: (i) Move the box so that it is in front

Question:

Make the following changes to Program 16.10:

(i) Move the box so that it is in front of the sphere,

(ii) Make the box transparent/refractive, and the sphere reflective,

(iii) Move the checkerboard plane so that it is placed vertically behind the box and sphere. Try to place the objects so that both the sphere and the checkerboard plane are visible through the transparent box.

Program 16.10Compute Shader vec3 raytrace3(Ray r) { // this function is identical to raytrace() from Program 16.7 } vec3vec3 raytrace(Ray r) { m if (c.object_index == 1) { // generate a secondary ray for the intersection with thevec3 refracted_color; vec3 final_color; Ray ray; Collision collision; // holds the refracted color // final// The "push" function, which schedules a new raytrace by adding it to the top of the stack void push(Ray r,// The "pop" function, which removes a raytrace operation that has been completed Stack Element pop() { //// Five-phase processing of a given ray: (1) collision, (2) lighting, (3) reflection, (4) refraction, (5)break; PHASE 2-Phong ADS lighting computation stack[index].phong_color= ads_phong_lighting(r, c); break;PHASE 4-generate a refraction ray case 4: { if (stack[index].depth < max_depth) // stop if at max depth iffloat refraction_ratio = 0.66667; if (c.inside) refraction_ratio= 1.5; //1.0/refraction_ratio, when ray exitsif (c.object_index == 3) stack[index].final_color = stack[index].phong_color*rbox_color; if (c.object_indexreturn popped_stack_element.final_color; } // final color of the last-popped stack element

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question

Computer Graphics Programming In OpenGL With JAVA

ISBN: 9781683922193

2nd Edition

Authors: V. Scott Gordon PhD, John L. Clevenger PhD

Question Posted: