Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Deferred Shading: point light and bounding volume


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
31 replies to this topic

#21 froop   Members   -  Reputation: 636

Like
0Likes
Like

Posted 08 May 2011 - 08:15 AM

In that tutorial they reconstruct position from depth which is fine.

Are you sure that the sphere has the correct radius? I had this once when I used a sphere that was too small.

Sponsor:

#22 enigmagame   Members   -  Reputation: 138

Like
0Likes
Like

Posted 08 May 2011 - 10:40 AM

In that tutorial they reconstruct position from depth which is fine.


It's right, in fact storing also x and y positions don't change the results.

Are you sure that the sphere has the correct radius? I had this once when I used a sphere that was too small.


I don't understand very well. What you intend?

#23 n3Xus   Members   -  Reputation: 709

Like
0Likes
Like

Posted 09 May 2011 - 04:16 AM

You must make you sphere smaller or bigger depending on the maximum light range. You should have a unit sphere (a sphere with radius 1) and then scale this sphere by the maximum light range using a scale matrix, so you end up with a matrix for a sphere which is like this:


sphereWorldMatrix=sphereScaleMatrix*sphereTranslationMatrix.

#24 froop   Members   -  Reputation: 636

Like
0Likes
Like

Posted 09 May 2011 - 01:35 PM

Yeah, or instead of using a matrix, in the vertex shader multiply the sphere vertices by your lightrange and add the translation offset.

#25 enigmagame   Members   -  Reputation: 138

Like
0Likes
Like

Posted 10 May 2011 - 01:58 AM

You must make you sphere smaller or bigger depending on the maximum light range. You should have a unit sphere (a sphere with radius 1) and then scale this sphere by the maximum light range using a scale matrix, so you end up with a matrix for a sphere which is like this:


sphereWorldMatrix=sphereScaleMatrix*sphereTranslationMatrix.


Yes, but I already do that, the vertex shader receive the world matrix (for the sphere) that you've wrote above. I think that the problem isn't here.
The problem is the clear cut, that you can see in all the screenshot that I've linked in the precedents post.
Small sphere radius:
Posted Image]
Big sphere radius:
Posted Image

#26 Hodgman   Moderators   -  Reputation: 31122

Like
0Likes
Like

Posted 10 May 2011 - 02:53 AM

That's because there's no connection between the range of your light and the size of your sphere.....

#27 enigmagame   Members   -  Reputation: 138

Like
0Likes
Like

Posted 10 May 2011 - 02:58 AM

That's because there's no connection between the range of your light and the size of your sphere.....


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

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

I obtain the same, wrong, result.

#28 Hodgman   Moderators   -  Reputation: 31122

Like
0Likes
Like

Posted 10 May 2011 - 03:10 AM

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.

#29 enigmagame   Members   -  Reputation: 138

Like
0Likes
Like

Posted 10 May 2011 - 03:59 AM

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


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.

#30 Hodgman   Moderators   -  Reputation: 31122

Like
1Likes
Like

Posted 10 May 2011 - 04:44 AM

In the attenuation function you posted, the attenuation becomes zero at a distance of 'lightRadius' 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 radius of your sphere should be at least 'lightRadius' 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).

#31 enigmagame   Members   -  Reputation: 138

Like
1Likes
Like

Posted 10 May 2011 - 12:13 PM

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. Posted ImagePosted ImagePosted Image
I've created a new mesh, and this is the results:

Posted Image

It seems correct. You confirm?
Thanks.

#32 MajorTom   Members   -  Reputation: 715

Like
0Likes
Like

Posted 10 May 2011 - 12:42 PM

I've created a new mesh, and this is the results:

Posted Image


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.

Saving the world, one semi-colon at a time.





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