Skip to main content

Posts

Showing posts from 2019

Beyond Ray tracer - Part 2

In my previous post I updated the render to allow perspective projection. This time I will move forward, and introduce 3 important updates: The construction of the Cornell Box Fortunately the Renderer already provides functionality to create and display meshes. From this, I have created 2 base objects, A box and Plane. Both objects are of a unit size. The Use of materials Making proper "realistic" ray tracer involves more than having objects with color. I have created a new structure called Material , containing additional properties, like Specular power, and Specular strength. In the following posts I will extend the material to include other properties, like BRDF, used to provide a more accurate physical light simulation. The result is a Cornell Box, only accounting for Diffuse and Specular components. Note that this box doesn't have the dimensions, or material properties of the official Cornell Box. Direct Lighting in a Cornell Box Depth rende...

Beyond Ray Tracer - Part 1

The simple ray tracer has been completed. Now what? It seems that I had already some spare time, so I have decided to move a bit further with the Ray Trace Renderer. My goal is to create a Ray Trace Renderer to render a Cornell Box (Should I consider it as the equivalent to a Diploma in computer graphics?) This Renderer will feature both Direct and Global Illumination. Keep in mind that, in order to keep it simple, I will not include reflections and caustics. The whole Rendering will be processed by the CPU (multi-threaded at most). It's not my intention to use GPU in this iteration. Getting hands dirty First step is to restructure the code, like making it more object oriented, and splitting the project into different files (not a single file, as it was currently) Second step is to extend the variety of Graphic Objects, not only to having Spheres, but in general for any kind of triangle based meshes. Graphic Objects A Graphic Object interface will hold some generic...

Simple Ray Tracer - Part 3

Specular Lighting Specular lighting is the reflection of the light's color on the surface, and projected on the screen (or the viewers point of view). In the Phong lighting model the Specular contribution to the light is defined as a relation between the vector from the camera to the surface, and the normal to the surface. When the light hits the surface, it's reflected along the surface normal. Then, the angle formed between the reflected light vector and the screen vector is used to calculate the Specular component of the surface. The Formula in the Phong model is expressed in the following snippet: Vec3 CalculateSpecular(Vec3 const & intersect, Vec3 const & n, Vec3 const & viewDir) const { Vec3 specular = color; Vec3 lDir (position.x - intersect.x, position.y - intersect.y, position.z - intersect.z); lDir.Normalize(); double dDotN = 2 * dotP(lDir, n); Vec3 reflection = n; reflection *= dDotN; ref...