Jump to content
  • Advertisement
Sign in to follow this  
emuw

Photon Mapping - What is wrong with my pic?

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Sorry I am posting an ugly picture. Could you help me find out what is wrong with it. http://pg.photos.yahoo.com/ph/emuwemuw/detail?.dir=/4eb2&.dnm=abe7scd.jpg&.src=ph There is a block and glass ball in it. I can't figure out what cause those bright spots. Another problem is why the walls are not smooth? Is that because the estimate radius is too small, or the emitted photons are not enough? BTW, I stored the photons whenever they hit the diffuse surfaces. Should I separate them into 2 maps, one for those bounced only once, and the other bounced more than once. I guess if I store them in one global map, I should have all the information of direct and indirect illumination. Am I right? Thank you.

Share this post


Link to post
Share on other sites
Advertisement
I dont see the glass ball. but I see a caustic on the floor but I can't tell where it's coming from.

the bright spots are probably caused by tone mapping error. you probably got some values more then one and your not clipping them properly. that's my guess anyway.

the reason the walls dont' look smooth is probably because you used to few photons, or perhaps your radius is to small. you can compensate few photons with a large radius. you'll need several million photons to get any sort of convergence necessary for direct viewing(using a small radius and hence accurate). this is why the photon map is rarely visualized directly. you'll have to increase the radius for more smoother results.

you should only have one global photon map and it represents all typs of illumination. that is if you're following the jenson two pass technique, but it depends on what you're using it for. if you only want to use it to compute indirect illumination, then you'd just store photons that have bounced more then once. so it really matters what you're using it for. the two pass algorithm uses path tracing for direct illumination, and importance driven sampling using the photon map for indirect illumination, and also using the photon map directly after a few diffuse bounces. the only photon map that is directly visualized is the caustic map. but some use it to compute indirect illumination only, but it's rarely used for direct illumination, it would probably take several tens of millions to look reasonable for that.


Tim

Share this post


Link to post
Share on other sites
Thank you for your reply. That picture is just a global map rendering without ray tracing and caustic, so the ball is missing. I was trying to get the seperate pictures of four components as listed in Jensen's book.

I am still confused about using one global map for all illuminations. We only store the photons when they hit the diffuse surfaces, right? So how could we get the specular effect on a mirror ball if we use only one global map.
This is my understanding, please correct me if I am wrong.
1.For specular reflection, I should use classical ray tracing.
2.For caustic effect, use a caustic map.
3.For direct and indirect illumination,I could use a global map to approximate them if I don't want to use shadow photons or other extension of Photon Mapping(I haven't studied that yet). In this map, we store all photons if they hit the diffuse surfaces no matter how many time they are bounced.

I will look into the tone mapping error, but could you tell me a little bit more? What do you mean by "more than one" and how to clip it?

Thank you very much.

Share this post


Link to post
Share on other sites
Quote:

I will look into the tone mapping error, but could you tell me a little bit more? What do you mean by "more than one" and how to clip it?

I mean to say, you might have a rgb value that is greater then [1,1,1]. I don't know if you take that into account when you write the pixels to the screen. one way is to define an exponential mapping like this

red = 1 - e^(red*c)
green = 1 - e^(green*c)
blue = 1 - e^(blue*c)

where c is some constant defining your range. set it to something like 2 to test. I know 2 is reasonable.

Quote:

So how could we get the specular effect on a mirror ball if we use only one global map.

if you wanted a detailed specular effect, use the caustic photon map.

Quote:

1.For specular reflection, I should use classical ray tracing.

ya, specular effects are easy to sample because you only need to send rays in a small set of directions.

Quote:

2.For caustic effect, use a caustic map.

yes

Quote:

3.For direct and indirect illumination,I could use a global map to approximate them if I don't want to use shadow photons or other extension of Photon Mapping(I haven't studied that yet). In this map, we store all photons if they hit the diffuse surfaces no matter how many time they are bounced.

I think there is a little confusion here. you probably DONT want to use the global photon map to approximate direct lighting. what is usually done, is the direct lighting is computed via direct integration of the light(like in path tracing). You cant use the global photon map for direct lighting AND at the same time, use the caustic map, because caustic effects are stored on the global photon map too, so you'd be adding caustics twice and your caustic would be too bright. what is normally done is this.

compute indirect illumination via path tracing as usual BUT, when the rays hit another surface, return the estimate from the global photon map. in this way, we can simulate indirect diffuse illumination with only one ray. thus we don't need to recurse much. so the global photon map is usually used after one or more diffuse bounces as an estimate. in addition it can be used to importance sample this step, but I don't want to confuse so I'm gonna give you an example without importance sampling

here is a simple shader that only does diffuse and caustic stuff(no specular)

color = (0,0,0)
for all pixel (i,j) {
for all n samples {
ray = getprimaryray(i,j)
color += trace(ray, 0);
}

color /=n;
plotpixel(i,j, color);
color = (0,0,0);
}

trace(ray, depth) {
color = 0;
hit = nearestIntersection(ray);

if(depth == 0) {
color += BRDF*causticmap->irradianceEstimate(hit.position, hit.normal) //add in caustic illumination
for each light {
color += BRDF*DirectIllumination(hit); //add in direct illumination
}
}
else {
color = BRDF*globalphotonmap->irradianceEstimate(hit.position, hit.normal);
return color;
}


newray = getrandomdiffusedirection(hit.normal) //return a random direction weighed by cos

color += BRDF*trace(newray, depth + 1);
return color;
}





This is what I mean by only using the global map only after the first diffuse bounce. there are a lot of details missing, like how to properly integrate direct light, but obvious hacks can work for testing purpose. just a passing note, a proper diffuse BRDF = reflectance/PI and always <= 1/PI

Tim

Share this post


Link to post
Share on other sites
Thanks again, your explanation is really helpful.
Here is the picture I got for indirect illumination alone. It looks more reasonable.
http://pg.photos.yahoo.com/ph/emuwemuw/detail?.dir=/4eb2&.dnm=a005scd.jpg&.src=ph
Still I got one bright spot, although I have used a simple tone mapping Y/(Y+1). I just found out what caused it but I don't know why that happened. May be you can help again.

I hope I can express it clear. I am using the source code included in Jensen's book to build the photon maps. I found that some times it gave me a fatal "Access Voilation" error when the line 234 "dist1 = np->pos[p->plane] -p->pos[p->plane];" was executed(I said sometimes because it didn't happen every time). I traced into it and found out p->plane equaled some weird number like -12581 which meant it hasn't been changed during the balance process. The more weird thing was that only one photon(No.52171) in the array was not been changed. I just cannot understand why and I guess it may relate to some memory thing which I don't know much. So to make the program run, actually I just forced the function locate_photons return whenever p->plane met weird number.

Now the bright spot happened because some photon stored had weird power. These photons had resonalbe position values but had wrong plane number(-12581) and large auto-initiated power value. This is killing me.

One more weird thing is, after I got the picture with the bright spot, I ran the photon tracing and rendering again(not close the program) and I got a picture without spot. What could I do?
-sigh

[Edited by - emuw on November 22, 2005 5:06:01 AM]

Share this post


Link to post
Share on other sites
Sounds like some of your photons aren't getting initialized.

I haven't looked through jensen's source code in detail but I've heard from a couple of people that it's buggy.

I'd go through the code with a fine-tooth comb and check where the initialization might be failing.

Share this post


Link to post
Share on other sites
pm me your email I got an implimentation written by jensen that I know works. He gave it for a class of mine lol(but I had to fix a bug).

Tim

Share this post


Link to post
Share on other sites
I just fixed it. It makes me feel great!!!
The problem should be in the scale function.(I didn't test much but mine picture looks fine now.) In the for loop, "i<stored_photons" should be "i<=stored_photons". One photon was left unscaled, so after shuffled by the balance procedure, that photon had very large power. This caused the bright spot. But I am not sure it is the reason of "Access Violation" error(Since fortunately it is not happening now).
Again, thank you tim and others who replied my thread. I should asked earlier so I could understand better and save a lot of time.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!