# I could use some help with photon mapping

 12 December 2012 ChrisFontas New Member portfolio Chris Fontas Stanford, USA 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; level++; Intersection *hit = photon.ray.FindIntersection(Objects, 0); if(hit != NULL) { Ray temp; temp.SetE(photon.pos); temp.SetD(photon.ray.GetD()); temp.SetEnd(temp.GetE()+temp.GetD()); 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; temp.Reflect(hit); photon.ray = temp; hit->mat->gloss = gloss; TracePhoton(photon, level); } else if(random >= Pd && random < Pd + Ps) { spec /= Ps; photon.col = photon.col*spec; temp.Reflect(hit); 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; temp.Reflect(hit); if(mirr.r == 0 && mirr.g == 0 && mirr.b == 0 && refract == 0) { GeneralPhotons.push_back(photon); photon.col = (photon.col * (diff/Pd)); photon.ray = temp; hit->mat->gloss = gloss; TracePhoton(photon, level); } } } } share quote
 12 December 2012 CGTalk Moderation Expert 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. share quote

 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 CGSociety Society of Digital Artists www.cgsociety.org Powered by vBulletinCopyright ©2000 - 2006, Jelsoft Enterprises Ltd.