• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Arjan B

Path tracing - Direct lighting

4 posts in this topic

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?

0

Share this post


Link to post
Share on other sites
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.
1

Share this post


Link to post
Share on other sites

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.

1

Share this post


Link to post
Share on other sites

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
1

Share this post


Link to post
Share on other sites

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
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0