An attempt to make day/night cycles in TMW

Content and general development discussion, including maps, quests, and server code from the development team.
User avatar
v0id
Novice
Novice
Posts: 196
Joined: Tue Sep 15, 2009 10:31 pm
Location: Désolé, je ne loue pas.

An attempt to make day/night cycles in TMW

Post by v0id » Mon Jan 25, 2010 12:29 am

Hi,

Today we had a talk with BlueSoul and some other people about how to implement a day and night cycle. Not the cycles scheduling system, the graphical effect.
One idea that came out is to use dark blue layer and blend it with the actual graphics in a special way.
The advantage of this system is that you dont have to modify the external graphics for the night cycle, and it allows transitional effects (night -> dawn -> day).
The main disadvantage is an additional graphics processing.

For testing purposes, here is a patch
0001-Nightfall-system.patch.zip
patch for git.
(1.99 KiB) Downloaded 61 times
that implements this idea.

To install :

Code: Select all

git clone git://gitorious.org/tmw/mainline.git tmw
cd tmw
git am path/to/the/patch
autoreconf -i
./configure
make
./src/tmw
I noticed a little drop of fps with my configuration, but it is still nicely playable. I'd like to hear about you.
The patch applies the night effect all the time, and it also affects the GUI (more on this below).
night.jpg
Night (amount = 1.0)
night.jpg (169.02 KiB) Viewed 2535 times
nightfall_or_dawn.jpg
Dawn (amount = 0.5)
nightfall_or_dawn.jpg (171.82 KiB) Viewed 2536 times
What it does and how :

* For now, it is implemented for the software rendering, not OpenGL.
* The effect is performed on each screen update just before the SDL_Flip() call.
* It affects the SDL_Surface that represents the whole screen, so both the GUI and the world. I am sure their is an intermediate step where the GUI is not yet in this surface, or there is a separate SDL_Surface for it before a blit on the global SDL_Surface.
* A separate function performs an Overlay blending of a dark blue color on each pixel of the original SDL_Surface.

If you think this implementation is relevant for a day/night effect, what remains to do is :

* Retrieve the server time, for example every hour, and make a float in [0,1] to pass to the function that realizes the effect. That would update the rendering and make a smooth transition between day and full night.
* I think it's still acceptable to perform the effect on the GUI if there is no other choice, but it would be better to apply it only on the world.
* Optimize the rendering and implement it for the opengl rendering too.

Regards
User avatar
baseballboy
Warrior
Warrior
Posts: 501
Joined: Sun Jan 04, 2009 9:04 pm
Location: USA, Alabama

Re: An attempt to make day/night cycles in TMW

Post by baseballboy » Mon Jan 25, 2010 1:13 am

Interesting
BaseBaIIBoy - 99, Zalika - 95, Mou. - 86, baseballboy - 83, Abacus - 82, Laticia - 76

<o11c> More boobs please.
User avatar
Rotonen
TMW Adviser
TMW Adviser
Posts: 3154
Joined: Wed Sep 08, 2004 8:48 pm
Location: Espoo, Finland

Re: An attempt to make day/night cycles in TMW

Post by Rotonen » Mon Jan 25, 2010 7:46 am

It shouldn't dim the light effects like the soul menhir effect.
This message used to be meaningful.
User avatar
Crush
TMW Adviser
TMW Adviser
Posts: 8046
Joined: Thu Aug 25, 2005 5:08 pm
Location: Germany

Re: An attempt to make day/night cycles in TMW

Post by Crush » Mon Jan 25, 2010 1:01 pm

Is there a reason why you don't use the existing overlay system (the engine which draws the clouds, for example) for this? That way you wouldn't also affect the gui. As Rotonen pointed out it would be better when it would be possible to exclude some graphics like certain particle effects from the effect. The only feasible method I could think of would be to reclor tiles and sprites themself before drawing with them.
  • former Manasource Programmer
  • former TMW Pixel artist
  • NOT a game master

Please do not send me any inquiries regarding player accounts on TMW.


You might have heard a certain rumor about me. This rumor is completely false. You might also have heard the other rumor about me. This rumor is 100% accurate.
User avatar
v0id
Novice
Novice
Posts: 196
Joined: Tue Sep 15, 2009 10:31 pm
Location: Désolé, je ne loue pas.

Re: An attempt to make day/night cycles in TMW

Post by v0id » Mon Jan 25, 2010 2:22 pm

Is there a reason why you don't use the existing overlay system
Thanks to point that out. That's my will to use something like that. In fact, I ve just explored the code yesterday, and my priority was to test the effect, in terms of performance and quality (and i d like to know more about that, if some of you could test it :) ). So i ve gone straight to the global sdl surface :)

So that's the next step.
The only feasible method I could think of would be to reclor tiles and sprites themself before drawing with them.
Good idea. That would prevent to apply the effect each frame and save some cpu.
User avatar
Claire
Peon
Peon
Posts: 69
Joined: Mon May 18, 2009 6:46 pm
Contact:

Re: An attempt to make day/night cycles in TMW

Post by Claire » Mon Jan 25, 2010 2:27 pm

night-time and day time is a great idea!!! yay!! :)
Caput
Peon
Peon
Posts: 5
Joined: Thu Jan 07, 2010 2:07 am

Re: An attempt to make day/night cycles in TMW

Post by Caput » Mon Jan 25, 2010 9:36 pm

Yeah, that is a good idea!
User avatar
Doulos
Novice
Novice
Posts: 189
Joined: Mon Jan 26, 2009 6:23 pm

Re: An attempt to make day/night cycles in TMW

Post by Doulos » Tue Jan 26, 2010 10:15 pm

Please keep in mind that certain areas will remain unaffected.

Caves, for example, cannot undergo "night". That's just silly since they're not lit up by the Sun. Other areas I can think of would be inside buildings. The lighting would be local (lamps, candles, etc.) unless you care to explain away the coding laziness by saying all TMW buildings come complete with glass tops.

Please don't create a global, careless "night".

Note: :idea: Dawn/nightfall would be more convincing if the land had a more orange "cast" than just a steadily increasing blue that covers the land.

If you're going to implement day/night, do it well.

:wink:
User avatar
Crush
TMW Adviser
TMW Adviser
Posts: 8046
Joined: Thu Aug 25, 2005 5:08 pm
Location: Germany

Re: An attempt to make day/night cycles in TMW

Post by Crush » Tue Jan 26, 2010 10:25 pm

Regarding night in buildings: It depends.

Some buildings might be abandoned and dark during the night.

Other buildings might be lit by torches, candles or other light sources during the night. I would expect the light conditions to be different from during the day where the main light source is the sunlight which comes through the windows.

In any case the view out of the windows should be different during the night.


An idea how we could do that? anyone?
  • former Manasource Programmer
  • former TMW Pixel artist
  • NOT a game master

Please do not send me any inquiries regarding player accounts on TMW.


You might have heard a certain rumor about me. This rumor is completely false. You might also have heard the other rumor about me. This rumor is 100% accurate.
User avatar
Jaxad0127
TMW Adviser
TMW Adviser
Posts: 4209
Joined: Thu Nov 01, 2007 6:35 pm
Location: Internet

Re: An attempt to make day/night cycles in TMW

Post by Jaxad0127 » Tue Jan 26, 2010 11:49 pm

Crush wrote:Regarding night in buildings: It depends.

Some buildings might be abandoned and dark during the night.

Other buildings might be lit by torches, candles or other light sources during the night. I would expect the light conditions to be different from during the day where the main light source is the sunlight which comes through the windows.

In any case the view out of the windows should be different during the night.


An idea how we could do that? anyone?
Duplicate each tileset for day/night and carefully map so we can swap between them on the fly and have it look good. Your map changing proposal for manaserv is the best place to add this new functionality (tileset swapping).
Image
User avatar
Doulos
Novice
Novice
Posts: 189
Joined: Mon Jan 26, 2009 6:23 pm

Re: An attempt to make day/night cycles in TMW

Post by Doulos » Wed Jan 27, 2010 12:52 am

Crush wrote:Regarding night in buildings: It depends.

Some buildings might be abandoned and dark during the night.

Other buildings might be lit by torches, candles or other light sources during the night. I would expect the light conditions to be different from during the day where the main light source is the sunlight which comes through the windows.

In any case the view out of the windows should be different during the night.


An idea how we could do that? anyone?
True: buildings would be darker if they only had candles lighting them. They'd be subject to partial change. Caves should be static.

Would this mean actually lighting the rooms with light sources? No shadows necessary... but parts of the room where the candle light is brightest?
August Knight
Peon
Peon
Posts: 78
Joined: Sat Oct 03, 2009 3:06 am

Re: An attempt to make day/night cycles in TMW

Post by August Knight » Wed Jan 27, 2010 3:29 am

I've noticed that players with their Ambient FX on high wandering in caves acts as a light source. Maybe create an NPC with such effects to simulate a candle/light source.

On magic "houses" or areas, we could use the glow of those wisps/spectre/poltergeist, if not bobbing around, as a source of light/static NPC.
User avatar
Jaxad0127
TMW Adviser
TMW Adviser
Posts: 4209
Joined: Thu Nov 01, 2007 6:35 pm
Location: Internet

Re: An attempt to make day/night cycles in TMW

Post by Jaxad0127 » Wed Jan 27, 2010 4:10 am

August Knight wrote:I've noticed that players with their Ambient FX on high wandering in caves acts as a light source. Maybe create an NPC with such effects to simulate a candle/light source.

On magic "houses" or areas, we could use the glow of those wisps/spectre/poltergeist, if not bobbing around, as a source of light/static NPC.
That's just a simple overlay.
Image
User avatar
Doulos
Novice
Novice
Posts: 189
Joined: Mon Jan 26, 2009 6:23 pm

Re: An attempt to make day/night cycles in TMW

Post by Doulos » Wed Jan 27, 2010 3:41 pm

Rotonen wrote:It shouldn't dim the light effects like the soul menhir effect.
Or on any of the game windows such as chat box (it's a dark blue too, just noticed it).
Axalix
Peon
Peon
Posts: 59
Joined: Wed Jun 11, 2008 12:34 pm

Re: An attempt to make day/night cycles in TMW

Post by Axalix » Wed Jan 27, 2010 11:02 pm

jaxad0127 wrote:Duplicate each tileset for day/night and carefully map so we can swap between them on the fly and have it look good. Your map changing proposal for manaserv is the best place to add this new functionality (tileset swapping).
Why can't you apply the same mechanisms that are being used while coloring the items (clothes)? Duplicating each tileset (manually) may take much time, plus it will double current number of objects. Nevertheless, recoloring tiles on the fly can also help with the effect of gradual changing from twilight to deep night. So, i also agree with this:
Crush wrote:The only feasible method I could think of would be to reclor tiles and sprites themself before drawing with them.
Post Reply