Need assistance with projecting a TextureCubeMap based on a position (not the camera)

Soooo… I’m working on an point light shadow renderer.



I’ve gotten to the point where I am generating the correct cube shadow map, however… I need to be able to project this from the position of the light… and I am stumped.



Maybe I should first ask… how is inPosition calculated? I’ve tried multiple methods of using the light position… but I end up with weird results. I’m really close to having something usable… if I could just get this one piece solved.

I got to the same point as you and stopped because i didn’t have time to look into the math involved.

There must be something to do close to how the sky cube map is looked up.



However @zarch suggested in the deferred rendering thread to just use 6 standard texture and just pass along the lightviewprojection matrice and just do the same as pssm or bsr. I think it’s a valid way to go, if youc an’t get the math done.



InPosition is the position of the vertex in model space, which means the position of the vertex relative to the center of the model.

Your trouble might be because you don’t compare things in the same space.

Light positions are in world space, so basically you have to use the worldMatrix to transform the inPosition in world space.

@nehon said:
I got to the same point as you and stopped because i didn't have time to look into the math involved.
There must be something to do close to how the sky cube map is looked up.

However @zarch suggested in the deferred rendering thread to just use 6 standard texture and just pass along the lightviewprojection matrice and just do the same as pssm or bsr. I think it's a valid way to go, if youc an't get the math done.

InPosition is the position of the vertex in model space, which means the position of the vertex relative to the center of the model.
Your trouble might be because you don't compare things in the same space.
Light positions are in world space, so basically you have to use the worldMatrix to transform the inPosition in world space.


I tried that to begin with because I was having issues with format of the TextureCubeMap (which I resolved in a very cheesy way... but that's for someone smarter than me to fix properly. My temp solution worked for the hardware related issues I was having).

The problem I hit there was knowing which map to use where.... which led me to the realization no matter which method you use, you still have the same issue :(

Oh… and thank you for the info about inPosition… that sounds like it will solve the problem.