Advertisement

2D Dynamic Shadows, Lighting & Mapping

Started by May 23, 2012 06:47 PM
1 comment, last by SimanQzia 12 years, 5 months ago
Greetings again,

That's a second project that I'm posting in this forum.
I was searching for more efficient ways to generate and draw lighting or shadow layers.
However, I never came up with a way that I can apply to both, OpenGL and DirectX.

Note: I've also attached two demos. (High Quality Set)
1. Day lighting demo, just sun shadow generation which has a lot of options. [attachment=9001:Daylighting Demo.rar]
2. Room and day lighting demo. [attachment=9002:Room Lighting Demo.rar]

1. Static Lighting Generation (OpenGL & DirectX 7/9)
At first, I programmed static lighting tool that allows you to generate lighting layer and export it as an image.
I even made some use out of it. I used it to generate shadow mapping for a game called CS2D.

You can check a short preview of it. Just in case, it is available to download.
[media]
[/media]

Tool Screenshots
u15a1_4cf161d6s2.jpg

u15a1_4cf161d6s4.jpg

2. Real-Time Methods and Improvements

(OpenGL & DirectX 7/9)


I felt like it's not enough, so I tried going further.

The main problem I had, the slow calculation of light and the process to record it in the image.

So, I came up with several improvements.
I saved every pixel of light source that was recorded in main pixel map.
This way I just had to remove only the pixels that are necessary in the update - light moving or map changing.

Later on, I changed all the pixel map drawing to scaled image on the screen.
All that was left, to overwrite buffer image only when necessary, that is when player or light is moving, or walls appearing/disappearing.
In the end, I managed to create an algorithm that generates light pixels way damn faster, that was the last step till now.

3. Practical Use

Finally, my lighting library was finished. I searched for the ways to use it. The library was written in BlitzMax and C++Languages.
Surprisingly, it was applied on new CS2D version (0.1.2.0)

Don't mind that daylight shadows shows up in room, that was decided by the creator of the game.
The original library disabled day lighting in the rooms ;}

Comparison between new with Lighting and old CS2D.

comparisoni.png


Video Preview Of The Engine
[media]
[/media]

4. Open Source 2D Lighting Library


I didn't intend to release it to public, however I think I could share it if someone ask it privately :}
I'm also searching for the people whom I could use this engine for!

I could also create a tutorial, that will depend on interest and feedback.

Enjoy!

The work you have done looks really impressive smile.png , thought the announcement forum would be better suited for this kind of post. Or even better a journal here on gamedev.
Advertisement
Sure, I'll check those sections before posting all the other projects :}
Thanks!

This topic is closed to new replies.

Advertisement