Jump to content
  • Advertisement
Sign in to follow this  

Projective Texturing

This topic is 3213 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
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!