Thank you for examples, txesmi! I have a question.
float3 clipSpaceCoordinates = mul(float4(vecLightPos[i].xyz, 1.0f), matViewProj).xy;
float2 normalizedProjectionCoordinatesXY = clipSpaceCoordinates.xy / clipSpaceCoordinates.w;
clipSpaceCoordinates is a float3, but you use it's clipSpaceCoordinates .w in normalizedProjectionCoordinatesXY calculation.
Also, in clipSpaceCoordinates itself you only set .xy while calculating it.
So in order to compile, I've changed float3 clipSpaceCoordinates to float4, but it doesn't work.
Also, I've set CHILD flag for the pp view.
EDIT:
Also in
normalizedScreenCoordinates.y = (1.0f - normalizedProjectionCoordinatesXY.y) / 4.0f;
You used
normalizedProjectionCoordinatesXY.x
Instead of Y is that intentional?
EDIT2: ok, I see that you fixed the previous post, but it still doesn't work for some reason...
This is the code I tried out (tried both vecLightViewPos and vecLightPos).
float4 clipSpaceCoordinates = mul(float4(vecLightViewPos[i].xyz, 1.0f), matViewProj);
float2 normalizedProjectionCoordinatesXY = clipSpaceCoordinates.xy / clipSpaceCoordinates.w;
float2 normalizedScreenCoordinates;
normalizedScreenCoordinates.x = (1.0f + normalizedProjectionCoordinatesXY.x) / 4.0f;
normalizedScreenCoordinates.y = (1.0f - normalizedProjectionCoordinatesXY.y) / 4.0f;
float2 screenCoordinates = normalizedScreenCoordinates * vecViewPort.xy;
float normalizedProjectionCoordinatesOfOuterPointOfLightSphereX = mul(float4(vecLightViewPos[i].xy, vecLightViewPos[i].z - vecLightViewPos[i].w, 1.0f), matProj).x;
float projectedLightRadiusInScreenPixels = vecViewPort.x * (normalizedProjectionCoordinatesOfOuterPointOfLightSphereX - normalizedProjectionCoordinatesXY.x) / 2.0f;