**2**

# Deferred Shading: point light and bounding volume

###
#22
Members - Reputation: **140**

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
Members - Reputation: **951**

Posted 09 May 2011 - 04:16 AM

sphereWorldMatrix=sphereScaleMatrix*sphereTranslationMatrix.

###
#25
Members - Reputation: **140**

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:

]

Big sphere radius:

###
#27
Members - Reputation: **140**

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
Moderators - Reputation: **49135**

Posted 10 May 2011 - 03:10 AM

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
Members - Reputation: **140**

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
Moderators - Reputation: **49135**

Posted 10 May 2011 - 04:44 AM

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).