hw2

advertisement
Image Synthesis (236373)
Homework Assignment #2
Due date: 26/11/2013
____________________________________________________________________________
Introduction
In this exercise you are required to develop an as-efficient-as-possible ray-caster, which
incorporates a simple global illumination model. Your implementation should handle scenes
consisting of triangulated objects and you should output the resulting image as computed by
your ray tracer. Furthermore, a performance evaluation report should be generated.
Objectives
Your goal is to implement a basic ray-caster as part of your on-going skeleton. The “raytrace”
command will execute your ray tracer and should have the following syntax:
raytrace –w 1920 –h 1080 –n 1 –s 1
Where –w / -h is the width / height of the output image, the default values should be 1920x1080.
The voxel factor is passed through the –n flag, a voxel factor of n voxels per dimensions means
a total of 𝑛3 voxels and you should use a default value of 0 (no voxelization). The last parameter
is –s, the supersampling value and the default is 1 (no supersampling).
You should set/load a scene with various objects and define a default camera from which you
will view the scene. Your ray tracing algorithm should take into account the following camera
properties: position, direction and view angle (see in MFnCamera: eyePopint, viewDirection,
focalLength, horizontalFilmAperture). You must also add light sources to the scene, each of
them is defined by its position and RGB emitted light. Your code should support ambient,
directional and point light sources. When your scene is ready you can move on to the
implementation of the ray caster.
The raycasting algorithm is composed of the following components:

Implement uniform space partitioning by voxelization, as learned in class.

Implement regular supersampling on a regular grid inside every pixel

Implement texture mapping with a bi-linear filter.

Shoot rays from the default camera onto the screen

Traverse each ray until an object is being hit

Compute shadow rays from each hit point to a light source
Along with the output image, your plugin should also produce a performance report printed into
a text file with the following fields:
Time performance counters
Preprocessing time before actual ray casting (seconds)
prepTime
Ray-casting time (seconds)
renderTime
Total time (seconds)
totalTime
Average rendering time per pixel (seconds)
timePerPixel
timePerPixelDeviation Standard deviation of the rendering time per pixel (seconds)
Object counters
Total number of polygons in the scene
polygons
Intersection optimizations performance counters
Average number of polygons per ray tested for intersection
polygonsPerRay
Average number of voxels traversed per ray
voxelsPerRay
Total number of ray-polygon intersection tests made
intersectionTests
Percentage of intersection tests that actually compute intersection point
Intersections
Your own performance counters
Describe their meaning and values
…
Tips and General Guidelines

The view angle of a camera can be obtained from its horizontal film aperture and its focal
𝑑
length by the following relation: 𝛼 = 2𝑎𝑟𝑐𝑡𝑎𝑛 2𝑓 , where 𝛼 is the horizontal view angle, 𝑑 is
the horizontal film aperture and 𝑓 is the focal length. See also here View Angle.

Non-polygonal objects are to be triangulated. Make sure every object in the scene has only
triangular faces. Check polyTriangulate in Autodesk API guide.

Timers in Maya API can be utilized through MTimer.

Note: you are not allowed to use the method closestIntersection and we expect you to
implement a similar method from scratch.

When grading your software, we will focus on correctness and speed. Please consider those
parameters as crucial guidelines when you design your solution.

Please test your algorithm with simple and complex scenes. You should verify that the result
makes sense. Potentially you can debug your code with the built-in ray tracer in Maya.

If you have any questions please post them in the Q/A Piazza forum under HW2.
We also intend to publish useful tips through this forum, so try to keep updated.
Submission
The assignment can be done in either pairs or singles. Please submit a single zip file using the
electronic submission button in the course’s website. Your file should contain the project code,
the compiled plugin .MLL file in Release mode (64 bit) and the report. Your report should
contain instructions on how to use your ray-caster. Please explain any related parameters.
Moreover, you should include in your report images of some (at least 2) interesting scenes.
Good Luck!
Download