Lighting a 2D RPG, tile-based, top-down game. So confused.

Started by
4 comments, last by Eric F. 8 years, 4 months ago

Hey all.

I have my own editor (Direct2D) and engine, and its all coming along nicely. I now need to add lighting (and possibly later shadows), and after spending the whole day yesterday and today researching on google and reading articles on Gamedev, I'm 100% confused and unsure on how to proceed. I dont want to start on a path that will lead nowhere or make the engine slow to a crawl because of bad implementation.

My game is tile-based, and I would like to add several lighting effects, such as:

- objects emitting light (candles, torches, camp fires)

- global lighting (to have the whole screen appear with a blueish tint, for example)

- particles emitting light

- a light radius around the player

- each light source needs to modulate depending on other light source, if possible.

I read about using alpha bitmaps you draw on top of your objects and such, but I feel that this is an old technique that would be taxing if several "light maps" would be used. It also raises the question of Z-order of the tiles vs player vs lights and shadows, etc.

Then I read about shaders--which I have ZERO experience with--and seem like what I should be using to add lighting to my game.

I would welcome any suggestions, and I am starting the lighting system from scratch so whatever is the current norm is fine with me. I wish to stay with Direct2D if it is an option.

Are shaders the way to go? If so, are there any web/reading material focused on 2D I could read?

Thanks a lot! Sorry if this topic has been covered before, but none of what I found so far was helpful.

PS: As a reference, I am trying to accomplish something similar to how Delver's Drop does lighting to start with:

Delvers-Drop-Puzzle-Room.jpg

with a mix of he old Diablo games:

maxresdefault.jpg

Advertisement

Hi ,

The way you can do this is by using ambient light and some simplified version of point light.

Every light source will have intesity and radius/distance in screen space.

You can use normal maps for better details , but creating them for 2D space is not easy you have to find a good soft for that ( I dont know if maya / max/blender can do that).

And finaly dont forget about gamma correction , when you put your textures in the shaders :)

dgi.

And one more thing if your engine is working with layers(background,tiles,objects,gui)

You can render the background to texture(1) , then render tiles and objects to another texture(2)(it is better if you do the lighting as post - processing).

Then you render (1) - > (2) - > gui

to achieve the first image:

1. you render your normal scene.

2. accumulate lights into a dedicated image. You can either calculate the fall off by hand, or better, let the artist draw something. (so it's nothing else than the additive image drawing)

3. multiply pixel by pixel both images.

one step further would be to render all sprites that should cast shadows (from 1.) into a separate image. during 2. you'd walk pixels from the center of the lightsource towards the borders and stop walking if you hit an occluder pixel. step 3 stays the same, then it should look something like: http://www.catalinzima.com/wp-content/uploads/2008/05/dynamicshadows11.jpg

Lighting in those two games have been faked, So I wouldn't try to worry too hard. Just try to find something that works.

For example, you can use a post processing effect to draw fog over the screen, Then use an addative mass to simulate lighting within an area around a lamp.

Thanks for the suggestions guys.

I moved my rendering from DX9 to DX11, and oh my, how different it is. As soon as I'm done with the basics I'll get back on track with the lighting and investigate what you guys proposed.

It's taking me several days to put back in what was in D3DX9. I could use like, DirectXTK, but I want to learn and stay lib-free.

This topic is closed to new replies.

Advertisement