Jump to content


Materials and light transport


61 replies to this topic

#21 Alienizer

    Member

  • Members
  • PipPipPipPip
  • 435 posts

Posted 07 April 2012 - 02:17 PM

Well, that's the part I'm not sure about. What I do is loop 100 times, and for each loop, I loop through all the lights and shoot a photon = lightColor * lightPower, that's all. So I obviouslt do this all wrong?

I appreciate your help Reedbeta.

#22 Reedbeta

    DevMaster Staff

  • Administrators
  • 5308 posts
  • LocationSanta Clara, CA

Posted 07 April 2012 - 11:32 PM

Try this: for each light, calculate lightPower = lightColor * pi * area. (lightPower is an RGB color, in case it wasn't clear.) Then for each light, calculate photonPower = lightPower / numPhotonsPerLight, then shoot numPhotonsPerLight photons with that power. You can decide what numPhotonsPerLight should be.

This should work correctly, but if you have a variety of lights of different powers in your scene, it will produce photons with a variety of different powers. As mentioned earlier in the discussion about reflection, having photons with a variety of different powers increases the noise in the rendered result and requires you to shoot more photons or render for longer to get a smooth result. So, it's better to distribute photons proportional to the power of the lights, so that high-power lights shoot more photons than low-power ones; then the photons can all be the (roughly) the same power. This is very similar to the reflection probability method we just discussed in this thread, as well as the triangle area probability we talked about in another thread, so you should be able to figure it out if you feel like taking this on... :)
reedbeta.com - developer blog, OpenGL demos, and other projects

#23 Alienizer

    Member

  • Members
  • PipPipPipPip
  • 435 posts

Posted 08 April 2012 - 12:13 AM

I see what you mean! But what I'm doing is shooting photons until I fill up the memory storing them, so I never know how many photons will be shot by a light, until it's all done! So that's also the wrong way to go about it? or can I still do it that way using your second suggestion?

So if I have 3 lights of diffrent powers, say, 10, 35 and 60, the idea is to shoot 10 photons for the first light, 35 for the next and 60 for the last, each with identical 'power'? as oppose to shoot the same number of photons for all lights and adjust the photon power for each light?

#24 Reedbeta

    DevMaster Staff

  • Administrators
  • 5308 posts
  • LocationSanta Clara, CA

Posted 08 April 2012 - 02:19 AM

Yeah, that's the idea. You can still shoot an unknown number of photons, if for each photon you randomly pick a light to emit it from, with probability proportional to power.
reedbeta.com - developer blog, OpenGL demos, and other projects

#25 Alienizer

    Member

  • Members
  • PipPipPipPip
  • 435 posts

Posted 08 April 2012 - 02:44 AM

You're a genius, works perfect thank you :D

When I trace after shooting all the photons, if I hit a light, how would this work now with lights of diffrent power and area?? Do I simply return lightColor * PI * lightArea?

#26 Reedbeta

    DevMaster Staff

  • Administrators
  • 5308 posts
  • LocationSanta Clara, CA

Posted 08 April 2012 - 04:46 AM

No, lightColor is the color to return from a ray that hits the light. That's why we calculated lightColor * pi * area, because that's the formula to transform between radiance (what a ray carries) and power (what photons carry).
reedbeta.com - developer blog, OpenGL demos, and other projects

#27 Alienizer

    Member

  • Members
  • PipPipPipPip
  • 435 posts

Posted 08 April 2012 - 04:34 PM

ok, is 'area' the light area or the search radius?

#28 Reedbeta

    DevMaster Staff

  • Administrators
  • 5308 posts
  • LocationSanta Clara, CA

Posted 08 April 2012 - 09:42 PM

The surface area of the light's geometry.
reedbeta.com - developer blog, OpenGL demos, and other projects

#29 Alienizer

    Member

  • Members
  • PipPipPipPip
  • 435 posts

Posted 09 April 2012 - 03:44 AM

You said no when I asked you "Do I simply return lightColor * PI * lightArea?" :blink: and you said to use "lightColor * pi * area" :wacko: where area is the area of the light geomety.

I'm all confused now Reedbeta :D :D :D

Hope you have a great Easter, and thanks for your patience with me!

#30 Reedbeta

    DevMaster Staff

  • Administrators
  • 5308 posts
  • LocationSanta Clara, CA

Posted 09 April 2012 - 05:59 AM

Rays that hit a light return lightColor.

The photons from the light must add up to lightColor * pi * the surface area of the light's geometry.
reedbeta.com - developer blog, OpenGL demos, and other projects

#31 Alienizer

    Member

  • Members
  • PipPipPipPip
  • 435 posts

Posted 09 April 2012 - 01:52 PM

But this would only apply is I know how many photons per lights I shoot as you described in #22?

In your reply #24, that's how I do it. But at trace time, if I hit a light, do I also return the light color?

#32 Reedbeta

    DevMaster Staff

  • Administrators
  • 5308 posts
  • LocationSanta Clara, CA

Posted 09 April 2012 - 04:42 PM

I'm not sure where the confusion is. It's really simple: when raytracing, and the ray hits a light source, you just return the light color. When emitting photons, you must ensure that the total of all photons emitted from a light equals (at least approximately) the light's total power, which as mentioned is lightColor * pi * lightArea. It doesn't matter how you shoot your photons as long as you do something to ensure this is true. If you don't know ahead of time how many photons you will shoot, then you must incorporate the number of photons in some other way, or the photon map won't match the direct lighting.
reedbeta.com - developer blog, OpenGL demos, and other projects

#33 Alienizer

    Member

  • Members
  • PipPipPipPip
  • 435 posts

Posted 09 April 2012 - 05:40 PM

oh I see! so lightColor * pi * lightArea is not for each photons, but for all of them (for that one light source), so each photons shot out are (lightColor * pi * lightArea) / numPhotons which is what you already said in #30

When you trace back, rays that hit a light return lightColor, but aren't they going to look all at the same intensity? Say, if one light source shoot 50 photons, and they other one shoot 100 photons, it's like a 50w and 100w, so ins't the 50w be reduced so that it looks not as bright as the 100w?

#34 Reedbeta

    DevMaster Staff

  • Administrators
  • 5308 posts
  • LocationSanta Clara, CA

Posted 09 April 2012 - 05:51 PM

If one light source is 50 watts and another is 100 watts, then

a. They might be the same color (equal intensity) but the first one has 1/2 the surface area of the other
b. They might be the same area but the first one has 1/2 the intensity of the other
c. Some other possibility (e.g. the first one is 2x the area and 1/4 the intensity, or whatever).

Power is a combination of intensity and area, but when you hit a light source with a ray, it cares only about intensity, not about area. Photons care about power, so they care about both intensity and area.
reedbeta.com - developer blog, OpenGL demos, and other projects

#35 Alienizer

    Member

  • Members
  • PipPipPipPip
  • 435 posts

Posted 09 April 2012 - 06:06 PM

Make sense, I understand that. So if the brightest light in my scene is 300w, then the 100w light when a ray hits it is lightColor*100/300 ?

#36 Reedbeta

    DevMaster Staff

  • Administrators
  • 5308 posts
  • LocationSanta Clara, CA

Posted 09 April 2012 - 06:12 PM

No...like I've been saying all along, the color when a ray hits it is JUST lightColor. NOTHING ELSE.
reedbeta.com - developer blog, OpenGL demos, and other projects

#37 Alienizer

    Member

  • Members
  • PipPipPipPip
  • 435 posts

Posted 09 April 2012 - 07:38 PM

ok, so then how can one light bulb show not as bright as another if they all return lightColor???

#38 roel

    Senior Member

  • Members
  • PipPipPipPip
  • 698 posts

Posted 09 April 2012 - 07:45 PM

Because each light has a lightColor...?

#39 Alienizer

    Member

  • Members
  • PipPipPipPip
  • 435 posts

Posted 10 April 2012 - 01:55 AM

yes, they all have the same color vec3(1,1,1) so at trace time if we return that for each lights, they will look all the same intensity right?

So if you're saying that a 100w should be vec3(1,1,1) and the 50w should be vec3(0.5,0.5,0.5) then it's not going to work because we will be shooting 100 photons at vec3(1,1,1) and 50 photons at vec3(0.5,0.5,0.5) when we should shoot photons all at vec3(1,1,1).

#40 roel

    Senior Member

  • Members
  • PipPipPipPip
  • 698 posts

Posted 10 April 2012 - 07:38 AM

Just some examples. If a light has an "intensity" lightColor of vec3(1,1,1), another light with the same area but a lightColor of vec3(.5,.5,.5) should emit half the number of photons. Yet another light, with a lightColor of vec3(.2,.2,.2) and half the area should emit a tenth of the number of photons the first light does.. And a last light, with a lightColor of vec3(.25,.25,.25) with four times the area of the first light, should emit the same number of photons of the first light. (select the hidden part of the answer if my tricks works for you, but think first). (and excuse me for any miscalculations)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users