Wednesday, February 27, 2008

Code Up

Here's a link to my code.

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.

Monday, February 25, 2008

Final Product

Hey everyone, I feel very good about finishing this project (even if I did have to use a week's worth of late days!) While completing this, I learned a ton of vector math, C++ programming and got to know a fellow grad student better, Nate Gaunt. Here's what I've got:


specular reflection coefficient (ks) = 0.5
No clamping Needed


This is without clamping the overflow values - noticed the distortion on the specular highlight
specular reflection coefficient (ks) = 1.0

So, I would like to calculate the correct normal on my triangles; I'm pretty sure that's why no light is reaching it. Also, the images are rendered upside down (like a real pinhole camera!) This would be something good to change. Even after inverting the image, I'm still a little unclear of why the specular highlights aren't directly facing the camera - I'm pretty sure they should be.

frost@localhost ~/cs534/assignment_3 $ time g++ World.cpp

real 0m25.019s
user 0m2.550s
sys 0m0.300s

25 seconds to compile! I have about 20 .h files and about 5 .cpp files, all of which are including each other. Good thing I used #ifndef __CLASS__ and #define __CLASS__ checks.

frost@localhost ~/cs534/assignment_3 $ time ./a.out
Ambient Constructed2 argument constructor

real 0m18.004s
user 0m5.170s
sys 0m0.190s

Only 20 seconds to run. This is on a old P4 running a crappy kernel (I need to build a new one; genkernal = slow).

frost@localhost ~/cs534/assignment_3 $ cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 15
model : 0
model name : Intel(R) Pentium(R) 4 CPU 1800MHz
stepping : 10
cpu MHz : 1794.705
cache size : 256 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 2
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm up
bogomips : 3591.96



Sunday, February 24, 2008

Additional Images






Looking Good!

My images are starting to look good! Here are a couple with Matte shading; switching out to Phong shading shouldn't be much more difficult due to the (somewhat) modular nature of my program.



Correctly Shaded Image - but really dark - More Coming Soon!

Closer with the shading - possiby using an uninitalized variable somewhere?

I've been working solid since the last post. Here's where I'm at:


Shading Looking Weird...


I've been working for a couple of hours this morning and the shading isn't looking quite right:



Saturday, February 23, 2008

Some Progress Today

Hey Hey,

I think I have a decent idea about the lighting model for matte and spectral lighting. I am going to spend another hour or so working through what I need to implement to get matte lighting working, and then hopefully implementation will be quick. Things are looking better. I found an error in my color routines, so my shapes don't look so bad. Still, my image is upside down and I'm not totally sure why, but hey, I'm implementing a pinhole camera right!?!?




I'll post the code, so you too can build such beautiful images!

Assignment 3 : An Update

This assignment has been extremely difficult so far. Luckily, we have one "late pass" to use over the semester. We can turn in an assignment by the time the next one is due. I plan on using it for this project. Joe Kniss, the graphics professor, is an extremely cool guy and a great lecturer. Never before have I had a math teacher/professor that makes the mathematics so interesting. I've been working like mad on this project, but the C++ and vector math aren't something I'm used to. For the past two years, I haven't dealt with memory management at all (I like Python & Java.)

Tonight I finished the perspective view and all the object stuff. All the math was worked out a couple of days ago, but I was fighting C++ (and idiot mistake) bugs a lot. I had a pass-by-value method that I thought was pass by reference, even thought I wasn't de-referencing any pointer... The other big mistake I corrected tonight was the fact that I was using the center point I calculated for my view plane, BEFORE I actually calculated what that center point was. It was awfully "nice" that the Point3D class I am using allows that, but hey I could always write error checking. Any sort of assertion or some error checking would have been good. The bugs weren't too bad, but I kept second guessing myself with all the math, so everything took basically the entire day to get basic shapes up. 10 hours of programming today (and about 50 from earlier), and I don't have too cool of a picture yet.



Just an intermediate result, more coming soon!

My girlfriend Kate has been extremely nice to me during the self-imposed hermitage of ray tracing. I had two laundry pickups and drop offs, lots of kisses, hugs and massages. Once I get this assignment done, I am going to take her someplace nice to eat and hopefully to a romantic evening.

Saturday, February 16, 2008

Computer Graphics : Ray Tracing

This semester I am taking a course titled "Advanced Computer Graphics : Vector Graphics" which totally focuses on ray tracing. For the course, we are simulating light rays as they intersect objects. One of the requirements for our third assignment is to place all of our deliverables on a website. Since I've set up then entire blogger/analytics/adsense package with Google, I figured this would be a great place to put everything.