Day/night time and lighting change idea

Got a great idea for HoA or wish to discuss a current feature? Let us know about it!

Moderator: Staff

User avatar
Roots
Dictator
Posts: 8643
Joined: Wed Jun 16, 2004 6:07 pm
Location: Austin TX
Contact:

Day/night time and lighting change idea

Postby Roots » Fri Jun 12, 2009 8:10 am

I had a random late-night-coding idea pop into my head on a possibly good way for the game to implement day and night time/lighting. I've always disliked it when you play 98% of an RPG in bright, sunny conditions except for those rare special night scenes. There are some games that just let day/night cycles progress somewhat naturally (toned down of course so something like 24 hours = 6 minutes in game time). Sometimes the day/night timer is only "running" when the player is at certain areas of the game, like walking around the world map. Dragon Warrior (Dragon Quest) III for the NES implemented this and actually did a very nice job with it. A town or map could be very different depending upon if you visited it during day time or night time.


So the problem with "ever-lasting daylight" except during special scenes is it just doesn't seem quite like a world when night only happens in special cases. The problem with a day/night timer is that sometimes we would want a scene to occur at a specific time and want to use a specific day/night lighting. If we're in a very different lighting and force an instant or very sudden transition just for the purposes of a scene, well that's kind of cheap.


Anyway here's my idea. We would implement a sort of natural occuring lighting that would occur across a map. For example, if the player was traveling through a forest trail map and we wanted them to have to stop at a clearing in the middle of the map and setup camp because night fall came and it got too dark, we could set the initial lighting condition for the map at say "late afternoon". Then we could have a series of checkpoints across the map and when the player reaches those checkpoints, we progress the lighting a little further. This way whether it took the player 2 minutes or 30 minutes to reach the middle of the map, the lighting conditions would be the same upon entering the clearing.

If the player backtracked (say, made it to the 3rd lighting check point and then turned around and went back to the first), we wouldn't progress the lighting forward or backward. That's one small disadvantage since theoretically the player could spend 30 seconds in one lighting environment and several minutes in another. But if we assume the common case where the player only moves forward through the map and space the lighting checkpoints easily, I think it should be okay.

One thing this idea doesn't address is what do we do if in the same example, the player almost gets all the way to the clearing (so its almost night), then backtracks entirely and exits the map, and then re-enters the map? In that case we might be forced to restore the late afternoon lighting at the beginning fo the map even though it was just night lighting. Or we might have to prevent the player from leaving the map somehow.


Anyway just something I wanted to write down before I forgot it. Such a system should be pretty easy to implement for the programmer (we just have to use map zones), but designing the game around the feature could prove to be a little difficult.
Image
User avatar
prophile
Senior Member
Posts: 324
Joined: Fri Jan 27, 2006 7:18 pm
Location: Chaldon, Surrey, UK
Contact:

Re: Day/night time and lighting change idea

Postby prophile » Sun Jun 14, 2009 1:06 pm

You could base day/night entirely on the player's location. Set a few key points in each map, attach a time of day to each and interpolate between them.
Alastair Lynn / Resident Whinger / Allacrost
User avatar
prophile
Senior Member
Posts: 324
Joined: Fri Jan 27, 2006 7:18 pm
Location: Chaldon, Surrey, UK
Contact:

Re: Day/night time and lighting change idea

Postby prophile » Sun Jun 14, 2009 1:22 pm

To give an example of how it might work:

Code: Select all

#include <math.h>

typedef float vec2 __attribute__((vector_size(8)));

struct KeyPoint
{
   vec2 location;
   float lightLevel;
};

float SelectLightLevel ( vec2 loc, const KeyPoint* points, int pointCount )
{
   float weightTotal = 0.0f;
   float lightLevel = 0.0f;
   for (int i = 0; i < pointCount; i++)
   {
      float xdist = points[i].location[0] - loc[0];
      float ydist = points[i].location[1] - loc[1];
      float weight = powf(xdist*xdist + ydist*ydist, -0.25f);
      weightTotal += weight;
      lightLevel += weight * points[i].lightLevel;
   }
   return lightLevel / weightTotal;
}

// apply an overall tint of: g=lightLevel
//                           b=0.3+lightLevel^4.6/0.7
//                           r=lightLevel^0.44
Alastair Lynn / Resident Whinger / Allacrost
User avatar
Jetryl
Artist
Posts: 1485
Joined: Fri Aug 26, 2005 7:35 am
Location: Southern Minnesota, USA

Re: Day/night time and lighting change idea

Postby Jetryl » Wed Jun 17, 2009 10:34 am

Alternately, just have two things:
1] a setting for a scene to lock at a given time once it reaches that time.
2] Make time-of-day pass exponentially (actually, linearly might work) faster as you get closer. Really, the only reason to have this instead of just waiting the 6 min of gametime, is because they might breeze through the scene in 1 minute. You could just speed things up dumbly (by a factor of 3), but as a point of programming practice, I would always try to avoid these kinds of leaks if it's trivial to do so.


Honestly, though, this ensurer is really overkill. Why?
- Most scripted scenes are totally ToD agnostic. Really. Only a tiny fraction 'need' to be at a given time.

- Most scenes can have an excuse for time passage grafted onto them, because most of them start 'en media res' (sp?), meaning there's no previous context to contradict. 'en media res' is a storywriting term; it refers to scenes that start in the middle of the action. Any flashback is this. Any "meanwhile, over where this other character is" scene, is this. Any "and then a while later" scene is this - and you can really liberally insert these; pretty much any time your character sits down to "do some scene-based action." For example if they're looking through a library, you could just have them find the book in five-seconds. Or, you could play a little passage-of-time soundeffect, wash the screen over with a cinematic transition, and still have them find the book in five seconds of the player's time, but communicate to the player that it presumably took quite a while. In fact, no one will think this is a cop-out at all; they'll actually find it cool, because it's a form of cinematic storytelling. Another common one is characters sleeping at the inn and getting woken up. There are so many excuses that you basically can always count on being able to contrive a scene to be at your desired time. So much so that several games have shipped with this assumption - such as seiken densetsu 3. And in fact succeeded in never having jarring time changes.

So I would say, definitely do the day/night swap-over-time thing. It's totally sweet. Don't over-engineer it, though; only consider building a system of ToD-ensurers AFTER you run into some scene that's not amenable to excuses. I doubt you will. And if you don't, you're wasting tons of work. Never waste work solving hypothetical problems; because programmers barely have enough time to even solve the real problems.
Image
User avatar
Psiweapon
Member
Posts: 76
Joined: Mon Jun 13, 2011 10:00 pm
Location: Ze Interbutt
Contact:

Re: Day/night time and lighting change idea

Postby Psiweapon » Sun Jul 10, 2011 3:44 am

Roots said:
But if we assume the common case where the player only moves forward through the map and space the lighting checkpoints easily, I think it should be okay.


I wouldn't rely on players' common sense for anything. Players will rape, kill and skin your gameplay assumptions in no particular order :angel:

@Jetryl: It's "in media res". Latin for literally in the middle of the thing, or in the middle of stuff.

My take: Combine a regular multiplied time method with the checkpoints idea. When the player is nearing an area that should be entered at a particular time, make the time run faster to reach the needed "hour"
nan
Newbie
Posts: 18
Joined: Sat May 28, 2011 12:57 pm

Re: Day/night time and lighting change idea

Postby nan » Sun Jul 10, 2011 1:43 pm

Alternatively you could allow the player to rest, implement camping(camp fire, tent sprite?) and taverns. The time would be fast forwarded till the particular area is accessible: "Rest until ...".
User avatar
Psiweapon
Member
Posts: 76
Joined: Mon Jun 13, 2011 10:00 pm
Location: Ze Interbutt
Contact:

Re: Day/night time and lighting change idea

Postby Psiweapon » Sun Jul 10, 2011 2:56 pm

That sounds pretty good!
Lordakius
Junior Member
Posts: 25
Joined: Thu May 26, 2016 9:22 pm

Re: Day/night time and lighting change idea

Postby Lordakius » Mon Nov 28, 2016 11:46 am

Without knowing if this topic has been discussed further, I wouldn't recommend the rest until solution, since then you force the player to wait until he can enter a specific area. (at least that is how I understood it)

Is there progress on this or did we throw the idea away ?
User avatar
Roots
Dictator
Posts: 8643
Joined: Wed Jun 16, 2004 6:07 pm
Location: Austin TX
Contact:

Re: Day/night time and lighting change idea

Postby Roots » Thu Dec 01, 2016 6:06 am

The idea wasn't thrown away, we just haven't been in a spot to really implement it. And we probably won't be for a while. It's just an idea right now, and there hasn't been any coding or other effort done with it in mind.

We do have day/night in the game already, but there's no timer that determines when it changes from one to another. The first few maps of the game take place at night, then at the end of one map we transition to another, where it is now day. I think this sort of "forced" day/night is more viable for us to do right now. Also, we don't have any sort of worldmap for the game right now. I'd like to have one, but building one would be quite a lot of work and I don't see us getting around to that anytime soon.
Image

Return to “Ideas and Game Features”

Who is online

Users browsing this forum: No registered users and 1 guest