Jump to content
  • Advertisement
Sign in to follow this  
anonentity

Per-tile lighting, is there a DESTALPHA?

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

Hello there, I hope this is not a redundant post, can't seem to find what I need on google... I am making a nice little 2d isometric game and everything is working great. Now as I make my per-tile lighting system, I am wondering more and more about SDL's bizzare alpha blitting. Basically I do the following: tempsurf = IMG_load(); SDL_SetColorKey(tempsurf, SDL_SRCCOLORKEY, alphaPixel); surf = SDL_DisplayFormatAlpha(tempsurf); SDL_FreeSurface(tempsurf); // My own utility function that sets the alpha value for pixels which // match the given color parameter. This works fine... SetAlphaForColor(surf, BLACK_COLOR, someAlphaValue); In the end I get isometric diamond tiles that are totally transparent where they are supposed to be, and partially transparent in the tiles bounds. I use these tiles for my super sophisticated "shading" algorithm (tee-hee!). Basically I pregenerate 10 of these from black diamonds, so I get 10 levels of black shading. Then in my lighting algorithm I set one of these tiles for each tile of the currently drawn screen. I first draw the screen, then do another pass to draw the shading overtop. PROBLEMS: My FPS dropped in half, even though all the alpha stuff is pre-generated and I keep my surfaces in main memory. Not a big deal because half of 200 is still acceptible. The top of tall sprites get clipped by the shadows in a way that looks unnatural. QUESTIONS: 1 - is there a way that I can specify that I want something blitted to a surface only where the destination surface is not totally transparent (alpha > 0), something like SDL_DESTALPHA? This would allow me to use black rectangles and then dest blit them over sprites so that the shading is consistent. If I write my own, how do I make it fast? 2 - is there a better way to handle the algorithm in general? A more efficient way? Well, that's my fishing expidition. Thanks in advance for any tips!

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!