Jump to content
  • Advertisement
Sign in to follow this  
Dreq

OpenGL 2D Real-Time Shading

This topic is 5403 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 finally have a very nicely done lib I've written to do 2D games in 3D-accelerated OpenGL. It uses alpha-layered PNGs to texture quads. Here's screenshot of a test (uses about 7 images total): clicky Anywho, Now that I've got a pretty good understanding of that aspect, my next (slightly odd) challenge is to have real-time shadows for 2D textures. I figured there must be ~some~ way to achive this.. perhaps with pixel shaders, but does anyone have a clue of where I should look to learn about this kind of thing? I guess the best way to describe it is, it uses the opacity of each pixel in the surrounding objects of that same 'layer' to generate shading to be applied to the lower 'layer', and no -- not doing self-shadow as that would require some sort of reference to the 3D shape of the 2D object O_O

Share this post


Link to post
Share on other sites
Advertisement
You might be able to do it with shadow maps. Keep in mind though that without depth information the shadows won't be correct when they cross would-be 3D objects (eg, the computer table). The only other option would really be the usual grey blob on the floor.

Share this post


Link to post
Share on other sites
Well honsetly that was a test, the actuial engine will be SNES style 2D RPG view. Each shadow would be calculated individually per object and would be drawn on the ground, disregarding anything not on the 'floor' layer.

Share this post


Link to post
Share on other sites
Quote:
Original post by Dreq
I guess the best way to describe it is, it uses the opacity of each pixel in the surrounding objects of that same 'layer' to generate shading to be applied to the lower 'layer', and no -- not doing self-shadow as that would require some sort of reference to the 3D shape of the 2D object O_O

Ahh, in that case all you need to do is offset the texture coordinates for the 'upper' layer and render the 'lower' layer with the lower layer's texture blended with black according to the alpha channel of the upper layer.

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!