Jump to content
The Dark Mod Forums

Dynamic daytime cycles


MirceaKitsune

Recommended Posts

Here's a stranger idea I've been thinking about with a lot of interest. I might want to use it as part of a campaign I'll make someday, though I thought to ask early on in case others might try it earlier. As far as I'm aware, idTech 4 should have the abilities needed to support this, but it might take some hacking and will certainly require new scripts.

 

Would it be possible to create a complete dynamic daytime cycle in TDM? Broken down into exact components, what I'd like to do is basically:

 

- Skybox, texture: First off, a sky texture that changes colors dynamically in a smooth and realistic transition; During the day bright blue, during dawn / dusk orange and purple near the horizon, during the night a black starry sky. Optionally, a texture of moving clouds layered on top of the sky would be a great addition, respecting the lighting of the sun behind them.

 

- Skybox, celestial bodies: Next we need the actual sun and moon to move across the sky. I assume this can be achieved by simply creating a textured flat surface for each, then binding them to a rotating entity. As far as I'm concerned, the sun and moon can just transition overhead in a circular pattern (like Minecraft), I'm not personally interested in fancy orbits.

 

- Lighting: Obviously we'll want two dynamic lights to represent the sun and moon, which change angle color and intensity accordingly. Ideally we can use infinite distance light sources (if idTech 4 supports such), who's origin is ignored and only the angle is used to determine shadow direction.

 

- Sounds: An optional but welcome addition would be speakers that loop sounds at different intensities based on daytime. Lets crickets sing during the night and birds during the day, etc.

 

- Clocks: A secondary but noteworthy feature would be clocks that show the daytime. First a mechanical clock item, which the player can pick up like the compass or spyglass, and which shows the hour just like the spyglass shows direction. Second are stationary clock entities (grandfather clocks, clock towers, etc) who's tongues should correctly indicate the in-game time of day.

 

- Daytime controlled AI paths: The last great ability would be AI's taking different actions based on the time. For instance: Civilians walk around the street during the day, visit a tavern for a few hours at sundown, then go to sleep in their bed during the night. The daytime should of course be a publicly available variable, so custom scripts can use it for various features.

 

I know some will say "this is overkill for TDM, you don't hang around long enough to notice the days pass by". I disagree however, especially for long campaigns or complex missions: Some levels took me over 3 hours to complete, at least during the first run when I had to learn them... therefore a sped up daytime cycle (eg: 1 in-game day = 1 real-life hour) can make perfect sense for some FM's! Apart from the visual aspect, consider the fun extra challenge of finding different routes to sneak through based on the daylight outside, or learning when a guard stops patrolling a certain area at a certain hour and using your clock to make your entry at the best time. I agree this isn't something missions should do regularly, but a few special ones could totally make use of this mechanic creatively.

Link to comment
Share on other sites

[clouds] respecting the lighting of the sun behind them.

 

It's not overkill :) Everything apart from the lit clouds would be do-able with a map script. You can see an example of the clocks and AI changes in grayman's WS1: In the North.

 

For the lit clouds, you'd need a custom shader. I started work on one in the summer, developing it in shadertoy, but got sidetracked.

Link to comment
Share on other sites

http://forums.thedarkmod.com/topic/17606-what-kind-of-fan-missions-would-you-like-to-see/?p=383280

 

Though in actual protoyping I've decided not to try lengthening shadows; partly for gameplay/design reasons, partly because I've already had to fix a parallel-light-not-passing-through-visportal glitch.

  • Like 1

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Link to comment
Share on other sites

Someone cleared me up on parallel lights in another thread, so dynamic sun / moon lights should be simple. A custom shader is of course what I had in mind, for both the changing sky texture as well as clouds with lighting.

 

What might be tricky is that, daytime needs to be a single variable, which increases each frame and eventually resets. Everything must be able to act upon its value: The sun and moon can't just rotate at a given speed... their rotation must sync up with this number, and so do the blend values between sky textures. Do materials support using script variables to determine how multiple textures are combined on one surface?

 

And that's an interesting prototype. I hope at least one of these attempts get finished and stable to use throughout missions!

Link to comment
Share on other sites

Do materials support using script variables to determine how multiple textures are combined on one surface?

 

Yes. There's a script function setShaderParm() that you use to get numbers into material shaders.

 

Everything is straightforward except the lit clouds, although of course setting up multiple AI paths is more work that setting up one set. And if you want a result as sophisticated as WS1, then you can multiply those multiple paths by all your multiple RIT paths too :blink:

Link to comment
Share on other sites

The way I would do this is like the game Anchorhead. The gameplay is broken into chapters. When you complete the objectives for one chapter, it opens the next chapter later in the day or night. Then you can script the changes.

 

It's more natural for our kind of game to advance time of day in parallel with the story/gameplay than procedurally.

What do you see when you turn out the light? I can't tell you but I know that it's mine.

Link to comment
Share on other sites

Yes. There's a script function setShaderParm() that you use to get numbers into material shaders.

 

Everything is straightforward except the lit clouds, although of course setting up multiple AI paths is more work that setting up one set. And if you want a result as sophisticated as WS1, then you can multiply those multiple paths by all your multiple RIT paths too :blink:

 

Nice... that should definitely make this idea doable then!

 

As for AI paths, I assume they would be one of the easiest things: Simply create a new entity called something like path_daytime, and have it target multiple path_corner entities, each target taking a minimum and maximum time of day between which it can be randomly chosen. Of course the mapper must create the paths for all possible routes and actions, but I think that's a small price to pay overall.

Link to comment
Share on other sites

I feel like the one thing that would get kind of wonky even if you did get it working, is the dynamic skylights. More the shadows. I mean I don't know the id4 near as well as most of you but the shadows tracing is useful in controlled scenarios, and can be somewhat painful without lightmaps. Well that and the fact of there not being any form of occlusion or soft shadowing.

 

I'd like to here SteveL's opinion on the matter but the lighting available is extremely basic for shadows. You can fake ambient light bounce and Irradiance particles with using smaller diffused lights with most the advanced effects disabled. Problem is you can't effectively setup a sky light entity to throttle that subtle effect. If you could tie in the color of the ambient world light with the transition of the day night cycle, it would still be a bit flat but would be a start.

Edited by Epifire

Modeler galore & co-authors literally everything

 

 

Link to comment
Share on other sites

You certainly could update the main ambient light, plus smaller local ambient lights too to stay in sync. But moving those small ambient lights around so that they stay looking natural with different sun angles would be a huge pain and no longer straightforward.

 

A more practical plan would be katsbit's method of quickly simulating a reflected skylight by using a pair of parallel lights, the main one shadow casting and the opposing one not, and colored from the opposite side of the colour wheel.

 

You'd want to use several parallel sun or moonlights instead of one for the whole map, for efficiency. You'd keep them all at the same angle, and cover the transitions between them with tunnels or indoor areas.

 

One extra task with the dual light system is that you have to turn off your non-shadow-casting parallel lights when the player is indoors, using location scripts.

 

The shadows would look the same as they do now. I don't know whether anyone has used light maps in TDM, but most rely on engine shadows plus a few ambients. The only thing like light maps in TDM is the pre caching of worldspawn shadows during dmapping. They get stored as models in your dmap file. With moving parallel lights they'd have to be calculated dynamically, but that in itself wouldn't be a problem. The perf hit from stencil shadows comes from their geometric complexity and the amount of overdraw that they create, not from having to create them in the vertex shader.

 

Yes I have done this myself in a map... The one I was working on when I made this thread. For moonlight anyway.

 

Daylight comes with its own problems. As someone pointed out to me in another thread, the AI spot you instantly in bright light.

  • Like 1
Link to comment
Share on other sites

Changing the ambient light colour just needs tables (though results may vary depending on the player's ambient rendering setting), and a skybox background can blend gradually between two cubemaps: see the links via my first link above.

 

The flat look is unfortunate, though. You can use tricks like blend lights (the shadow effect inside the arch) to make things less visually monotonous, but that's only a partial solution.

post-35144-0-95319000-1452093661_thumb.png

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Link to comment
Share on other sites

Changing the ambient light colour just needs tables (though results may vary depending on the player's ambient rendering setting), and a skybox background can blend gradually between two cubemaps: see the links via my first link above.

 

The flat look is unfortunate, though. You can use tricks like blend lights (the shadow effect inside the arch) to make things less visually monotonous, but that's only a partial solution.

attachicon.gifitr1.png

 

Or use the Strombine technique:

 

http://lunaran.com/page.php?id=165

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

Thinking about this, having a slow moving moon/sun would be cool but the map would have to be small to cope with so many surfaces being lit. But during the day I would imagine it would be more perf friendly because all the night/street and other lights could be removed!

 

I am gonna try this on a section of Bcd or the garden in Sir Talbot for comparison purposes.

Link to comment
Share on other sites

I did wonder about a global Strombine ambient, but I'm not sure how it should work around arches and tunnels and so forth. (The opposite problem to lights/ambientlightnfo_clouds, which looks good over open terrain but creates cloud patterns under overhangs where there shouldn't be any.) In the above screenshot, there's a shadow light inside the arch and the roof above is unshadowed.

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Link to comment
Share on other sites

The way I would do this is like the game Anchorhead. The gameplay is broken into chapters. When you complete the objectives for one chapter, it opens the next chapter later in the day or night. Then you can script the changes.

 

It's more natural for our kind of game to advance time of day in parallel with the story/gameplay than procedurally.

This, or a variation on it (say, update the skylight position every few seconds, not every frame) would be a big performance improvement.

 

If you update a shadowcasting light position every frame, then the engine needs to calculate and upload to the GPU a new shadowcasting silhouette every frame. That's pricey, it's basically the same cost that already comes with moving torches and moving AI, known perf killers.

 

The Strombine method of baking lighting by hand looks *really* labor-intensive. Has anyone tried it?

Link to comment
Share on other sites

There's a small/simple demo map: http://wiki.thedarkmod.com/index.php?title=Light_Textures_and_Falloff_Images&redirect=no#Example_from_Rich_is_Bored

I don't know of any full-scale missions using Strombine lights. Some use grime corner decals, and Arcturus's Christmas map appears to have baked-in shadows applied as textured models.

Edited by VanishedOne

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Link to comment
Share on other sites

Strombine could work with complex occluding geometries but not as a single light. Basically you would need a hierarchy where the largest un-occluded surface area

is lit and all other complex areas are in shadow then relight the next largest area excluding areas already lit by the first light. And so on...

 

Cubemap lights would make this easier ;)

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

I was thinking of using only two light sources for the whole map (one for sun and one for moon), as multiple light sets seem a bit excessive. In any case, I agree good area portaling is certainly a must, since even one dynamic light can be slow when it touches so many surfaces.

Link to comment
Share on other sites

So had a play at converting Sir Talbot to a daytime mission -

 

- http://forums.thedarkmod.com/topic/11610-darkmod-inspiration-thread/page-53

 

That looks really awesome and neat, I like! Glad to have been of inspiration :) Since nearly the entire mission takes place indoors, this shouldn't affect the gameplay too much either.

 

The real test though would be adding the actual daytime cycle. Of course as an experiment, since I assume this mission is too small to make any practical use of it.

Link to comment
Share on other sites

games that do have a day/night cycle seem to update the suns position every 15 minutes, so evey 15 minutes you can see the shadows cast on the ground move. they don't jump to a new position, they slide across the ground in a fluid motion.

 

Sure. A dynamic smooth transition (updated each frame if possible) is what I'm thinking about too. Only trick is doing it for a material, two objects (sun and moon planes), and two dynamic lights... all at once and in sync.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • OrbWeaver

      Finally got round to publishing a tutorial on baking normal maps in Blender, since most of the ones we have are inaccessible or years out of date.
      · 0 replies
    • nbohr1more

      The FAQ wiki is almost a proper FAQ now. Probably need to spin-off a bunch of the "remedies" for playing older TDM versions into their own article.
      · 1 reply
    • nbohr1more

      Was checking out old translation packs and decided to fire up TDM 1.07. Rightful Property with sub-20 FPS areas yay! ( same areas run at 180FPS with cranked eye candy on 2.12 )
      · 3 replies
    • taffernicus

      i am so euphoric to see new FMs keep coming out and I am keen to try it out in my leisure time, then suddenly my PC is spouting a couple of S.M.A.R.T errors...
      tbf i cannot afford myself to miss my network emulator image file&progress, important ebooks, hyper-v checkpoint & hyper-v export and the precious thief & TDM gamesaves. Don't fall yourself into & lay your hands on crappy SSD
       
      · 7 replies
    • OrbWeaver

      Does anyone actually use the Normalise button in the Surface inspector? Even after looking at the code I'm not quite sure what it's for.
      · 7 replies
×
×
  • Create New...