• Create Account

### #ActualDrColossus

Posted 08 June 2012 - 02:33 PM

You have to manually divide the lightspace position by it's w-value unless you're using a texture function that does that for you, like textureProj (assuming that you don't account for that already within your scaling somewhere).

So without any scaling, your sampling coordinate would be

vec4 lightSpacePos = lightMatrix * invView * fragmentPos;
vec2 projCoords = 0.5 + 0.5 * lightSpacePos.xy / lightSpacePos.w;


The 0.5 + 0.5 * brings the coordinates from [-1, 1] in the [0, 1] range.

I hope that fixes it

### #2DrColossus

Posted 08 June 2012 - 02:32 PM

You have to manually divide the lightspace position by it's w-value unless you're using a texture function that does that for you, like textureProj (assuming that you don't account for that already within your scaling somewhere).

So without any scaling, your sampling coordinate would be

vec4 lightSpacePos = lightMatrix * invView * fragmentPos;
vec2 projCoords = 0.5 + 0.5 * lightSpacePos.xy / lightSpacePos.w; //the 0.5 + 0.5 * brings the coordinates from [-1, 1] in the [0, 1] range


I hope that fixes it

### #1DrColossus

Posted 08 June 2012 - 02:32 PM

You have to manually divide the lightspace position by it's w-value unless you're using a texture function that does that for you, like textureProj (assuming that you don't account for that already withing your scaling).

So without any scaling, your sampling coordinate would be

vec4 lightSpacePos = lightMatrix * invView * fragmentPos;
vec2 projCoords = 0.5 + 0.5 * lightSpacePos.xy / lightSpacePos.w; //the 0.5 + 0.5 * brings the coordinates from [-1, 1] in the [0, 1] range


I hope that fixes it

PARTNERS