Posts

Part 4: Texture, Normal and Bump Mapping & Perlin Noise

Image
The fourth part of the ray tracer is all about textures. For this part, the following features are introduced: 1. Texture Mapping In this version of the ray tracer, three types of textures ( Image , Perlin and Checkerboard textures) are supported. For this reason, I decided to implement a base Texture class, and three derived classes called ImageTexture , PerlinTexture and CheckerboardTexture . For texture mapping, there are several options for using the color value obtained from the texture:   - Replace all: Disable all shading computations and just paste the texture color on the object.   -  Replace kd: Normalize the color value obtained from the texture to [0,1] range and use it as the diffuse reflectance constant (kd) directly.   - Blend kd: Normalize the color value obtained from the texture to [0,1] range and take the average of the obtained value and the provided diffuse reflectance constant (kd). Use this value as the new kd.   - Replace backgroun...

Part 3: Transformations, Instancing, Multisampling & Distribution

Image
For the third part, a lot of new features are introduced to the ray tracer. 1. Transformations In order to implement transformations, firstly I implemented a Matrix4f class which is able to support basic matrix operations such as inverse, transpose, multiplication with another matrix or a vector etc. Three types of transformations which are Translation , Rotation and Scaling are supported in this new version of the ray tracer. While parsing the scene, final Transformation Matrices are stored for each object, which will be used for transforming Rays , Hits and BoundingBoxes later. For meshes, the transformation matrix is stored only for the main mesh object, not for all of its children triangles. In addition, for transforming bounding boxes, transformations are applied to all 8 corners of the bounding box and the new bounding box is computed based on these new corners, instead of applying the transformations directly to the min and max corners. To intersect rays with the transformed...

Part 2: Recursive Ray Tracing & Bounding Volume Hierarchy

Image
For the second part of the ray tracer, two new features are added to my basic ray tracer: 1. Recursive Ray Tracing ( Reflection & Refraction ) 2. Bounding Volume Hierarchy Besides these core features, the new ray tracer also supports the following: 1. PLY File Parsing As the core ray tracer is improved, it will be able to deal with more and more complicated scenes and larger meshes. Since most of these advanced scenes are represented using PLY files, this version of the ray tracer also provides support for PLY file format. For parsing PLY files, an external library called hapPLY is utilized. 2. LookAt Camera In the previous version, only the simple camera model where the image plane is represented by left, right, top and bottom parameters was supported. With this version, the ray tracer also supports LookAt Camera model where image plane is described by the angle called fovy and it is assumed that the image plane is centered with respect to the camera position. While parsing the...

Part 1: Basic Ray Tracer

Image
In the first assignment, we are expected to implement a basic ray tracer which supports the following features: 1. XML Parsing  & Storing a Scene:       A Scene is provided to the ray tracer as input, which is defined as an XML file. So, the first thing to do is parsing this input XML file and storing the Scene in a convenient way. For XML parsing task, an external library called TinyXML-2 is utilized. For now, a Scene consists of Cameras , Point Lights , Materials , Objects and their related Vertex Data . 2. Simple Perspective Camera Model:       For the first version of the ray tracer, only the simple perspective camera model is supported. In the input files, it is not guaranteed that the camera vectors are provided as orthogonal unit vectors, so they are converted to orthogonal unit vectors by the ray tracer to make sure that the camera parameters are set correctly. 3. Ray-Object Intersections:       Currently, there are 3 type...