Sign in to follow this  

Projective Texturing

This topic is 2848 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, I am currently re-evaluating how efficient my spotlight technique is and I have come to the conclusion it would be probably be faster to use a projected texture (and look more appealing). I just wanted to confirm I have the right end of the stick - in that I would have to do something like this: Vertex Shader:
// Generate projected Coordinates and pass them to the pixel shader
wOut.projTexCoords = mul(gCameraPos, gWorldViewProj);
Pixel Shader:
pIn.projTexCoords.xyz /= projTexCoords.w;

//X & Y just saves writing it twice
if (abs(projTexCoords.xy) <= 1.0f && projTexCoords.z >= 0.0f)
{ 
   // The light shines in the visible frustum so sample the texture
   projTexCoords.x = 0.5f * projTexCoords.x + 0.5f;
   projTexCoords.y = -0.5f * projTexCoords.y + 0.5f;

   // Then sample valid spotlight texture with the above coordinates 
   // and increment the litcolor
}
I have already created myself a texture which will represent the spotlight all i would need to do is used alpha blending to blend the the geometry already in the scene. This will be in its own pass (2nd pass of the shader) which comes after all the standard world geometry has been drawn, if I enable blending for this pass I think I should be okay. Do that sound about right to you guys? Am I missing anything? Thanks.

Share this post


Link to post
Share on other sites

This topic is 2848 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this