2D Real-Time Shading

Started by
3 comments, last by Dreq 19 years, 6 months ago
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
"Mommy, where do microprocessors come from?"
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.
"Voilà! In view, a humble vaudevillian veteran, cast vicariously as both victim and villain by the vicissitudes of Fate. This visage, no mere veneer of vanity, is a vestige of the vox populi, now vacant, vanished. However, this valorous visitation of a bygone vexation stands vivified, and has vowed to vanquish these venal and virulent vermin vanguarding vice and vouchsafing the violently vicious and voracious violation of volition. The only verdict is vengeance; a vendetta held as a votive, not in vain, for the value and veracity of such shall one day vindicate the vigilant and the virtuous. Verily, this vichyssoise of verbiage veers most verbose, so let me simply add that it's my very good honor to meet you and you may call me V.".....V
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.
"Mommy, where do microprocessors come from?"
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.
"Voilà! In view, a humble vaudevillian veteran, cast vicariously as both victim and villain by the vicissitudes of Fate. This visage, no mere veneer of vanity, is a vestige of the vox populi, now vacant, vanished. However, this valorous visitation of a bygone vexation stands vivified, and has vowed to vanquish these venal and virulent vermin vanguarding vice and vouchsafing the violently vicious and voracious violation of volition. The only verdict is vengeance; a vendetta held as a votive, not in vain, for the value and veracity of such shall one day vindicate the vigilant and the virtuous. Verily, this vichyssoise of verbiage veers most verbose, so let me simply add that it's my very good honor to meet you and you may call me V.".....V
*smacks his head* Its always the obvious that is overlooked >.<
"Mommy, where do microprocessors come from?"

This topic is closed to new replies.

Advertisement