I'm trying to do a simple ray tracing assignment, in c# (ported from python). I've managed to make the sample code show the correct picture, but when I try and adapt it to my assignment something goes wrong.
If I knew what was going wrong I would post some code that I thought might help, but I have no idea where to start.
Basically my assignment outputs something like this:
http://i56.tinypic.com/2vcdobq.png
With specular highlighting on, and
http://i53.tinypic.com/2e1r38o.png
With it off. It's suppose to look something like:
http://i56.tinypic.com/2m7sxlh.png
My Phong lighting formula looks like:
Colour I = diffuse_colour;
Vector L = light.vector;
Vector N = normal; //FIXME!
Colour Is = diffuse_colour * light.intensity;
Colour Ia = new Colour(1,1,1) * light.ambient;
Colour Kd = specular_colour;
Colour Ka = Kd;
double Ks = sharpness ?? 0.4;
Vector H = Vector.unit(view + L);
//Phong Illumination
//I = KaIa + KdIs max(0,L.N) + KsIs (H.N)^n
I = Ka * Ia
+ Kd * Is * Math.Max(0, L.dot(N))
+ Ks * Is * Math.Pow(H.dot(N),200); //FIXME?
And I copied it from the working sample code, so I know it works.
Any thoughts would be great, because I'm stumped.
You have two implementations of the same algorithm. You claim that they produce different results. Finding the mistake seems straightforward: run both algorithms step by step in their respective debuggers, simultaneously. Watch the state of both programs carefully. The moment they produce different program states, there's your bug.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With