• 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
Hodgman

Distance squared light falloff

9 posts in this topic

For the solar panel one, i guess at distance 0, the area of the solar panel there would be very close to 0 too, canceling it out.

0

Share this post


Link to post
Share on other sites

Here you are mixing up relative and absolute measurements. You quoted "doubling the distance cuts the intensity by four"... now how do you go from doubling the distance to "2 feet"? Or more specifically, which distance did you double?

Doubling the distance would mean to go from 1 foot to 2 or from 0.3m to 0.6m in both cases you doubled the distance and quartered the intensity...

 

Yes, this.  Your falloff factors are relative to a distance of 1 in each of your respective units, so relative to 1 meter, a factor of 2.69 is correct - because the light at 0.6096 meters will be that much brighter than the light at 1 meter.  Important to keep your units consistent.

 

In this case, to do an equal comparison you need to use the falloff at 0.3048 meters (1 foot) and compare to the light at 0.6096 meters (2 feet) - that gives us 10.7639 and 2.6909, and what do we get if we divide the former by the latter - 4.

1

Share this post


Link to post
Share on other sites

Point emitters are just a theoretical non physical thing. It's just used because hey, it looks good and close enough to physical that who cares right? There is no real world analogue to an infinitely small point light of course, quantization as photons blah blah blah. It's a useful hack and that's that. And importantly its the fastest useful hack you can do, at least for getting close. And it should still be energy preserving, after all the closer you are the the infinitely small point source the smaller the area being affected. At zero, the point source, you've infinite energy and zero area to fall on so congratulations!

 

I guess if you really wanted to, and why wouldn't you? You'd use the blogs thing and estimate the actual area of the light source for everything. The area being the coil inside the lightbulb, or maybe the area of the reflector on a flashlight if you want to get all that light in there. I.E. choose your convenient light diffuser/reflector. More accurate light falloff for real cheap, sounds good to me; even if most light sources we actually have are extremely small (which is why point light sources work so well as an analogue) there's still other things that will reflect them in a static fashion/diffuse the light to the point that an area light source such as the blog's would be more correct.

Edited by Frenetic Pony
0

Share this post


Link to post
Share on other sites
Even if it's not right I use 1 / (1 + d^2) it's cheaper than 1 / (1+d)^2 and nicely avoid infinite problem. For pc game I would use area lights for everything but it's just not feasible on mobiles yet. Edited by kalle_h
0

Share this post


Link to post
Share on other sites

Ad infinite problem, maybe this is absolutely obvious and I'm just spamming, but from what I remember, the number of photons is, by all means, finite (and can be computed). Therefore you can't recieve infinite energy near the light.

 

F.e. for 40W cool white fluorescent bulb it should be around 2.55 X 10^19 photons radiated per second (counting effectivity in - it can be derived from energy of single photon E=hf=h * c / lambda, average wavelength for light = 600 nm, energy = 40W ~ 40J (assuming we radiate the light for 1 s), with this value divide the actual energy radiated by the bulb (of course after application of efficiency which should be just several percent)).

0

Share this post


Link to post
Share on other sites

It's just used because hey, it looks good and close enough to physical that who cares right?

 

It's used because it's trivial to analytically integrate a punctual light source with any BRDF, which isn't true of area lights.

0

Share this post


Link to post
Share on other sites

One measures the distance as being 2 feet, and calculates a falloff factor of 1/4.
The other measures the distance as being 0.6096m, and calculates a falloff factor of 2.69.

Here you are mixing up relative and absolute measurements. You quoted "doubling the distance cuts the intensity by four"... now how do you go from doubling the distance to "2 feet"? Or more specifically, which distance did you double?
Doubling the distance would mean to go from 1 foot to 2 or from 0.3m to 0.6m in both cases you doubled the distance and quartered the intensity...

That example only contains absolute measurements. The "doubling the distance" bit was mentioned earlier, the way I've heard photographers explain 1/d2. This example only contains absolute d values being plugged into 1/d2.

Your falloff factors are relative to a distance of 1 in each of your respective units

Ah that makes sense! So when games use code like:

output = dot(n,l) * 1/(d*d) * intensity

then intensity is the value that you want the light to have at one unit from the centre... pretty obvious once I say it, since that's what happens.

And with the blog's formula, you're not setting intensity at 1 unit, you're setting intensity at the surface of the emitter. So the two formulas are give multipliers that should be used against different initial intensity values.
 
I guess seeing that the above code doesn't take steradians or areas into account anywhere, we're using some kind of assumption that all of our calculations are being done for some small-steradian-subtending small-area, which is the same for every one of our pixels? So if our game uses metres for everything, our light intensity value is in "light-units per small-area-at-1m-distance"?
 
 
If you bring the light 2x closer, it will get 4 times brighter, and with it being a point there's no limit to the number of times you can do this... so:

Also notice that while moving arbitrarily close to a theoretical point light source the energy doesn't go to infinity, the energy density does..

Thanks! So even if the light emits a quantifiable pulse of 100 photons, then at the moment of emission, there's always only 100 of them... but if your receiver was at the same point, with zero area, then we'd say there was 100 photons being received in zero area, which gives us a reading of infinity photons per m2!
 
In games, using the above code snippet as an example, we pretty much never take the receivers area into account (except for the N.L term). If we accounted for the actual world-size of the pixels that we're shading, and the solid angles that they subtend, would this cancel out the wackyness caused by the fact that the energy density approaches infinity? i.e. in order to measure that infinite energy density, our receiver have to have zero area, so you'd end up with something that's wacky in a different way, like x0Pwhwk.gif? Or we'd have a rectangular receiver area with most of it having zero energy and a single point on it's surface having infinite?
 

this formula doesn't work when the radius of the emitter is zero, so I'm still left puzzled about how to reconcile point emitters with spherical emitters. These two variants (1/d2 and 1/(d/r+1)2) give different answers

I figured this one out myself - it is possible to reconcile the two formulas:
In the formula from the linked blog, d is the distance from the outside of the emitting sphere to the receiver, and r is the sphere's radius. We can rearrange the blog's formula like so:
zQMzcUD.gif
Importantly, d+r is the distance from the centre to the receiver, which is what the typical 1/d2 formula uses. So if we let D=d+r, and try and find an equivalnce with the typical formula, we get:
EZhingb.gif
4gAaYuZ.gif
So, our typical 1/d2 formula is actually true for a sphere with radius of 1 unit (so again, your 'light intensity' game values are relative to 1 of your distance units). I guess this also implies you shouldn't trust it's answers for values of D that are smaller than 1, because such a situation should be unpossible, although the math does hold up until D hits zero smile.png

 

 

I'm still confused about the differences that occur depending on whether we treat our receiver as a spherical cap vs a rectangle though (with the 1/d^2 law being right for the spherical cap). Is this always the most appropriate geometrical approximation to be using?

Edited by Hodgman
2

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