An attempt to make day/night cycles in TMW

Content and general development discussion, including quest scripts and server code. TMW Classic is a project comprising the Legacy tmwAthena server & the designated improved engine server based on evolHercules.


Forum rules

This forum houses many years of development, tracing back to some of the earliest posts that exist on the board.

Its current use is for the continued development of the server and game it has always served: TMW Classic.

User avatar
v0id
Novice
Novice
Posts: 196
Joined: 15 Sep 2009, 21:31
Location: Désolé, je ne loue pas.

An attempt to make day/night cycles in TMW

Post by v0id »

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 104 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 (amount = 1.0)
Night (amount = 1.0)
night.jpg (169.02 KiB) Viewed 4744 times
Dawn (amount = 0.5)
Dawn (amount = 0.5)
nightfall_or_dawn.jpg (171.82 KiB) Viewed 4745 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
Knight
Knight
Posts: 502
Joined: 04 Jan 2009, 20:04
Location: USA, North Carolina

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

Post by baseballboy »

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: 08 Sep 2004, 19:48
Location: Bern, Switzerland

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

Post by Rotonen »

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: 25 Aug 2005, 16:08
Location: Germany

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

Post by Crush »

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: 15 Sep 2009, 21:31
Location: Désolé, je ne loue pas.

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

Post by v0id »

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
Novice
Novice
Posts: 69
Joined: 18 May 2009, 17:46
Contact:

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

Post by Claire »

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

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

Post by Caput »

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

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

Post by Doulos »

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: 25 Aug 2005, 16:08
Location: Germany

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

Post by Crush »

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
Manasource
Manasource
Posts: 4209
Joined: 01 Nov 2007, 17:35
Location: Internet

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

Post by Jaxad0127 »

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: 26 Jan 2009, 17:23

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

Post by Doulos »

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
Novice
Novice
Posts: 78
Joined: 03 Oct 2009, 02:06

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

Post by August Knight »

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
Manasource
Manasource
Posts: 4209
Joined: 01 Nov 2007, 17:35
Location: Internet

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

Post by Jaxad0127 »

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: 26 Jan 2009, 17:23

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

Post by Doulos »

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
Novice
Novice
Posts: 60
Joined: 11 Jun 2008, 11:34

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

Post by Axalix »

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