Sign in to follow this  
enigmagame

Deferred Shading: point light and bounding volume

Recommended Posts

enigmagame    140
[quote name='Hodgman' timestamp='1305017631' post='4808882']
That's because there's no connection between the range of your light and the size of your sphere.....
[/quote]

Do you mean the attenuation? Because if I use the original attenuation formula described on the tutorial:
[code]

//surface-to-light vector
float3 lightVector = lightPosition - position;
//compute attenuation based on distance - linear attenuation
float attenuation = saturate(1.0f - length(lightVector)/lightRadius);
[/code]

I obtain the same, wrong, result.

Share this post


Link to post
Share on other sites
Hodgman    51234
The range of your light is determined by your attenuation function, yes.

This is pretty straight-forward. Any pixel that has a greater-than-zero attenuation result MUST be covered by your sphere mesh. If you sphere mesh doesn't cover pixels with >0 attenuation, you're going to get a hard edge where pixels stop being lit.

Solve your attenuation function to find out what the maximum range of lit pixels is, and then make your sphere that big.

Share this post


Link to post
Share on other sites
enigmagame    140
[quote name='Hodgman' timestamp='1305018618' post='4808888']
Solve your attenuation function to find out what the maximum range of lit pixels is, and then make your sphere that big.
[/quote]

Sorry, but I don't understand very well. I'm a bit confused.
I've correctly understood the problem that you've explained, but not the solution.

Share this post


Link to post
Share on other sites
Hodgman    51234
In the attenuation function you posted, the attenuation becomes zero at a distance of '[font="Courier New"]lightRadius[/font]' units from the centre of the light. Any pixels further than this distance away will not be lit.

Also, any pixels outside of your sphere will not be lit.

Therefore the [i]radius [/i]of your sphere should be at least '[font="Courier New"]lightRadius[/font]' units to avoid getting the hard-line where a pixel that should've been lit, isn't (due to it not being covered by the sphere).

Share this post


Link to post
Share on other sites
enigmagame    140
Ok guys, I've found the problem, and it was a very, very, very stupid problem: the size of the sphere mesh.
I was convinced, very convinced, that the size was 1, but I was wrong. [img]http://public.gamedev.net/public/style_emoticons/default/sad.gif[/img][img]http://public.gamedev.net/public/style_emoticons/default/sad.gif[/img][img]http://public.gamedev.net/public/style_emoticons/default/sad.gif[/img]
I've created a new mesh, and this is the results:

[url="http://imageshack.us/photo/my-images/90/deferredshadingd2011051.png/"][img]http://img90.imageshack.us/img90/992/deferredshadingd2011051.th.png[/img][/url]

It seems correct. You confirm?
Thanks.

Share this post


Link to post
Share on other sites
Pthalicus    738
[quote name='enigmagame' timestamp='1305051190' post='4809061']
I've created a new mesh, and this is the results:

[url="http://imageshack.us/photo/my-images/90/deferredshadingd2011051.png/"][img]http://img90.imageshack.us/img90/992/deferredshadingd2011051.th.png[/img][/url]
[/quote]

Yeah, looks fine.
It's easy to over look things, it's always best to narrow down where the problem could be, in this case the size of the sphere.
Nice work.

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