[BP] Geographically Correct Sun System

Hey guys,
[Edit] - new version of the product is up on Gumroad with improvements and real time UMG controller of key parameters.

New video:
Link to download: UE4 Geographically Correct Sun System

**Old post: **

I’m an architect and I was very surprised when I’ve learned that UE4 doesn’t have a proper sun system, like 3ds max or just about any 3d package I guess. That’s why I’ve built one. I’m currently considering adding some things to it or around it and I’d welcome your suggestions. I’m thinking that this could do well in the marketplace but I’m afraid that currently it doesn’t meet their “volume” criteria, even though I wouldn’t consider pricing this anything steep.
So let me know what you think. You can find it here:

And here you can see it in action:

This is amazing, thank you!

You’re welcome!

Just watching your video…do you have a true night time in this system? I’m guessing you’d need to disable the sun during the night hours since game worlds aren’t the physical size of Earth and the sun isn’t that far away from the landscapes, otherwise you’d have secondary lighting coming from beneath your landscape.

It was hard to tell from the video how you handle when the sun is not in the sky (and the moon should be - do you have a moon?).

The sun doesn’t turn off when it’s night time and there’s no moon yet. You can download the BP to check it out if you want. I’ve did several experiments but the reason I don’t have a moon in the released version is because I found no easy way of making it fall behind the clouds while also be lit by the sun. I like not turning the sun off since it casts lighting on the moon (when I was testing with it) generating accurate moon phases. Turning the sun off as it crosses a certain elevation isn’t a big deal and concerning under-lighting, it would only happen on the extents of the scene and only if you place something vertical right there, so I’m not concerned with this. A better fix would be extending the edges of the world just slightly.
Regarding the moon, my attempt was to make it as geometry, and use similar equations as the sun’s to drive it. To get it behind the clouds I figured I need to track it’s position on the sky material (just the way the sun is tracked and drawn currently) and mask the sky and not the clouds while keeping the geometry of the moon just slightly further away than the sky sphere. If anybody has a better solution to this I’m looking forward to hearing it. In so far I wasn’t able to do what I’ve just described because I haven’t spent enough time with the sky material and I’m also considering the necessity of rebuilding it considering that it’s strongly linked with the sun system and currently is a very cluttered affair.
And just as the day is a true day, the night is a true night, basically the sun has the azimuth and elevation that an architectural visualization software (3ds max, revit, etc.) would tell you it should have at a particular time and in a particular location. This means the length of the day, and subsequently, night is accurate. Otherwise the sky’s colors during the phasing in and out of day are the default ones, and it’s debatable to which extent they are “true”. Maybe, in the winter, the atmosphere is a bit different or maybe a haze parameters ought to be inputted but this is a different story.
Thanks for the input and, again, let me know if you have any suggestions for implementing a moon behind clouds.

Kleiner Baer, has a tutorial series that is the same is this. here is the link to the tutorial series

I know those tutorials, they were part of the inspiration for this, but they’re definitely not the same. Kleiner Baer uses approximations of the sun’s movement which is rather strange since he ends up with quite a heavy set of nodes. This is why he has, apparently, so many exceptions, around the poles/equator, etc. The formulas I use which you get if you download the archive, work irrespective of particular locations on the globe. He also acknowledges no way of getting the moon behind the clouds in so far and I’ve commented on one of his videos. Feel free to download my version and cross check it with what you see on Little Bear’s tutorials.

I just tested your BP and it looks fine to me. Good work! I wrongly asumed that using simple approximations would make it easier. So it’s funny to see that by using exact calculations you end up with a much more streamlined blueprint.
I am flattered that you took some inspiration from my version of a Day/Night cycle. However the core of your version which is the calculation of the sun’s pitch and yaw is completely different than mine. Also I’d like to mention that cgiteach even tried to contact me before he even started this thread which I think is very kind. I just didn’t reply because I’m a little shy :wink:
Regarding your WIP: I know you like my idea of creating the moon phases with the sun directional light as in reality but I myself don’t think it’s a good idea anymore. I suggest turning the sun off at night. There should be ways to create moon phases that will not cause as much trouble as a directonal light shinning through from below and that will use up less system power. I like the idea of projecting a moon texture into the skysphere (I don’t know how as “SkysphereImage” doesn’t work for me). Moon phases could then be created using a texture atlas (I have never done that before).
Also I had a minor bug. The sun would freeze close to the end of the day (before midnight) and then jump to the starting position of the next day. Maybe I did something wrong.

I would also recommend making the moon a mesh that emits its own light and has its own light attached and operates similar to the sun. It’s the most cost efficient way to achieve great looking results.

The PDF covers that glitch at the end of the day. It happens for some positions on earth (latitude/longitude). I think that in the end I’ll remake the sky system entirely so as to have more control over it. Thanks for all the feedback guys.

How would you go about setting up a print string to display time of day/date/year etc on screen? Could you use a similar approach to Keiner Baer in his tutorial?

When I was testing this I placed a print string component inside the event graph, because I couldn’t get it to print inside the editor(so in the construction script). Check this image I’ve put up for reference. Obviously this is done inside the blueprint controlling the animation.

Hello Guys,

Cgiteach, Thanks for jumping in on the other forum, this is exactly what I was thinking of! Using the color curves is a great way to control the color shifts for the different parts of the sky!

I merged it into my own project and did not use the provided map, so I’m not sure that it functioned as intended, but the sky light was not recapturing with animated time of day or in the editor. I am a beginner, so I was poking around with it and I was able to integrate the skylight with the script and get it updating both in the editor and in game, very handy! In my customized version, I added categories to the interface to streamline it further and provide extra information (one category was called: “Select actors to control”). I tried to organised it so that the most used options would show at the top in each category. Ill do some research into streamlining further for our own use, but if you are interested I can share my modifications.

I think we could get text display working in the editor same as the game view with a “txt actor”…? I would like to have some interface in game so the user could set the time of day and speed of the animation. When they drag the slider it goes to the time of day interactively and when they release it will animate the day/night cycle from that point based on the speed (or not if speed is zero). Ideally, this would be built in UMG though, so we would not get display in the editor, but it would allow more flexibility in game. We could have the interface off screen and have it slide in when summoned (maybe a swipe in from the right edge for touch interface and a key press for PC?)

Well, I’m full of ideas here. lets see if any of these resonate with you guys and we can chat more if they do.

Ryan Dashkevicz

Hi, I just bought your amazing control. I opened the and did a copy/paste on the blueprints into my map. I can edit the controllers just fine, but nothing seems to change in the map. What do I need to do? Never mind my question, what I did was imported the assets into the instead :slight_smile: Thanks for the great effort in this system!

Hey, I wanted to do that! I’ll probably just use yours as a base and add more features. I want to add a geographically based night star map as well, and maybe the moon. You could also intergrate tides or add lighting changes for dawn/dusk or sunrise/sunset.

For the moon, I’d probably create it’s own personal light that’s hidden and only affects it.

Glad you guys like it. ZacD, you can enhance on it as much as you like. I’m currently wrapped up with another project and I’ll make a comeback to this in a couple of months. If you’ve done something with my system feel free to post it here or let me know one way or another (anybody who got this should have my email).

Hey cgiteach, thanks for sharing this :slight_smile:

I think I found a little bug, if you use any UTC time other than zero then the sun will freeze for a couple of seconds (it’s probably noticeable only when the speed is set high :p).

I think the sun should be turned off as it goes below the horizon. I have noticed the when I have actors the intersect my landscape mesh, as the sun goes under my landscape, the objects that intersect the mesh create light leaks.

Has any progress been made on your sun system? Does it work with 4.8.2?

Thanks for sharing.

I have added a moonlight and use for the moon this:


How can I apply the mond phase ( sunlight dot moonlight ) to the skyboximage ?

A fast and easy way would be to map the location and opacity of the moon relative to that of the sun, that is when the sun is bellow the horizon you make the moon appear and then rotate it relative to the position of the sun (easiest would be to invert the spherical position of the sun so the two are opposite)

I’ve recently downloaded my own blueprint at work and it took a while to get it working on a 4.9 project. I’ll update it very soon and link everyone who downloaded/paid for it.