Jump to content
  • Advertisement
Sign in to follow this  

Showing only part of a texture?

This topic is 3029 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


I am trying do something similar to do a lighting effect similar to this:


mostly where the screen is black on only shows the part of the calculated light area.

Unfortunately, that is in flash and I would like to do it using either SDL or openGL. I am running into a bit of a snag of how something like that would be accomplished.

I was thinking that I would have my bottom texture for the board, then a full black shape covering it, then put a polygon with an alpha on 0 on top of that for the 'lighting'. However, after searching for quite some time, I have come up with nothing.

Would anyone be able to help point me in the right direction?

Thank you in advance!

[Edited by - tont on August 29, 2010 2:03:56 PM]

Share this post

Link to post
Share on other sites
Couple of possibilities:

1) As soon as you have the shape figured out, create a texture large enough to cover the entire screen in system memory with rgb = 0, and alpha = 0 inside the shape, alpha = 1 outside the shape. Upload it to the graphics card. (this could also be done using render to texture). Either render it last, using either alpha blending or alpha testing, or use it in an additional texture stage when rendering objects, as an alpha mask.

2) Render a polygon representation of the shape into the stencil buffer and use that information in a shader to determine which pixels should/should not be rendered.

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!