Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views


Sign in to follow this  


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.
Sign in to follow this  


Recommended Comments

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]

Share this comment

Link to comment
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

Share this comment

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!