[SOLVED] 6.837 Assignment 6 Grid Acceleration Solid Textures

preview_player
Показать описание
Download Link:

In this assignment you will modify your ray tracer to use the grid from the previous assignment for fast ray casting. You will use your ray marching code and intersect all the objects stored in each traversed cell. You must pay attention to intersections outside the cell and implement early rejection to stop marching when you have found an appropriate intersection. To measure the performance improvement, you will analyze various statistics about your raytracer.

Finally, you will add new Material effects where the color of the material varies spatially using procedural solid texturing. This will allow you to render checkerboard planes and truly satisfy the historical rules of ray-tracing. Solid textures are a simple way to obtain material variation over an object. Different material properties (color, specular coefficients, etc.) vary as a function of spatial location.

Tasks
Use the provided static RayTracingStats class to compute various statistics including the number of pixels, the number of rays cast, the number of ray/primitive intersection operations, the number of cells in the grid, the number of grid cells traversed with the ray marching technique, and the total running time. Add the following timing and counter increment functions provided in the RayTracerStatistics class to your code:
raytracing_stats.h
raytracing_stats.C
Before beginning computation, call:

RayTracingStats::Initialize(int _width, int _height, BoundingBox *_bbox,
int nx, int ny, int nz);
For each non-shadow ray cast (a call to RayTracer::TraceRay()), call:

RayTracingStats::IncrementNumNonShadowRays();
For each shadow ray cast, call:

RayTracingStats::IncrementNumShadowRays();
For each ray/primitive intersection operation (each call to intersect for non-group and non-transform objects), call:

RayTracingStats::IncrementNumIntersections();
For each cell traversed (a call to MarchingInfo::nextCell()), call:

RayTracingStats::IncrementNumGridCellsTraversed();
From these numbers we can compute the average number of rays per pixel, primitive intersection calls per ray, grid cells per ray, rays per second, etc. Add support for an additional command line argument, -stats. If this option is specified, at the end of your rendering loop, print the various statistics by calling:

RayTracingStats::PrintStatistics();
Verify that the statistics are reasonable for simple test scenes without the grid, with and without shadows. Test this part of the assignment with examples from past assignments. Note that the number of rays cast and objects intersected can be predicted from the image resolution and number of objects in the scene.

Now use the grid as a spatial acceleration for your ray caster. Implement two ray casting methods, RayCast and RayCastFast. If no grid is specified at the command line, the grid will be NULL and you should use the non-accelerated ray casting method (RayCast) which simply loops through all the objects in the scene as in previous assignments. If a grid is specified at the command line (-grid nx ny nz) and -visualize_grid is not specified, use the accelerated ray casting method (RayCastFast), which marches along the ray through the grid and only tests the ray for intersection with objects in the current cell.
Make sure that you accelerate all your ray intersection routines, in particular do not forget shadow rays. Pay attention to objects that overlap multiple cells --- don't incorrectly return intersections outside of the current cell. Implementation of the marking strategy mentioned in lecture to avoid duplicate ray-primitive intersections for objects that overlap multiple cells is optional (extra credit).

Since infinite primitives (e.g., planes) should not be stored in the grid, you'll have to handle them separately. You'll probably want to add an extra Object3DVector to the Grid class to store these primitives. You will always compute the intersections with these primitives and compare them to the closest in-grid intersection.
Finish your implementation of the grid rasterization for scene hierarchies that include transformations (flattening the transformation hierarchy). You'll need to store the accumulated transformation matrix with each primitive. You can do this by creating a new Transformation that wraps around the primitive Object3D and store that in the Grid.
Рекомендации по теме
visit shbcf.ru