Jump to content

  • Log In with Google      Sign In   
  • Create Account


Want to make light/day cycle, searching for light engine or sugestions / ideas how to achieve


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 BaneTrapper   Members   -  Reputation: 1112

Like
1Likes
Like

Posted 22 March 2014 - 04:39 PM

Hello.

I am working on a hobby project a "2d, rpg, top down, tile based, real time, hack and slash".

I came to a point where i am supposed to add day and night cycle, but i am oblivious how to achieve that, adding light engine would allow to make torches/fire at night to glow which would be good so any suggestions?

 

What i want:

Dynamic lights.
To pass time from day to night and repeat.

To have glow effect like torches.

 

Most have:

Be usable with c++ and OpenGL.

 


Current projects:
The Wanderer, 2d turn based rpg style game

www.gamedev.net/topic/641117-check-up-the-wanderer/


Sponsor:

#2 Álvaro   Crossbones+   -  Reputation: 11891

Like
0Likes
Like

Posted 22 March 2014 - 05:01 PM

I can see two options:
1. Keep things symbolic. Make a day and a night version of each sprite, and do a quick transition from one to the other when the sun goes up or down (you can even have some sound queues, like the ululating of an owl for sunset and the crowing of a rooster for sunrise, plus different background music for day and night). This is an especially good idea if you have some clear rules about what happens at night or during the day (Dangerous creatures wander the woods at night? Shops are only open during the day? I really don't know what your game is about...).
2. Go 3D. You can keep your game mechanics 2D, but if you want to render lighting effects (you mentioned torches), I can't see how you could do that without knowing the geometry of the scene and the characters in some detail.

I strongly suggest going with option 1, particularly for a hobby project.

#3 BaneTrapper   Members   -  Reputation: 1112

Like
0Likes
Like

Posted 22 March 2014 - 05:06 PM

I can see two options:
1. Keep things symbolic. Make a day and a night version of each sprite, and do a quick transition from one to the other when the sun goes up or down (you can even have some sound queues, like the ululating of an owl for sunset and the crowing of a rooster for sunrise, plus different background music for day and night). This is an especially good idea if you have some clear rules about what happens at night or during the day (Dangerous creatures wander the woods at night? Shops are only open during the day? I really don't know what your game is about...).
2. Go 3D. You can keep your game mechanics 2D, but if you want to render lighting effects (you mentioned torches), I can't see how you could do that without knowing the geometry of the scene and the characters in some detail.

I strongly suggest going with option 1, particularly for a hobby project.

All my games geometry is 4 vertices that represent (Box, square), of sizes 32/ 24/ 16 pixels.

Screen:

Wanderer_lost_in_time_Teaser1.png

Example.png

All i want from the light engine is that is has
"dinamic point lights" "shapes for blocking light".

and as mentioned before be usable with c++ and openGL


Edited by BaneTrapper, 22 March 2014 - 05:14 PM.

Current projects:
The Wanderer, 2d turn based rpg style game

www.gamedev.net/topic/641117-check-up-the-wanderer/


#4 Servant of the Lord   Crossbones+   -  Reputation: 17154

Like
3Likes
Like

Posted 22 March 2014 - 06:14 PM

For a basic day/night effect, you can use the glColor color of your vertices, and instead of having them pure white (255,255,255), use a color that changes as the time of day changes, perhaps by having a texture that you use to lookup the colors by index. You do this for all your regularly draw images, when you draw them, except for things you don't want affected by sunset/sunrise/nighttime colorations (things like text, and GUI stuff).

 

kbyt.png

 

Index into the image depending on the time of day. I just slapped this gradient together, but you'll need to finetune it to fit the appearance you want for your game, by trying it out in your code.

 

For lights such as torches, you can use a texture blended with additive alpha blending.

For cast shadows, you can use a texture blended with regular alpha blending.

 

foza.png


Edited by Servant of the Lord, 22 March 2014 - 06:14 PM.

It's perfectly fine to abbreviate my username to 'Servant' rather than copy+pasting it all the time.

[Fly with me on Twitter] [Google+] [My broken website]

All glory be to the Man at the right hand... On David's throne the King will reign, and the Government will rest upon His shoulders. All the earth will see the salvation of God.                                                                                                                                                       [Need free cloud storage? I personally like DropBox]

Of Stranger Flames - [indie turn-based rpg set in a para-historical French colony] | Indie RPG development journal


#5 DareDeveloper   GDNet+   -  Reputation: 892

Like
1Likes
Like

Posted 23 March 2014 - 02:51 AM

A more sophisticated solution would not have to be completely 3D but you would need additional textures that store some information about the shape of the object.

 

This shows a project that did something like that.

https://www.kickstarter.com/projects/finnmorgan/sprite-lamp-dynamic-lighting-for-2d-art?ref=live

 

Ideally that would probably be rough normal vectors stored in a texture ... and the lighting engine would use it.

Guess something like that is needed if you want different light sources to have the desired effect, but not sure what a tool to create those maps with would look like.

 

You might be able to use only one grayscale image with the one value indicating how much the local color is influenced by the ambient light. The ambient light could change over time. The local color would stay the same. Black would mean it is always shown as a shadow.

Faking a local light source by modifying the color of the ambient light and using the resulting color (and maybe intensity) to modify the rendered object color might give reasonable results. Not sure ... guess a lightsource behind an object would be problematic.

 

Using white and black for darker and brighter is not optimal.

Maybe you can look at art tutorials and come up with a smart innovative way to accomplish what you want:

http://androidarts.com/art_tut.htm


Edited by DareDeveloper, 23 March 2014 - 02:57 AM.

Given enough eyeballs, all mysteries are shallow.

ProcGames.com


#6 BaneTrapper   Members   -  Reputation: 1112

Like
0Likes
Like

Posted 23 March 2014 - 07:47 AM

Ive found a tutorial that was pretty simple and i followed it:
http://www.facepunch.com/threads/1011659

Big thanks to for that tutorial "Austin Shindlecker (Austech)"

 

But it was pretty slow making it with lines, but it makes really nice look.

Id like to improve performance allot, on these screens i optimized a bit and that light takes about 20% of cpu which will totally crush my game if i make few of those.

Onto something faster i shall search!

 

Some screens:

Untitled1.png

Untitled12.png

 

I really hoped there is a library / engine that i can just strap onto openGL and get per pixel Light or texture lights but meh, oh well the search continues.

Thank you guys on suggestions but i am unable to build my own light system i just don't have time to study math required.

It is something i will have to do later on, for now i will focus on current project, thank you on the suggestions.

And i someone has a suggestion for a light engine that i can implement with c++ openGL please let me know!


Edited by BaneTrapper, 23 March 2014 - 08:23 AM.

Current projects:
The Wanderer, 2d turn based rpg style game

www.gamedev.net/topic/641117-check-up-the-wanderer/





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS