100% Guaranteed Results


CENG477 – Assignment 1 – Ray Tracing Solved
$ 24.99
Category:

Description

5/5 – (1 vote)

CENG477
Introduction to Computer Graphics
Assignment 1 – Ray Tracing
(v.1.0)

1 Objectives
Ray tracing is a fundamental rendering algorithm. It is commonly used for animations and architectural simulations, in which the quality of the created images is more important than the time it takes to create them. In this assignment, you are going to implement a basic ray tracer that simulates the propagation of light in real world.
Keywords: ray tracing, light propagation, geometric optics, ray-object intersections, surface shading
2 Specifications
1. You should name your executable as “raytracer”.
2. Your executable will take an XML scene file as argument (e.g. “scene.xml”). A parser will be given to you, so that you do not have to worry about parsing the file yourself. The format of the file will be explained in Section 3. You should be able to run your executable via command “./raytracer scene.xml”.
3. You will save the resulting images in the PPM format. A PPM writer will be given to you so you don’t have to worry about writing this file yourself. Interested readers can find the details of the PPM format at: http://netpbm.sourceforge.net/doc/ppm.html
5. You will have at most 30 minutes to render scenes for each input file on inek machines. Programs exceeding this limit will be killed and will be assumed to have produced no image. Note that horse and mug scene is exempt from the 30-minute rule as it has a high object count, and it is optional to render.
6. You should use Blinn-Phong shading model for the specular shading computations.

where I is the original light intensity (a triplet of RGB values given in the XML file) and E(d) is the irradiance at distance d from the light source.
3 Scene File
· Every number represented by X, Y and Z is a floating point number.
· Every number represented by R, G, B, and N is an integer.
Explanations for each XML tag are provided below:
BackgroundColor: Specifies the R, G, B values of the background. If a ray sent through a pixel does not hit any object, the pixel will be set to this color. Only applicable for primary rays sent through pixels.
MaxRecursionDepth: Specifies how many bounces the ray makes off of mirror-like objects. Applicable only when a material is of type mirror. Primary rays are assumed to start with zero bounce count.
Camera:
·Position parameters define the coordinates of the camera.
·Gaze parameters define the direction that the camera is looking at. You must assume that the Gaze vector of the camera is always perpendicular to the image plane.
·Up parameters define the up vector of the camera.
·NearPlane attribute defines the coordinates of the image plane with Left, Right, Bottom, Top floating point parameters, respectively.
·NearDistance defines the distance of the image plane to the camera.
·ImageResolution defines the resolution of the image with Width and Height integer parameters, respectively.
·ImageName defines the name of the output file.
Cameras defined in this homework will be right-handed. The mapping of Up and Gaze vectors to the camera terminology used in the course slides is given as:
Up = v
Gaze = −w u = v × w
AmbientLight: is defined by just an X, Y, Z radiance triplet. This is the amount of light received by each object even when the object is in shadow. Color channel order of this triplet is RGB.
PointLight: is defined by a position and an intensity, which are all floating point numbers. Color channel order of intensity is RGB.
Material: A material can be defined with ambient, diffuse, specular, and mirror reflectance properties for each color channel. The values are floats between 0.0 and 1.0, and color channel order is RGB.
PhongExponent defines the specularity exponent in Blinn-Phong shading.
MirrorReflectance represents the degree of the mirrorness of the material. If the material is of type mirror, you must cast new rays and scale the resulting color value with the MirrorReflectance parameters. The attribute type=“mirror” is provided only for the materials which has non-zero MirrorReflectance.
VertexData: Each line contains a vertex whose x, y, and z coordinates are given as floating point values, respectively. The first vertex’s ID is 1.
Mesh: Each mesh is composed of several faces. A face is actually a triangle which contains three vertices. When defining a mesh, each line in Faces attribute defines a triangle. Therefore, each line is composed of three integer vertex IDs given in counter-clockwise order (see Triangle explanation below). Material attribute represents the material ID of the mesh.
Triangle: A triangle is represented by Material and Indices attributes. Material attribute represents the material ID. Indices are the integer vertex IDs of the vertices that construct the triangle. Vertices are given in counter-clockwise order, which is important when you want to calculate the normals of the triangles. Counter-clockwise order means that if you close your right-hand following the order of the vertices, your thumb points in the direction of the surface normal.
Sphere: A sphere is represented by Material, Center, and Radius attributes. Material attribute represents the material ID. Center represents the vertex ID of the point which is the center of the sphere. Radius attribute is the radius of the sphere.
4 Hints & Tips
1. Start early. It takes time to get a ray tracer up and running.
3. Try to pre-compute anything that would be used multiple times and save these results. For example, you can pre-compute the normals of the triangles and save it in your triangle data structure when you read the input file.
5 Bonus
1. You can get 5 points bonus if your ray tracer is among the fastest N ray tracers to be determined by our benchmarks. Number N is to be determined experimentally but you can expect it to be a small number such as 5. Of course, your outputs should be correct to be eligible for this bonus.
6 Regulations
2. Changing the Code Template: We provide you a code template. You are free to edit, rename or delete any file from the given code template as long as you comply with the submission rules below. However, keep in mind that any error introduced by the changes you made is your responsibility.
4. Submission: Submission will be done via ODTUClass. To submit, you must select an option in “HW Groups” page in ODTUClass according to the criteria in the Groups section below. Create a “tar.gz” file named “raytracer.tar.gz” that contains all your source code files and a Makefile. The executable should be named as “raytracer” and should be able to be run using the following commands (scene.xml will be provided by us during grading):
tar -xf raytracer.tar.gz make
./raytracer scene.xml
Any error in these steps will cause a 5 points penalty over 100 points.
5. Groups: You can team-up with another student. To form a group, both students must select the same group with 2 people capacity in “HW Groups” page on ODTUClass. If you want to work on the homework by yourself, in the same page select any “Individual Work” option which only have 1 person capacity. A selection must be made to upload the homework.
To prevent cheating in this homework, we also compare your codes with online ray tracers and previous years’ student solutions. In case a match is found, this will also be considered as cheating. Even if you take only a “part” of the code from somewhere or somebody else, this is also cheating. Please be aware that there are “very advanced tools” that detect if two codes are similar.
8. Forum: Any updates/corrections and discussions regarding the homework will be on ODTUClass. You should check it on a daily basis.
9. Evaluation: Your codes will be evaluated on Inek machines using various scene files, including but not limited to the test cases given to you as examples. We will not use automated grading, but evaluate your outputs visually. Therefore, tiny pixel value differences will not cause point loss. Rendering all scenes correctly within the time limit will get you 100 points.
7 Sample Scene File
<Scene>
<BackgroundColor>R G B</BackgroundColor>
<ShadowRayEpsilon>X</ShadowRayEpsilon>
<MaxRecursionDepth>N</MaxRecursionDepth>
<Cameras>
<Camera id=”Cid”>
<Position>X Y Z</Position>
<Gaze>X Y Z</Gaze>
<Up> X Y Z </Up>
<NearPlane>Left Right Bottom Top</NearPlane>
<NearDistance>X</NearDistance>
<ImageResolution>Width Height</ImageResolution>
<ImageName>ImageName.ppm</ImageName> </Camera>
</Cameras>
<Lights>
<AmbientLight>X Y Z</AmbientLight>
<PointLight id=”Lid”>
<Position>X Y Z</Position>
<Intensity>X Y Z</Intensity>
</PointLight>
</Lights>
<Materials>
<Material id=”Mid” [type=”mirror”]>
<AmbientReflectance>X Y Z</AmbientReflectance>
<DiffuseReflectance>X Y Z</DiffuseReflectance>
<SpecularReflectance>X Y Z</SpecularReflectance>
<MirrorReflectance>X Y Z</MirrorReflectance>
<PhongExponent>X</PhongExponent> </Material>
</Materials>
<VertexData>
V1X V1Y V1Z
V2X V2Y V2Z
…………………
</VertexData>
<Objects>
<Mesh id=”Meid”>
<Material>N</Material> <Faces>
F F F
</Faces>
</Mesh>
<Triangle id=”Tid”>
<Material>N</Material>
<Indices>
V1 V2 V3
</Indices>
</Triangle>
<Sphere id=”Sid”>
<Material>N</Material>
<Center>N</Center>
<Radius>X</Radius>
</Sphere>
</Objects> </Scene>

Reviews

There are no reviews yet.

Be the first to review “CENG477 – Assignment 1 – Ray Tracing Solved”

Your email address will not be published. Required fields are marked *

Related products