Homework 3 - Transformations, Instancing, Distribution Ray Tracing
In the third assignment of CENG795, we are expected to introduce many new features to the ray tracer, such as:
When a focal length and aperture size is given, I choose a random origin resides in aperture box for the ray. To calculate ray direction, I use samples from the image's focal plane instead of the near plane. I calculate focal plane by using triangle similarity. It causes blur for the objects further and nearer.
In this scene point light used instead of area light, <MotionBlur>-5 0 0</MotionBlur> is assigned to the sphere, used reflector material of the cornellbox_dynamic scene(no glossy reflection).
All of them are rendered on #8 threads.
- Transformations
- Instancing
- Smooth shading
- Distribution Ray Tracing
- Depth of field
- Soft shadows (area lights)
- Glossy reflections
- Motion blur
- Simple Camera(Constructed with fov, distance, and aspect ratio)
- PLY parsing
Transformations and Instancing:
First I implemented basic transformation classes and matrix operations. If a mesh instance, a sphere, or a primitive triangle has some transformations, I apply them to their bounding boxes for keeping the order of the bvh. For instancing, I separated mesh triangles and primitive triangles.
- Primitive triangles and spheres convert the ray into their local space to check if it intersects.
- Mesh instances converts the ray into local space of the their meshes to check if it intersects.
- Meshes and mesh triangles doesn't apply any transformation, they expect rays from their space.
- If an intersection is found after applying transformations, normal is transformed with inverse transpose of the transformation matrix.
- As default, all the meshes has a mesh instance, to keep the code homogeneous.
Smooth shading:
For smooth shading, I needed to calculate vertex normals for every vertex. To do it in linear time, I implemented a vertex class. While processing faces of the meshes, I add the normal of the triangle scaled by the surface area to the vertex normal(for the corner vertices of the triangle). After all calculations are done, I normalize the vertex normal. The reason of scaling is assigning proper weights to the different triangles.
Transformation, instancing and smooth shading
horse_instanced_flat, and horse_instanced_smooth scenes adapted from CENG477 HW2 scene horse_instanced.xml:
Transformation, instancing and smooth shading
horse_instanced_flat, and horse_instanced_smooth scenes adapted from CENG477 HW2 scene horse_instanced.xml:
horse_instanced_flat.xml 100 samples
horse_instanced_smooth.xml 100 samples
killeroo_glass.xml 16 samples
Depth of field:
When a focal length and aperture size is given, I choose a random origin resides in aperture box for the ray. To calculate ray direction, I use samples from the image's focal plane instead of the near plane. I calculate focal plane by using triangle similarity. It causes blur for the objects further and nearer.
spheres_dof.xml 100 samples
Soft shadows:
To achieve rendering soft shadows, I implemented rectangle area lights. Instead of using a constant point of the light as position, I randomly sampled the surface of the light. It causes softer transitions.
Glossy reflections:
To render materials which are imperfected reflectors, I implemented glossy reflections. To achieve this, I randomly perturb the reflection rays according to material's properties.
Soft shadows and glossy reflections:
Soft shadows and glossy reflections:
metal_plates_point.xml 36 samples
metal_plates_area.xml 36 samples
metal_plates_area.xml 900 samples
Motion blur:
For the real cameras, there is a shutter speed factor. It causes blur on the movement direction for the moving objects. To simulate that behaviour, I picked a random time point for the each sample. For each ray tree, I use its time point to determine positions of the moving objects. Rendering more samples causes less noise on the image.
In this scene point light used instead of area light, <MotionBlur>-5 0 0</MotionBlur> is assigned to the sphere, used reflector material of the cornellbox_dynamic scene(no glossy reflection).
metal_plates_dynamic.xml 900 samples
cornelbox_dynamic.xml 900 samples
cornellbox_boxes_dynamic.xml 900 samples
dragon_dynamic.xml 100 samples
PLY Parsing:
For ply parsing, I used tinyply. There is one simple proplem about tinyply. Tinyply doesn't support hybrid meshes uses both triangles and quads. I may change the parser in the future. I parse:
- Vertices
- Vertex Normals(if given)
- Face Normals(if given)
Miscellaneous:
Specifications and Benchmarking:
For this assignment, I prepared a cmake project for crossplatform building. I rendered scenes on a different computer.
CPU: Intel Core i7-6700 CPU @ 3.40GHz (4 Cores)
RAM: 16 GB
Operating System: Windows 10 64-bi
Platform Toolset: Visual Studio 2017 (v141)
Configurations: Release x64
All of them are rendered on #8 threads.
killeroo_glass.xml 16 samples
killeroo_glass.png(800x800) is saved in: 29 seconds 994 milliseconds 245 microseconds
horse_instanced_flat.xml 100 samples
horse_instanced_flat.png(800x400) is saved in: 20 seconds 668 milliseconds 636 microseconds
horse_instanced_smooth.xml 100 samples
horse_instanced_smooth.png(800x400) is saved in: 21 seconds 47 milliseconds 577 microseconds
spheres_dof.xml 100 samples
spheres_dof.png(800x800) is saved in: 11 seconds 2 milliseconds 338 microseconds
cornellbox_dynamic.xml 900 samples
cornellbox_dynamic.png(800x800) is saved in: 3 minutes 21 seconds 2 milliseconds 74 microseconds
cornellbox_boxes_dynamic.xml 900 samples
cornellbox_boxes_dynamic.png(750x600) is saved in: 2 minutes 7 seconds 804 milliseconds 240 microseconds
metal_plates_point.xml 36 samples
metal_plates_point.png(800x800) is saved in: 19 seconds 624 milliseconds 849 microseconds
metal_plates_area.xml 36 samples
metal_plates_area.png(800x800) is saved in: 1 minute 6 seconds 643 milliseconds 764 microseconds
metal_plates_dynamic.xml 900 samples (no roughness)
metal_plates_dynamic.png(800x800) is saved in: 6 minutes 21 seconds 213 milliseconds 532 microseconds
dragon_dynamic.xml 100 samples, max recursion depth 6
dragon_dynamic.png(800x480) is saved in: 4 minutes 24 seconds 183 milliseconds 971 microseconds
Excellent!
YanıtlaSilBu yorum yazar tarafından silindi.
YanıtlaSilThat is really really great, especially Budha . I liked the pink horse by the way :)
Sil