Ooo...

Published January 08, 2007
Advertisement
Backlighting seems to be basically working now, yey! It's not perfect (I need to tweek a lot of hardcoded constants and other minor stuff), but I've basically proved that the method works which is pretty cool.

For starters, heres the reference image I've been trying to recreate:


Expanding the preprocessing step to generate the full scatter map wasn't too tricky. I had to remove one of the early-out optimisations because it messes up things down the line, but it's still plenty fast enough.



From left to right:
- Calculated backlight factor (how much light shines through at the edges).
- Normal map generated from backlight factor.
- Final scatter map, with normal map in RGB and backlight factor in A.

Now with some pixel shader magic, we use the scatter map to light the sprite. It's quite a simple shader, basically combining regular per-pixel normal mapping with a per-pixel backlight. Most of the work is already done in the preprocessing, the only unusual bit is the light falloff, which uses a finite linear falloff rather than the usual 1/linear, and using two different falloff factors for the two halves of the lighting.

Backlit (totally on top of the light source):


Backlit from the side:


Quite close to the reference image I think. [grin]

After some tweeking and tidy up, I'll post the preprocessing code and the shader code. I've also got to extend the shader to support sprite rotation, but that shouldn't be too tricky.
Previous Entry Backlit sprites, part 1
Next Entry Night Scene
0 likes 2 comments

Comments

HopeDagger
Very awesome. Although my graphics knowledge isn't sophisticated enough to understand how most of this magic is happening, I certainly appreciate the hard work it must take and the fantastic end results. Keep it up! [smile]
January 08, 2007 07:49 PM
Jotaf
Wow, pretty sweet :)

This reminds me of an idea I had back in the days (the old-school CRPGing days). I wanted to add a sort of a normal map to the 2d sprites, so that the lighting wouldn't look so plain. I already had pixel-perfect shadows so this was a natural extension.
The images were just good old pixel-art, so the map would have to be hand-drawn as well; to make it easier I created this little editor that let you heighten or lower the pixels, and then generated the appropriate lighting map. I dropped the project half way through, but it was very promising. I'm wondering now if it would be worth finishing...

BTW, any chance you can show us some assorted lights applied to all the test images you have? :P
January 09, 2007 10:15 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement
Advertisement