[Solved] CS180 Assignment6-Rendering image by ray tracing

$25

File Name: CS180_Assignment6-Rendering_image_by_ray_tracing.zip
File Size: 452.16 KB

SKU: [Solved] CS180 Assignment6-Rendering image by ray tracing Category: Tag:
5/5 - (1 vote)

In the second half of the class, we will focus on rendering image by ray tracing. One of the most important operations in ray tracing program is to find the ray-object intersection. Once we find an intersection of one ray, we can perform the shading and return the pixel color. In this assignment, we need to implement two parts: ray generation and ray-triangle intersection. The general work flow of the current code base is:

  1. Start from main We define the parameters of our scene. Add objects (spheres or triangles) to our scene, and set their material. Add the light sources to the scene.
  2. Call Render(scene) Inside a loop which iterates through all the pixels, generate rays, and save the returned color inside a framebuffer. Finally the framebuffer is saved inside an image.
  3. Later, we generate a ray through the pixel and call the CastRay function, which calls trace to find the intersection of ray and the closest object in the scene.
  4. Then we perform shading at this shading point. We have three different shading cases, and already provide the code for you.

The functions you should modify are:

  • Render() in the Renderer.cpp: You need to generate one ray for each pixel here, and call the function castRay(), which will return the color, and store the color in the corresponding pixel of the framebuffer.
  • rayTriangleIntersect() in the Triangle.hpp: v0, v1, v2 are the three vertices of the triangle, orig is the origin of the ray, dir is the direction(normalized) of the ray. tnear, u, v are the parameters (t, b1 and b2, respectively) that you need to update as the output of the Moller-Trumbore algorithm we derived in the class.

1 Getting started

In this assignment, you will have a new code base, the only dependency of the start code is CMake. We believe all of you are able to work on your own machine now.

Please download the projects skeleton code, and build the project by using the following commands:

$ mkdir build $ cd ./ build $ cmake . .

$ make j4

After this, you should be able to run the given code by using ./Raytracing.

There a few classes in our code base now. Some general introductions are:

  • hpp: Some functions or variables we use across the classes.
  • hpp: Since we no longer use the Eigen library, we provide the common vector operation here, such as: dotProduct, crossProduct, normalize.
  • hpp: The parent class of a primitive we can render. Triangle and Sphere classes are inherit from this base class.
  • hpp: Define the scene to be rendered. Including setting options and object list and lights list.
  • hpp: The main renderer class, which implements all ray tracing operations.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CS180 Assignment6-Rendering image by ray tracing
$25