Friday, May 16, 2008
Wednesday, May 14, 2008
Monday, May 12, 2008
Quite Possibly my ray tracing final project
(real 21m42.207s - Somewhat low-res star texture)
Sunday, April 27, 2008
Saturday, April 26, 2008
Transparancy + Reflection

Extremely High Resolution Image (2048 x 2048 -- 128 samples / pixel -- rendering time : real 279m22.153s, a bit over 4 hours)
This is the first image that I generated with spheres of different index of refraction, and ratio of reflectance to transmission. Overall, I think it looks pretty cool. There are a few minor changes I would like to make, but they shouldn't take too long. The sky needs to be changed from my polluted sky brown to a beautiful blue, the small middle sphere looks like it is getting clipped by the camera and the two upper spheres need more reflectance. This was still a ton of work getting here.

I like the color of the balls visible in this one

A box and a sphere

Messing with a transparent sphere and box

Some reflection


One of the passes at multiple spheres - after getting this far scene layout is taking a while

Index of refraction = 1.0, with some phong shading going on

Totally reflective - but still phong shaded
Sunday, April 13, 2008
Axis Aligned Boxes - Stage 1 Complete!

Pass 3 - Axis Aligned Box floating above the plane (rather than bisected)
Saturday, April 12, 2008
General Cleanup on Phong Shading
Coming soon : Dielectrics!
Thursday, April 3, 2008
Acceleration Data Structure - Bounding Volume Hierarchy
The basic binary tree stuff is sort of from here, but I wrote my own search routine and modified the code a bit.
The major point that could be improved on this is the splitting. Instead of alternating between the dimensions that I split on, I could write a method that determines the best way to split (based on the equality of the triangles in each subdivision.)
I spent a while getting this page to display in a somewhat aesthetic manner. Copy and paste between Kate and Firefox doesn't always look so great, and my blogger template doesn't lend itself to major widening my posts very well.
For a .tar.gz of this current revision, you can download one here. For the acceleration data structure, check out Object.cpp and Object.h.
1 Box (single bounding box)
real 0m24.015s
user 0m12.120s
sys 0m0.070s
2 Boxes -
real 0m16.169s
user 0m8.080s
sys 0m0.030s
16 Boxes -
real 0m9.564s
user 0m5.310s
sys 0m0.050s
From 1 bounding box to 2 it is very easy to see the running time getting cut in half. From 2 to 16, there is not such an obvious speed up. I believe this is because we have to traverse more levels of our tree (not too much locality) verse iterate through bigger triangle vectors (more locality.) If my model had more triangles, I think we would still see an exponential decrease in running time as we increase the number of leaves in the binary tree.
void Object :: BuildLevels(TreeNode * rootNode, int currentDepth, int splitDimension){
cout << "debugging = " << debugging << "\n";
debugging = debugging + 1;
cout << "currentDepth = " << currentDepth << "\n";
assert (rootNode->item != NULL);6
BoundingBox parentBox = *(rootNode->item);
int maxDepth = 16;
TreeNode * left, * right;
left = new TreeNode();
right = new TreeNode();
rootNode->left = left;
rootNode->right = right;
BoundingBox * leftBox, * rightBox;
Point3D smallPoint = parentBox.getSmallPoint();
Point3D bigPoint = parentBox.getBigPoint();
if (splitDimension == 0){
// split along x
float halfx = (parentBox.getSmallPoint().x + parentBox.getBigPoint().x) / 2;
// Let's start with the smaller box along an x cut
// it is defined by the smallest origional point and
// the x-cutpoint, y-maxPoint and z-maxpoint
leftBox = new BoundingBox(smallPoint, Point3D(halfx, parentBox.getBigPoint().y,parentBox.getBigPoint().z));
// the right box is defined by the x-cutpoint, y-minPoint,
// z-minPoint and the bigPoint from the origional box
rightBox = new BoundingBox(Point3D(halfx, parentBox.getSmallPoint().y, parentBox.getSmallPoint().z), bigPoint);
}
if (splitDimension == 1){
// split along y
float halfy = (parentBox.getSmallPoint().y + parentBox.getBigPoint().y) / 2;
leftBox = new BoundingBox(smallPoint, Point3D(bigPoint.x, halfy, bigPoint.z));
rightBox = new BoundingBox(Point3D(smallPoint.x, halfy, smallPoint.z), bigPoint);
}
if (splitDimension == 2){
// split along z
float halfz = (parentBox.getSmallPoint().z + parentBox.getBigPoint().z) / 2;
leftBox = new BoundingBox(smallPoint, Point3D(bigPoint.x, bigPoint.y, halfz));
rightBox = new BoundingBox(Point3D(smallPoint.x, smallPoint.y, halfz), bigPoint);
}
left->item = leftBox;
right->item = rightBox;
// let's go through all the triangles in the root and
// assign them to the left box, right box or both.
for (int i = 0; i <>triangles.size(); i++){
Triangle * myTriangle =rootNode->triangles[i];
if (triangleInsideBox(myTriangle, *leftBox) == true){
// add the triangle to the left box
left->triangles.push_back(myTriangle);
}
if (triangleInsideBox(myTriangle, *rightBox) == true){
right->triangles.push_back(myTriangle);
}
if ((triangleInsideBox(myTriangle, *rightBox) == false) && (triangleInsideBox(myTriangle, *leftBox) == false)){
cout << "ERROR!!! TRIANGLE IN NEITHER BOX!" << "\n";
}
}
if (currentDepth < maxDepth){
BuildLevels(left, currentDepth + 1,(splitDimension + 1) % 3);
BuildLevels(right, currentDepth + 1,(splitDimension + 1) % 3);
rootNode->triangles.clear();
}
else{
cout << "number of boxes in leaf = " << rootNode->triangles.size() << "\n";
}
}
Monday, March 17, 2008
.OBJ Loading Up
With the help of the two Nate's (Nate Gauntt helping with indexing into Nate Robbins GLM stuff) I was able to load in .obj files.
This took a while to render:
real 5m35.747s
user 4m45.890s
sys 0m2.280s
.OBJ model can be found here. Source is will be here (once the UNM CS network is up, that is.)
Saturday, March 8, 2008
Done - until refactoring
Sphere with Cool Texture by Autumn Stinar
Earth + Plane
Friday, March 7, 2008
Tiled Plane = Super Easy to test Anti-Aliasing
I used a completely square image that tiles perfectly. Here's the tile pattern I used (thanks Nate Gauntt):
Thursday, March 6, 2008
Thanks Nate!
tmpColor = RGBVector[width * vertical + horizontal]; // correct
tmpColor = RGBVector[height * vertical + horizontal] // totally wrong
Square Textures = Perfect, still some issues with non-square textures
Spherical mapping from a square texture to a sphere is at 100%. Check out the grid texture below Nate Gauntt send me for testing and it perfectly mapped to the sphere.
Tuesday, March 4, 2008
Anti-Aliasing Looking Good!
Here's an image I generated from an Earth texture @ 16 samples per pixel. However, I massively shrunk the original image. When I use my giant earth image, I am still getting some moray aliasing patters. I think I'll up the number of samples to 64 or 128 and try with the giant image.
....
RGBColor pixelColor = RGBColor(0,0,0);
int num_samples = 16;
float inv_num_samples = (1 / (float)num_samples);
RGBColor tmpColor;
for (int r = 0; r < c =" 0" o =" myWorld.ViewPlane.eyePoint;" count =" 0;" random1 =" (" random1 =" random1" random2 =" (" random2 =" random2" d =" myWorld.ViewPlane.from_screen_to_world(c+random1," tmpcolor =" myWorld.trace_ray(ray);"> 1){
tmpColor.r = 1.0;
}
if (tmpColor.g > 1){
tmpColor.g = 1.0;
}
if (tmpColor.b > 1){
tmpColor.b = 1.0;
}
tmpColor = tmpColor * inv_num_samples;
pixelColor = pixelColor + tmpColor;
}
myWorld.myfile << " " << (ceil( 255 * pixelColor.r)) << " " << (ceil( 255 * pixelColor.g)) << " " << (ceil( 255 * pixelColor.b)) << " "; // Don't forget to zero this out! This jacked me up bad. pixelColor = RGBColor(0, 0,0); ....
Sphere Texturing Done - Just need Anti-Aliasing

If people like checking this stuff out, leave me a comment! I've seen some hits from all over the world on this, and I would like to hear what you guys think.
Sunday, March 2, 2008
Looking Better
Ultimately, I realize that the Z-axis and Y-axis are incorrectly labeled in my code (they are switched). This hasn't been noticeable before, due to the self similar nature of all the objects I have ray-traced, but it explains why my relative positions look a little different than my class mates. Now, because of the above property, it makes a huge difference. I was repeating the texture below and above the equation.
200 x 200 texture
Attempt at Texture Mapping on a Sphere
The red around the border is intentional - I was concerned with accessing elements of my image in a non sequential way, I thought this was the source of my problem. However, the non sequential accesses are as they should be, right around the edges of the sphere where I wrap around to the other side to get my texture.
Wednesday, February 27, 2008
Code Up
Download it
A lot of the basic math stuff was taken from this guy, who wrote the book I paid almost $100 for. Since I signed up with amazon's referal program, I will have a link up soon for everyone to purchase the book from.
Next up is antialiasing and texture mapping. My plane will have a checkerboard and my sphere will have a texture of the earth. I hope everyone enjoys.


































