Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualsobeit

Posted 22 April 2013 - 12:56 AM

Yeah, the most straightforward way to do this is to pass your world position (which of course you have access to in the vertex shader) to the pixel shader via a TEXCOORD semantic.

 

Then in your pixel shader, you can multiply that by the View * Projection matrix of your light (so your camera's V and P matrices are shader parameters used by your vertex shader as usual, and your light's V and P matrices are shader parameters used by your pixel shader). This should get you in the same space as what you used to generate your shadow map.

but the world position in vertex shader is vertex-based, how do I know what's the world position for every fragment(or pixel)?

and what space is the xy axes of shadow map in? I think it's in window space which are all integers. but view * Projection matrix only take us to clip space right?

Thanks.


#1sobeit

Posted 22 April 2013 - 12:50 AM

Yeah, the most straightforward way to do this is to pass your world position (which of course you have access to in the vertex shader) to the pixel shader via a TEXCOORD semantic.

 

Then in your pixel shader, you can multiply that by the View * Projection matrix of your light (so your camera's V and P matrices are shader parameters used by your vertex shader as usual, and your light's V and P matrices are shader parameters used by your pixel shader). This should get you in the same space as what you used to generate your shadow map.

but the world position is vertex shader is vertex-based, how do I know what's the world position for every fragment(or pixel)? Thanks.


PARTNERS