Dynamic Sky
Team Members: Everett and Philip
Location: Riven
Challenge: Creating a realistic sky which can change with the time of day and weather
At the time of writing this dev blog post, the project of creating a dynamic sky has been ongoing for more than ten months. We’re proud to say that now the sky is reaching its completion.
The project started with our group’s dissatisfaction with our older skies. They all had big problems which couldn’t be overlooked. For example, our oldest sky was a basic, static skybox. At that point in time, we weren’t even considering having dynamic time or weather, so it served its purpose reasonably well. Eventually though, we grew more ambitious and wanted to bring a full day/night cycle with realistic weather changes to Riven. We brought in a third-party sky shader called UniSky for last year’s Mysterium demo, but we weren’t satisfied with certain limitations it had. For example, the sky tended to use flat colors for the clouds, all the way across the sky. There was no backlighting or shading from the sun or moon. It just didn’t meet our standards.
So we went to work designing a new way for a sky system to operate. The original idea we had was for a static skybox to use multiple textures (cloud alpha, cloud normals, cloud edges, etc.) to change its lighting and composition with the time of day. It was then realized that simply by animating this static system with pre-rendered dynamic clouds, we could have a skybox that looked natural, was lit realistically, and could have clouds that moved as the player worked in the game.
The first iteration of this idea was flawed. Our static system was based on a set of pre-rendered image textures, being brought separately into the shader. We naively extended this same system to animated clouds, without realizing that having 400 to 800 frames each for 8 texture sets would eat up a lot of storage space and system memory.
Eventually, after several revisions of this flawed system, we agreed that the texture sets needed to be overhauled to save space and be more efficient for the shader to compute. The system we decided on was to have one basic animated texture. This texture would be a grayscale animation of soft cloud formations, which could then be modified in real time to produce sharper cloud textures that could also morph on cue to cover more or less of the sky, making the transition from a clear blue sky to a gray overcast sky much smoother than in previous iterations.
The whole sky architecture was also designed so that it could be controlled using very few final variables. At this stage, there are three main properties that control the sky: time of day, cloud speed, and cloudiness. That isn’t to mention the complexities that depend on time, however, such as determining the correct position of the sun and moon as well as the proper colors of different parts of the sky. Weather effects like rain have not yet been integrated, so there will likely be a fourth variable (not in the sky shader itself, but in the related systems) for raininess, to transition from a light shower to a thunderstorm. We’ll likely end up limiting any extreme weather to be quite rare and quick, so as not to interfere with puzzle solving too much.
The lighting for the sky is all texture-based at this time. Most of the sun and moon’s influence on the sky is driven by simple black-to-white gradients, modified by the cloudiness of the sky and the appropriate color of the the sky, and these gradients move with the location of the sun. The cloud layer’s transparency blocks the sunlight, naturally, as well as part of the sun’s glow. When overcast, this creates a natural brightness in the sun’s half of the sky, while maintaining the flat haziness that defines a cloudy sky.
The moon is animated as well, with 27 frames of animation representing each daily phase. The phases fade between each other to produce a cohesive lunar cycle. Moonlight, though it hasn’t yet been made dynamic, will be directly affected by the phase of the moon. A full moon will illuminate the night scenes greatly, but a new moon will leave the scenes very dark. We’ve planned ahead though, and have added night-time activated lights in certain areas to make it easy to navigate Riven and solve the puzzles even in the extreme dark.
The last major change made to the sky, made during its second build in Unity, was the addition of a backlighting effect, which harshly darkens the centers of clouds which are blocking the sun, and softly darkens the centers of cloud all across the sky.
One of the problems we ran into, writing the software behind the sky, was that we often ran out of registers (or memory slots). None of us had ever written a shader of this size before, so we were not aware of the way in which writing a shader is so different from writing most programs. The main difference is that the entire program (and all its memory) is confined to the space available in the GPU (Graphics Processing Unit, a chip on the computer specifically for doing graphics operations).
So, we had to write the shader to be unusually lightweight and efficient with the memory it used. That meant storing variables for as short a time as possible, finding the least memory-consumptive way to do certain color-mixing operations, and finding new ways to cram data into otherwise unused channels of our textures. It was more than a few times that we were informed that we had “run out of constant registers” or had “exceeded the maximum number of instruction units” and had to rework everything from a blank slate. The final sky shader ended up being 557 standard lines of code.
The final version of the sky is flexible, determining cloud size and sky colors all in real time. It could be adapted for use in Tay and The 233rd Age, for example, and changed to match those Ages’ color schemes. The sky is the product of much of the last year’s development, and we think that it’s a robust addition to Starry Expanse.
August 3rd, 2012 at 8:22 pm
This is amazing. Any real-time look of Riven could be smashed completely with the glimpse of a static sky, so I am grateful you put so much effort into it. This sky puts any Uru sky to shame.
August 4th, 2012 at 5:58 am
Looks awesome! Well spent work, I hope you had a lot of fun doing it. Very encouraging to see this dedication, keep it up! I’m particularly impressed with the seamless transition from sunny to overcast.
There is only one detail that irks me, about “softly darkens the centers of clouds all across the skyâ€: For clouds that are a bit away from the sun (but not completely opposite), it shouldn’t darken the /center/, but the side that’s facing away from the sun. When the edge of the cloud away from the sun is white again like this, it makes the cloud look flat and unrealistic, which is a bit of a shame, as it distracts from all the other effects that look very nice. I’ve tried to crudely doctor it in this picture: http://cl.ly/IXL4 – I think you get the idea.
I wonder if it would be hard to integrate such an effect in your shader – scale the darkening a bit outward from the sun? In the other videos before “blue sky test2â€, it actually looks like you had something like that implemented. There I see the edge facing the sun brightened much more than the opposite edge (although maybe that was just based on distance from the sun?), so, assuming that the order is chronological, “blue sky test2†feels like a bit of a step backward.
August 8th, 2012 at 7:43 am
The centers are darkened based on proximity to the sun, and not by the direction/location of the sun with respect to the cloud (at this moment). We’re making some modifications to the sky shader now, and the addition of cloud normals and normal-based lighting from the sun is one improvement I hope to make. Thanks for letting me know!
August 4th, 2012 at 4:36 pm
Looking great! Thanks for sharing — these sorts of updates are not only interesting to read, but also exciting and encouraging for the state of the project. It’s great to see the care you’re all obviously bringing to this project — the original game was a work of art, and it looks like this will be, too. Keep up the amazing work!
August 4th, 2012 at 5:21 pm
I agree with Floydman – some of the most important aspects of RealRiven have to be a great dynamic sky as well as time of day cycles.
Fantastic work on the sky shader!
August 5th, 2012 at 8:34 pm
A question: Will the moon be set to be visible during the daytime when it is full enough and far enough away from the sun?
August 5th, 2012 at 9:06 pm
Yep. We’ll probably post some shots of the moon visible during the daytime soon.
August 8th, 2012 at 3:05 pm
This is awesome! But . . . does Riven have our moon? Is the moon mentioned in any Riven-related canonical stuff? If not, wouldn’t it be cooler to make the night sky a little more exotic? I’d love to see a sky that takes its cue from the “Starry Expanse” itself. Say, tons and tons and tons of stars, more and far brighter than we see on earth (as you might see if Riven’s world were situated closer to the center of a galaxy, perhaps), providing a sort of ethereal glow and luminous backdrop. Or at least a different kind of moon. Something to show that we aren’t in Kansas any more.
Can’t wait for this!
April 24th, 2013 at 11:33 pm
Actually, based on my reading of Myst: The Book of Atrus, Riven’s moon is actually much closer to the planet than on Earth or any stable Age, and that Atrus was not able to quite correct the moon’s position. Based on my estimations, the moon texture should be 1-1/2 to 2 times as large in the sky as compared to the playable demo.
November 25th, 2013 at 4:43 pm
I checked up with the Starry Expanse team via e-mail, and they assured me that the use of a Terran moon is only temporary. As Philip Peterson said:
I agree with you on the moon, by the way… there’s no way we’d release a Riven with a moon that resembles Earth’s. The image used with our dynamic sky was just a placeholder.
There also should be a new dev blog post eventually:
We are hoping to write a new Development Blog post soon (where soon := between 1 month and 9 months).
Anyway, I just thought I’d post an update.
August 13th, 2012 at 8:26 am
WOW!!!
Incredible work guys, and with such dedication you can only suceed and go from strength to strength. What a testament to your skills and abilities, this will be a magnificent product when it is finally released.
You should all be very proud of what you have achieved here – superb…
August 13th, 2012 at 1:43 pm
Hmmm, looks like my comments have vanished again…
August 14th, 2012 at 4:35 pm
John, some comments don’t appear until we’ve approved them, as part of the anti-spam mechanism.
August 15th, 2012 at 8:36 am
Yeh, sorry, just me being impatient as usual…lol
August 18th, 2012 at 12:33 am
Looks fantastic, guys.:) Is there anything you can take from myst V’s clouds? Specifiacally in Nobolen. Some great animated clouds there.
September 9th, 2012 at 12:46 am
I’ve been watching this blog since it launched, and the work you’ve done on the sky is really amazing. I do a lot of modding for the game Skyrim so it’s easy for me to see that this is something unique, and will be beautiful to experience. In your more than capable hands, Riven will breathe with new life!
August 4th, 2013 at 11:29 pm
It’s INSANE that you’re not kickstarting this. Work it out with cyan.
February 15th, 2014 at 4:21 am
Those clouds look awesome, but i heard you recently moved to the UDK engine. Does that mean these will not look the same anymore?
Also another question, why is the dev blog dead? 😀
February 15th, 2014 at 11:11 am
Those are the default UDK clouds. They are pretty good looking on their own, but we are (unfortunately) not at the stage where we can discuss our plans for the sky. That’s one of the only assets that does not easily translate from Unity to UDK, so we’re currently researching our options.
July 30th, 2014 at 10:59 pm
If the clouds can’t be used in UDK, is there any chance you you will be licencing the cloud system out to other Unity devs?
December 23rd, 2016 at 4:10 am
This is epic!
I like nothing more than the mood ans ambience in the Myst games.
I’m the guy that recommended or wished having as much environmental effects as possible. This is the way to go!
Especially rain and thunderstorm!
Id repeat some further thing, to wish-list!:
Distant Thunderstorms! (Only visible to one specific location, far away on the skyline).
Insects/flies (physical present).
Birds (like in Myst the seagulls, at the beginning).
Leaves which fly trough the air (Jungle area).
Variable small animal (frogs?, bugs).
Fish in the water (fish schools).
Small rocks rolling off some cliff?
Really special/rare weather condition?
Like some type of Aura Borealis or unusuall colored “Fog”, teal…
Share your ideas, even if only for imagination 🙂