Jump to content


Photo

Dynamic moonlight


27 replies to this topic

#1 SteveL

SteveL

    Hero Coder

  • Active Developer
  • PipPipPipPip
  • 3669 posts

Posted 07 March 2014 - 11:48 PM

This a demo map for the dynamic moonlight that varies with cloud cover. One of two moonlight tests I'm working on. Discussion and screenshots in the WIP thread today: http://forums.thedar...post__p__339257

Unfortunately I've not done a pk4 before and there's a problem with it -- I can't start the map using the New Mission route. It works when installed and loaded via the console. It's just called "moon" so install it like any mission but then try loading it with: map moon

The map starts off with the moon fully hidden behind a cloud for 20-30 seconds to give the player time to orient. Then it'll start to appear. Stand where you can see some shadows and look to the south west for the moon.

You might want to use the TIMESCALE console command to fast forward at any time.

As anyone who digs into the pk4 will see, the secret to this is a low-res (128x128) export of the cloud layer's alphamap (done in gimp), and stored in an entityDef. I'll be back to give a detailed explanation tomorrow (yawn!). Cloud position is preserved on save games. The script doesn't hold or need any variable data.

Hopefully someone will be able to tell me what I'm doing wrong with the pk4: [Link removed -- fixed version below]

Edited by SteveL, 08 March 2014 - 05:46 PM.

  • SiyahParsomen, RPGista and Anderson like this

#2 stumpy

stumpy

    Advanced Member

  • Member
  • PipPipPip
  • 1675 posts

Posted 08 March 2014 - 12:21 AM

i think its missing a guis loading screen.

#3 SteveL

SteveL

    Hero Coder

  • Active Developer
  • PipPipPipPip
  • 3669 posts

Posted 08 March 2014 - 07:06 AM

Did it work for you loading with console?
I never put a gui loading screen in, so I'm not missing a file. I'm not sure that can be the problem as I can create a new empty map and load it using the new mission route, again without adding a gui screen.

Edited by SteveL, 08 March 2014 - 07:06 AM.


#4 grayman

grayman

    Master Builder, Coder

  • Active Developer
  • PipPipPipPipPip
  • 11921 posts

Posted 08 March 2014 - 08:54 AM

I tried it using the in-game loader and it crashed. But I'm using a debug version of the DLL, which crashes sometimes in situations where a release version doesn't. I haven't debugged the crash.

What happens when others try loading it this way?

I used the "map moon" console method and it came up fine. It's an impressive technique once it gets going. For demo purposes, however, you might want to make the clouds move much faster. At first i swore the clouds were stationary and the stars were moving. Probably an optical illusion.

#5 SteveL

SteveL

    Hero Coder

  • Active Developer
  • PipPipPipPip
  • 3669 posts

Posted 08 March 2014 - 10:05 AM

It crashes for me using the in game loader too. I have to load it via console map command. Thanks for testing it. I have no idea how to interpret the crashing when normal loader is used. If no-one can fix that for me, I'll rebuild it from scratch instead of cutting out loads of stuff from my test map (which is what I did to make the above demo).

You can see it's the clouds moving if you look at the horizon, but I'll speed up the clouds on the next upload. I'm just extending it to give my caulk-tubes "method" of propagating moonlight a workout, and I'm adding a switch so I can can toggle the dynamic moonlight reduction off for the purpose of testing the light reaching all corners. I'll also set the cloud direction differently. I used a 45% angle for this demo but of course that means the same clouds pass over the moon with each cycle of the texture. There's no need for that repetition. The clouds look quite different when seen at different angles, so setting it an oblique angle would give hours without repetition.

#6 RJFerret

RJFerret

    Advanced Member

  • Member
  • PipPipPip
  • 1066 posts

Posted 08 March 2014 - 11:24 AM

It's not just the missing GUI, I copied/modified a GUI from another mission and it crashed in midst of loading.
"The measure of a man's character is what he would do if he knew he never would be found out."
- Baron Thomas Babington Macauley

#7 SteveL

SteveL

    Hero Coder

  • Active Developer
  • PipPipPipPip
  • 3669 posts

Posted 08 March 2014 - 11:59 AM

I will have a go at fixing it now by adding the dynamic moonlight bits only to a new map which loads ok. I'm hoping the glitch is down to me deleting loads of stuff from a much bigger map in DR to make this demo rather than the load of a big entityDef

Thinking about how to make this effect prefab-able, or at least reuseable in DR: the cloud direction / speed could be set with shaderparms on the cloud patch, because they'll be accessible to both the script and the material. It would be better if the mapper could choose a starting position for the clouds, so they can choose bright or clear over the moon, but that'll depend whether there's another free shaderparm we can co-opt. It might benefit from a higher-res texture too: 1024 gets pretty low-res when it's stretched over the sky. It's fine for most cloud layers but this one is meant to be looked at a lot.

#8 SteveL

SteveL

    Hero Coder

  • Active Developer
  • PipPipPipPip
  • 3669 posts

Posted 08 March 2014 - 12:42 PM

Fixed it! Phew! The moonlight setup wasn't the problem. It was something in my blueroom. I reacreated the blueroom with just the bits needed for this demo and it now works through the normal loader.

I'll upload a fresh version when I've made it go faster and tried another cloud direction and written up the caulk tubes bit.

#9 SteveL

SteveL

    Hero Coder

  • Active Developer
  • PipPipPipPip
  • 3669 posts

Posted 08 March 2014 - 03:34 PM

Ok guys, see if you can break this.

New version of the demo map with the crashing-at-start issue fixed, with faster clouds at an oblique direction so they don't repeat, and with extended areas to demo the second thing I want to test: a single parallel light flooding entire map with moonlight just like ambient world does (earlier discussion here: http://forums.thedar...post__p__338956 ). You still start off with 15 seconds of cloud, but overall the speed is tripled.

The moonlight effect looks less natural at this accelerated speed, but having to wait a minute between transitions in a test map is unhelpful. Please take that into account, as well as ignore missing walls.

I've added a big switch near map start that lets you turn off the dynamic moon dimming, and leaves it shining bright cloud or not, to make it easier to test the moonlight propagation.



Notes on the single moonlight setup

test map.png exploded test map.png

DISCLAIMER: I have no idea why this method works or whether it will tomorrow. I'm just sharing it because I've not been able to break it yet in 3 maps I've tried it in.

There's a single parallel light in the box high above the map. It's connected up to every exterior visleaf by caulk tubes, and to every interior visleaf that needs moon shadow. The end of each route has a single VP between the visleaf and the moonlight. The big area has a single caulk tube which floods a box that sits over the whole area. If you open up that top ceiling, you'll see lots of little VPs inside the box, one for each visleaf in the big area below.

If you brick up any of the visportals in the ceiling above a visleaf, the moonlight will glitch in that visleaf.

I've found the portals don't need to be open. You can use permanently closed func portals if you want, but I see no need. The extra portals don't open unless the leaf below them is to be rendered anyway.

You need a func static ceiling if you have a VP in the ceiling of a room of course. I've left off the FS ceiling in the building at the top right/northeast of the map so you can see sky through the VPs, and you can see they cast a small square of moonlight on the walls of the room.

The test map: https://www.amazon.c...yRr0shA-cB3zC38

EDIT: Added 2nd image

Update Nov 2014: I know a bit more about how this works now and I don't necessarily recommend it for a big map. It makes all areas in the map "connected" areas which means all the entities in those areas get tested for shadow interactions with the current view. That's not necessarily a big problem -- it's a bounding-box test rather than an expensive test on the exact shadow -- but the technique is disabling a (problematic) performance optimization in the engine so use with caution and if there are performance issues maybe try to break up the exterior into more than one parallel light separated by an indoor section or tunnel to cover the seam between the parallel lights.

Edited by SteveL, 08 November 2014 - 09:33 PM.

  • SiyahParsomen and Lux like this

#10 grayman

grayman

    Master Builder, Coder

  • Active Developer
  • PipPipPipPipPip
  • 11921 posts

Posted 08 March 2014 - 03:48 PM

Looks nice!

#11 Lux

Lux

    Advanced Member

  • Member
  • PipPipPip
  • 1575 posts

Posted 10 March 2014 - 09:03 AM

Wow, this is really cool use of caulk tubes. Where'd you get that idea? :P

Just kidding of course! Its cool that the caulk tube trick can be used to do something useful and imaginative.

Really interesting use here. This will help outdoor immersion a great deal.

Does this work without the visportals in the tube ends or did you add those to fix the flicker?

Also, visportals close when you have your back to them so if you turn away from the tube visportal in the ceiling, does the moon light effect stop?

Edited by Lux, 10 March 2014 - 09:50 AM.


#12 SteveL

SteveL

    Hero Coder

  • Active Developer
  • PipPipPipPip
  • 3669 posts

Posted 10 March 2014 - 10:39 AM

Thanks. The VPs don't need to be open so that's fine. They do need to be there or your entire exterior would be one big visleaf. Did you try the map? I'm anxious to know whether it works for everyone and not just me!

#13 grayman

grayman

    Master Builder, Coder

  • Active Developer
  • PipPipPipPipPip
  • 11921 posts

Posted 10 March 2014 - 10:43 AM

I wandered around in it for a while and everything worked fine.

#14 SteveL

SteveL

    Hero Coder

  • Active Developer
  • PipPipPipPip
  • 3669 posts

Posted 10 March 2014 - 10:48 AM

Thanks for the confirmation grayman.

@Lux: have you found something cool to do with caulk tubes too? I'm interested in any other tricks. This one I stumbled on independently, you'll see my thought process gradually taking shape in the first thread I linked :-)

#15 Lux

Lux

    Advanced Member

  • Member
  • PipPipPip
  • 1575 posts

Posted 10 March 2014 - 11:06 AM

Post #4518 and #4525 to which you replied. http://forums.thedar.../page__st__4500

It seems like you got the initial idea from this conversation.

Edited by Lux, 10 March 2014 - 11:20 AM.


#16 SteveL

SteveL

    Hero Coder

  • Active Developer
  • PipPipPipPip
  • 3669 posts

Posted 10 March 2014 - 11:22 AM

Aha! Yes of course I remember that now. You must have planted a seed in my mind.

#17 Lux

Lux

    Advanced Member

  • Member
  • PipPipPip
  • 1575 posts

Posted 10 March 2014 - 11:32 AM

\o/ I (may) have contributed something to TDM finally! Cool and thanks, SteveL.

The whole reason I did that was because I wasn't aware of how to make the mini scale city background or skybox stuff so it was just a workaround for my ignorance.

I haven't had time to run it yet as I'm at work but I'm going to check it out when I get home this evening and I'll let you know.

Edited by Lux, 10 March 2014 - 11:41 AM.

  • SteveL likes this

#18 Lux

Lux

    Advanced Member

  • Member
  • PipPipPip
  • 1575 posts

Posted 10 March 2014 - 04:25 PM

Really neat. I didn't notice any issues at all and walked around thoroughly. After taking a look at the map in DR its crazy how that works though I guess I've never really seen moon light like this before in TDM because of the previous issues.

In that back forest area with the hallway that had the square cutouts in the ceiling... the moon light came through and made a parallelogram on the wall because of the angle which was very cool... I started thinking... now make the moon light move with a script and timer and move the light across the wall and we have Raiders of the Lost Ark! Hehe.

Really great effect and opens a lot of possibilities.

I initially took the files out and put them in my test directory and tried running it that way but there were black patch textures and no skybox so I tried dmapping and got 3 leaks so I wasn't sure what was going on. Probably the directory it was being dmapped from I guess, because the .pk4 worked fine installing and running from the menu.
  • SteveL likes this

#19 nbohr1more

nbohr1more

    Darkmod PR, Wordsmith

  • Development Role
  • PipPipPipPipPip
  • 8043 posts

Posted 10 March 2014 - 04:51 PM

In that back forest area with the hallway that had the square cutouts in the ceiling... the moon light came through and made a parallelogram on the wall because of the angle which was very cool... I started thinking... now make the moon light move with a script and timer and move the light across the wall and we have Raiders of the Lost Ark! Hehe.


FYI. The most optimized way to move the apparent projection for a light is to move it's "light_center" value rather than moving the light itself.

GoliathVT over at Doom3world made a dynamic daylight script that did just that along with changing color to match sunset etc.
  • Lux likes this
Please visit TDM's IndieDB site and help promote the mod:

http://www.indiedb.c...ds/the-dark-mod

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

#20 STiFU

STiFU

    Uber member

  • Development Role
  • PipPipPipPip
  • 3122 posts

Posted 11 March 2014 - 03:49 AM

Youtubify please!! :)

#21 SteveL

SteveL

    Hero Coder

  • Active Developer
  • PipPipPipPip
  • 3669 posts

Posted 11 March 2014 - 04:54 AM

Youtubify please!! :)

Why didn't I think of that? :-) Probably because I've never done it. Can anyone recommend a piece of software that makes it easy?

I'd better add a few of those missing walls.

#22 STiFU

STiFU

    Uber member

  • Development Role
  • PipPipPipPip
  • 3122 posts

Posted 11 March 2014 - 05:16 AM

I have a tool packaged with my MSI graphics card. I don't remember the name of it right now. Then there's the well known program Fraps, but I don't think it's free anymore.

Google results in this, maybe it helps?


#23 RJFerret

RJFerret

    Advanced Member

  • Member
  • PipPipPip
  • 1066 posts

Posted 11 March 2014 - 07:27 AM

CamStudio http://camstudio.org
"The measure of a man's character is what he would do if he knew he never would be found out."
- Baron Thomas Babington Macauley

#24 VanishedOne

VanishedOne

    Advanced Member

  • Member
  • PipPipPip
  • 735 posts

Posted 19 December 2015 - 06:16 PM

According to the episode of QI XL that just aired, when the moon goes behind clouds your environment gets brighter, even in the countryside, because the clouds reflect light from below. :blink:


Some things I'm repeatedly thinking about...

- louder scream when you're dying


#25 Bikerdude

Bikerdude

    Mod hero

  • Member
  • PipPipPipPipPip
  • 18736 posts

Posted 20 December 2015 - 02:10 PM

Or GeforceExperience of you have a nvidia based card.





Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users