2D Real-Time Shading
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
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.
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement