I could use some help with photon mapping

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Search this Thread Display Modes
  12 December 2012
I could use some help with photon mapping

Hey Everyone,

I'm new to the forums here so first I'd like to say hello. I'm currently a computer science student studying on the west coast with an interest in computer graphics.

Currently I'm in the middle of implementing a photon map for a ray tracing program I built but I'm having a few issues. My first issue is that I don't feel like the photons in my global photon map are being dispersed properly. Below is a link to a picture of my own photon map with the photons rendered directly followed by a picture I found online of the same thing. I couldn't upload my picture here directly so please follow the link.

My picture:

Online picture:

Mine is lacking in a lot of places. 1) there aren't as many bright/white photons. 2) The photons in the shadows under the balls aren't as even and 3) it seems like photons are bunching up on the edges between walls on mine.

I've posted below the code to the function I wrote that traces photons throughout my 3D scene. I really appreciate any help or advice you guys have to offer!

Quote: void PhotonMap::TracePhoton(Photon photon, int level)
if(level >= 15) return;

Intersection *hit = photon.ray.FindIntersection(Objects, 0);
if(hit != NULL)
Ray temp;
photon.pos = hit->point;

/**Material properties of the hit surface**/
STColor3f spec = hit->mat->GetSpecular();
STColor3f diff = hit->mat->GetDiffuse();
STColor3f mirr = hit->mat->GetMirror();
float refract = hit->mat->GetRefract();
float gloss = hit->mat->gloss;
hit->mat->gloss = 10.0;

float Pr = Max(diff, spec); //Probability of reflecting
float Pd = Probability(diff, spec) * Pr; //Diffuse probability
float Ps = Probability(spec, diff) * Pr; //Specular probability
float random = (float)rand()/(float)RAND_MAX;

if(random >= 0 && random < Pd)
diff /= Pd;
photon.col = photon.col*diff;
photon.ray = temp;
hit->mat->gloss = gloss;
TracePhoton(photon, level);
} else if(random >= Pd && random < Pd + Ps)
spec /= Ps;
photon.col = photon.col*spec;
photon.ray = temp;
hit->mat->gloss = gloss;
TracePhoton(photon, level);
} else if(random >= Pd + Ps && random <= 1.0f)
float dx = photon.ray.GetD().x / photon.ray.GetD().Length();
photon.theta = 255.0f*acos(dx) / 3.14159f;
photon.ray = temp;
if(mirr.r == 0 && mirr.g == 0 && mirr.b == 0 && refract == 0)
photon.col = (photon.col * (diff/Pd));
photon.ray = temp;
hit->mat->gloss = gloss;
TracePhoton(photon, level);
  12 December 2012
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 12:49 AM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.