Jump to content

  • Log In with Google      Sign In   
  • Create Account

Path tracing - Direct lighting


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 Arjan B   Members   -  Reputation: 656

Like
0Likes
Like

Posted 09 January 2014 - 03:51 PM

In many explanations of path tracers, such as http://www.thepolygoners.com/tutorials/GIIntro/GIIntro.htm, they apply direct lighting at each intersection point of the path. So at every intersection point, they trace a ray towards a light, and sample a different direction to continue the path.

 

Suppose I send out a ray that bounces three times and then hits the one light in the scene. Adding direct lighting at every bounce would be the same as not doing that, but having three paths, each leading to a light. Here the first path goes from the first intersection point to the light. The second path goes from the first to the second intersection point and then to the light. The third ray goes from the first to the second to the third intersection point and then to the light.

 

Is my understanding correct about this direct lighting approach? Does it sum up to the same end result?

 

If so, does this not lead to many more "samples" hitting a light than normally would, leading to incorrect lighting?



Sponsor:

#2 ApochPiQ   Moderators   -  Reputation: 15832

Like
1Likes
Like

Posted 09 January 2014 - 08:22 PM

There are two ways lighting can be contributed to a point: direct (i.e. a ray can traverse from a light source to the point) and indirect (i.e. reflected off of other surfaces before reaching the point). Path tracing is designed to take both into account; the direct lighting is sampled by casting a ray towards each light source, and the indirect light contribution is accumulated by sampling paths that orient towards the rest of the scene. The distribution of indirect light samples can be controlled to give different surface effects.

#3 Bacterius   Crossbones+   -  Reputation: 8945

Like
1Likes
Like

Posted 09 January 2014 - 11:27 PM

Yes, they are different paths, so even though you might hit a light source twice, they are counted as different light paths. Another way to think of it is that the probability of hitting a specific point in space (such as a point light source) is zero. So even though it might appear to result in the light appearing brighter because it can be potentially counted twice, the bias converges to zero as you add more samples.

 

The advantage of direct lighting, of course, is that it helps a lot with very small lights, as you can directly sample them instead of relying on random chance to eventually fire a ray towards it, while keeping the result physically correct. The variance reduction is rather stunning, but of course it is situational (if you have lights everywhere direct lighting might prevent you from sampling them all in a reasonable time, for instance, but if you combine both approaches you can get the best of both worlds).

 

Furthermore keep in mind that an area light source (like a bright sphere) can be mathematically treated as an infinite number of point light sources... and you can integrate over that distribution of point light sources in order to use direct lighting on them.


The slowsort algorithm is a perfect illustration of the multiply and surrender paradigm, which is perhaps the single most important paradigm in the development of reluctant algorithms. The basic multiply and surrender strategy consists in replacing the problem at hand by two or more subproblems, each slightly simpler than the original, and continue multiplying subproblems and subsubproblems recursively in this fashion as long as possible. At some point the subproblems will all become so simple that their solution can no longer be postponed, and we will have to surrender. Experience shows that, in most cases, by the time this point is reached the total work will be substantially higher than what could have been wasted by a more direct approach.

 

- Pessimal Algorithms and Simplexity Analysis


#4 powly k   Members   -  Reputation: 653

Like
1Likes
Like

Posted 10 January 2014 - 04:11 AM

This is all about the probability of each path. As with all monte carlo integration, you have to compensate the values of each sample with the probability of choosing that sample. The probability of hitting a point or directional light with a random chance is exactly 0; they're a single point on a continuous hemisphere. On the other hand, such lights act as dirac functionals; their contribution is only non-zero at a single point and infinitely large there. This, when integrating over the hemisphere, means that you can just pull them out of the integral and sum them with the approximation of the integral; the indirect lighting.

 

In a mathematic sense all surfaces and lights are equal (which makes sense, secondary or tertiary light sources are just as much light sources as primary ones) but when actually tracing the scene it makes sense to try to focus on the important stuff; this also leads to importance sampling of materials and multiple importance sampling of materials and lights together.

 

A lot of these approaches result in the exact same results - you can trace two bounces per incoming ray, for example, just keep track of your probabilities and you'll be fine as in the result will be unbiased. The vast majority of the ideas and research on the subject don't really focus on getting the result right, but reducing variance (which is visible as noise). With bidirectional path tracing using multiple importance sampling and materials that are importance sampled accurately, you can save a lot of rendering time (orders of magnitude) and get the same level of noise in your results.


Edited by powly k, 10 January 2014 - 04:12 AM.


#5 Arjan B   Members   -  Reputation: 656

Like
0Likes
Like

Posted 10 January 2014 - 11:26 AM

Thanks for the replies!

 

Up until now, I just picked a direction uniformly at random from a hemisphere, which may turn out to be either of indirect or direct lighting. So when I add an extra direction, which is sure to be direct lighting, and sum it up with the possibly indirect one the scene will not seem more bright? I'm not sure how that bias converges to zero as I add more samples, because at every sample I take, I also take an extra direct lighting sample?

 

Unless I add weights to the rays, corresponding to their probability, which would make the above seem to make some more sense to me. And I think that that is what powly k was trying to explain to me. But how do I calculate these probabilities? Projecting an area light onto the hemisphere would give me some area of the hemisphere to pick directions from, and the probability would be that area divided by the total area of the hemisphere, right? But what probability would the indirect light sample get, then? 1 - the other probability? And what when there are multiple lights, and their projected areas on the hemisphere overlap?

 

I'm going to try to implement it sometime this weekend, hopefully to gain some more understanding. But am I correct so far about the following?

Wherever I usually sample a direction uniformly at random, I also sample an extra ray for every light source. This sample can be directed at any point on the light source. All of the colors returned by these samples are multiplied by their weights, which correspond to the probability of taking that specific sample and therefore should sum up to 1.


Edited by Arjan B, 10 January 2014 - 11:28 AM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS