A new sky system

Yeeh, modular shaders would be really nice. To be able to select lighting from one, fog from another, glow from something else, etc.

I’ve been playing around some with the SkyX lib, and found some good and some bad stuff.



There is a pretty solid system for calculating light colors. It creates gradients by setting a few fixed points (6-7 of them are added by default) and then interpolating between those values. You pass the sun height normalized to [0,1] and it finds the correct values.



There is one gradient for ambient luminocity and one for sun-color. The colors seem to match the skydome colors very well.



I’m not too excited about the skydome clouds. It uses a normal map to displace texture coordinates for volumetric effect. It looks descent but it’s an extremely cumbersome method filled with floats and vec3’s and clamps etc. I think raycasting would be better. Even if it’s not significantly faster (or slower) it would at least be cleaner.

First vid.



http://www.youtube.com/watch?v=gwhorduWO_o

7 Likes

Wow really nice… Brain says ā€œskyā€ :slight_smile:

thats a really awesome result, in such a short space of time!

That sunset is particularly fine. Does it angle a directional light to follow the sun as it goes across the sky?

Sweet!! Can’t wait to combine this with your trees :slight_smile:



How is the performance of this?



Try using the HDR processor, it supposed to have a autoexposure feature :slight_smile:

@normen

@wezrule2

Thank you. This didn’t happen fast tho, it was something I’ve been working on for some time.



@zarch

Yes, there is a directional light for the sun, and it follows the suns movement.



I am adding a moon as well, which will have a directional light too.



There is also an ambient light. The ambient light depends on the sun during daytime, and adds some blueish moon light at night.



Finally there is the scattering effect on the entire scene, which is fog-based.



You’ll be able to check it all out in the lib, it’ll be available as a project too.

Amazing!! :slight_smile:

@kwando

The performance depends mostly on the number of samples in the sky shader scattering. It’s all shader based. I’m using 8 samples in the video but i think 6 or 4 would do. People seem to often use that.



The directional/ambient light stuff is very light. The fog stuff is pretty light, but its performance will also depend on a number of samples. The clouds will be light, even when they are finished.



FPS for me is hard to use as a measure, because i never get very high fps. I think the computer does some power saving crap or something, because it never really gets warm. XD



The problem is that all colors that are generated are HDR adapted (to some degree), which is perfectly fine for the skydome, but all other materials using those lights and the fog aren’t adapted to them. Probably just gonna normalize them using some exposure constant people can set in the sky class (with a good default value). And of course leave an option to use the HDR colors if they want.

Here’s some example of how terrain fails with the HDR filter atm.



http://www.jamtlandoutdoors.se/images/dist/HDR_terrain_fail.png



Here’s the same type of images without the terrain.



http://www.jamtlandoutdoors.se/images/dist/HDR_win.png



http://www.jamtlandoutdoors.se/images/dist/HDR_win2.png

I think the terrain needs to be self shadowing to get shadows out behind the mountains etc during the sunset - that’s part of the reason it’s looking flat.

@androlo

Thanks a lot for your reply! I’m interrested since I made a atmospheric scattering shader some months ago… but it was to slow and hard to tweak in order to look good. Yours look good and seems to have decent performance!



Is it for aerial perspective only? Or can one travel through it to the outer space/over the clouds?



Don’t worry about measuring FPS it’s better too measure milliseconds instead, that way you do not depend on all other things in the scene while measuring…



BTW. enable shadowing on the terrain in order to improve the realism further :wink:



Anyways, I appreciate all your good work!

@kwando

I haven’t looked too much at space, but in the gpu gems article there’s one shader for sky from atmosphere and one for sky from space.



I’m putting in the full ground scattering stuff in the terrain now to try it out. Gonna try putting it in the forester impostors also. They are only four verts each so it wouldn’t be all too heavy. I wonder if impostor distance can be close enough to the camera so no scattering is needed on the geometry, tho I don’t think this so.

Looks sweet, as always totally impressed by your work.



I love, that you put in a moon also. What about stars in the night sky, is that planned?

@staugaard

Sure. Basically it will have sun, moon stars etc. all the regular stuff. Some parts may be more basic then others. At least initially.



I’m kind of looking forward to starting with the night stuff, because it is a bit weird. Getting good looking night scenes is not easy. Gonna experience some with the fog to try and spread out darkness more accurately etc. I’ve read some articles about it also.



It’ll just be moon lit nights at first tho, using the directional and ambient lights.

Sounds good.



I was talking about your sky system with my partner in crime which whom im developing Forging Life with. And we talked about using you sky system, instead of making one ourselves. Will we be able to use JUST the coulds, or is it ā€œuse allā€ or leave it?



And btw, will there be parameters regarding the cloud system? Im talking: cloud size, ā€œnumber of cloudsā€, wind and direction, color AND a transition period from where the clouds are at stage X to stage Y… ex: fine weather to dark stormym rainy weather clouds. So that it dosnt happen instant.



:slight_smile:

@staugaard

The clouds are part of the skydome shader. I guess you could break it out by copying and pasting.





Btw all I have now gotten the cloud lighting process started. I’ve settled for a shader based ray tracing routine. Not sure how complex I’ll make it, but I’ll start out calculating light attenuation due to scattering, and simple reflection.



EDIT: The sky pixel shader is very light, because most of the calculations take place in the vertex shader, so there is freedom to add stuff.

Been thinking some, and I’m gonna move the clouds out of the sky shader. I did an algorithm for attenuating light based on sun direction and cloud depth etc. (by ray tracing), but it takes a lot of iterations to get good looking clouds.



Ray-traced clouds will be put in, but as separate objects. The SkyX lib does this, and it looks very nice, so I asked myself why am I messing around with this ā€œpseudo volumetricā€ garbage. No point in trying to squeeze this into the skydome shader when I got all that nice SkyX code right in front of me…



I’ll leave some clouds in during first release, just as placeholders. They have a small volumetric effect and some other stuff. Gonna get started on moon/stars now, so I can release it.



The fog works pretty much as intended now. The colors work well throughout the entire day/night cycle. It needs a small tweak or two, but generally it works.



The night fog is very nice looking. It makes stuff gradually darker. Gonna keep exploring that.



New vid soon.

The moon lighting part is working now. Since moonPos = -sunPos in the simple poisition system it’s possible to use only one directional light at a time. The ambient lighting compensates during the transition. The moon luminance depends on its phase and position.



Have to fix the actual moon quad now, then it’s on to stars.

1 Like