# Photon Mapping problems

This topic is 3389 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm trying to add photon mapping to my ray tracer and got stuck with the calculation of the radiance estimate. The problem is that my estimation function always returns 0/0/0 and therefore all I see is a black image. Here is how I implemented my photon tracing/radiance estimate function: - First I calculate the photon power for a photon like this:
Color photonPower = curLight->GetColor() / numPhotons;

Where Color is a type containing 3 floats for RGB values, numPhotons is the number of photons emitted from the current light source and GetColor returns the light color/intensity. - When the photon hits an object I determine what to do next using Russian Roulette. Let's assume we are doing a diffuse reflection - then this is what I currently do in my code:
Ray reflRay = GetDiffuseReflection();
Color newPower = p_Power * DiffuseBRDF(hitPoint, hitNormal, p_Ray.m_Direction, reflRay.m_Direction, curMat);
PhotonTrace(p_Scene, p_Light, reflRay, newPower, p_TraceDepth + 1, p_RefrIndex);

First I calculate the diffuse reflection ray. Then I multiply the current photon power by the BRDF of the surface where the photon hit was detected (in the case of the diffuse BRDF all I do is (Normal * -reflRay.dir) * curMat->GetColor()) and store the photon (because we hit a diffuse surface). Then I recursively continue photon tracing with the new calculated photon power. - Finally my radiance estimate locates the n closest photons and performs the following calculation.
Color output(0,0,0);
for(int i = 0; i < PhotonsFound; ++i)
{
const Photon* p = m_Photons;
Vector3 dir = GetPhotonDir(p->m_Theta, p->m_Phi);
output += (hitNormal * -dir) * p->m_Power;
}

const float tmp = (1.0f / PI) / (MaxSqDistance);
output = output * tmp;

The problem that I have with my photon mapping implementation is that output is always very small (0.000xxxx values) and therefore my scene is just black. I'm not sure what parts of Photon Mapping I've misunderstood that my implementation is not working correctly. I hope someone can help and enlighten me!

1. 1
2. 2
frob
20
3. 3
Rutin
17
4. 4
5. 5

• 9
• 13
• 10
• 9
• 18
• ### Forum Statistics

• Total Topics
632555
• Total Posts
3007036

×