Lit Alpha Skyboxes
by Adam Armstrong · 05/02/2013 (5:26 pm) · 22 comments
After working on terrain for a bit, I started noticing the edges of it more and more. Having to hide the bottom of the scatter sky with terrain seemed to be a poor way of doing things - terrain is expensive, a limited commodity. It has a lot of things bundled up with it that aren't needed if you just want some distant obscuring thing, such as collision. I decided I wanted a skybox to do this job for me.

I had to add controls to provide a base color and an exposure control, and the color/luminance changes aren't quite perfect with a day/night cycle. I did add a control to the cloud layer to allow it to be either in front of or behind the skybox.
If you feel like trying this out, I've got a suitable skybox here:
www.xoltan.org/files/sky-hills.zip
I've made a github branch of the changes here:
github.com/xoltan/Torque3D/tree/skyboxAlpha
One note - this was added just after a new commit to the development branch that allows fog to fog skies. For these changes to be much use with that enabled and the level fogged, the fog height setting probably needs to be used. I don't know that I'm a fan of that, but I'm sure things will get sorted out.
Oh! One other important note. For a skybox to work as before - no alpha, not lit, it needs to be set as emissive in the material editor. I know that isn't the handiest solution, but I'm posting this in a bit of a rush. If needed, I bet things will be improved.
Thanks, hope you try this and like it!
Edit: fixed a small bug that had cloud layers in front/behind flag initialized incorrectly on level load, and changed the url at github.

I had to add controls to provide a base color and an exposure control, and the color/luminance changes aren't quite perfect with a day/night cycle. I did add a control to the cloud layer to allow it to be either in front of or behind the skybox.
If you feel like trying this out, I've got a suitable skybox here:
www.xoltan.org/files/sky-hills.zip
I've made a github branch of the changes here:
github.com/xoltan/Torque3D/tree/skyboxAlpha
One note - this was added just after a new commit to the development branch that allows fog to fog skies. For these changes to be much use with that enabled and the level fogged, the fog height setting probably needs to be used. I don't know that I'm a fan of that, but I'm sure things will get sorted out.
Oh! One other important note. For a skybox to work as before - no alpha, not lit, it needs to be set as emissive in the material editor. I know that isn't the handiest solution, but I'm posting this in a bit of a rush. If needed, I bet things will be improved.
Thanks, hope you try this and like it!
Edit: fixed a small bug that had cloud layers in front/behind flag initialized incorrectly on level load, and changed the url at github.
About the author
#2
05/02/2013 (7:59 pm)
This seems pretty cool can't wait to try it out.
#3
I realized that the photographer in me made a pretty picture, but one that perhaps wasn't as illustrative as it could be.

Here's one from a hundred meters up or so, looking at the edge of the world. I know I'm using unrealistic values for view distances, texture sizes, and map sizes, but it's fun for now. I have the clouds on top of the skybox in this image.

Same skybox, different color, different position of the sun.
05/02/2013 (8:33 pm)
That is an actual sun. It rises and sets behind the mountains, and the light rays spread from it when it is occluded. That makes sense since the light rays are a post process, and it isn't anything I did to make work. I should be more wary of happy accidents when programming.I realized that the photographer in me made a pretty picture, but one that perhaps wasn't as illustrative as it could be.

Here's one from a hundred meters up or so, looking at the edge of the world. I know I'm using unrealistic values for view distances, texture sizes, and map sizes, but it's fun for now. I have the clouds on top of the skybox in this image.

Same skybox, different color, different position of the sun.
#5
- Dave
05/02/2013 (10:23 pm)
Looks really nice. Would it help if we added a checkbox to LevelInfo that would make the fog go back to not affecting extremely distant objects? I'm now wondering if there are other cases where not fogging the far plane could be useful (such as a star field).- Dave
#6
05/03/2013 (2:08 am)
Awesome!
#7
Many thanks for sharing!
@David; Using the fog for covering up distant billboards and imposters in large levels and adding color matching the background. It also covers aliasing a bit. Fogging the skybox is indeed unwanted in cases like this. Checkbox would be great!
05/03/2013 (5:06 am)
@Adam; That's great, can put back the scattersky now! Many thanks for sharing!
@David; Using the fog for covering up distant billboards and imposters in large levels and adding color matching the background. It also covers aliasing a bit. Fogging the skybox is indeed unwanted in cases like this. Checkbox would be great!
#8
05/03/2013 (7:30 am)
Minor detail is the incorrect display of the same cubemap used in materials (and water?); transparency is not supported. One need to make a non-transparent version for that, I guess.
#9
@Nils: I'm not sure what to do about that right now. Having a non-transparent version would work, but doesn't feel elegant.
05/03/2013 (9:40 am)
@Dave: Thank you, and a checkbox would be great. That would give people a lot of flexibility.@Nils: I'm not sure what to do about that right now. Having a non-transparent version would work, but doesn't feel elegant.
#10
This is awesome. It could help with helping making random content look more realistic. Thanks!
05/03/2013 (11:13 am)
@Adam,This is awesome. It could help with helping making random content look more realistic. Thanks!
#11
05/03/2013 (12:28 pm)
Gorgeous.
#12
05/03/2013 (1:11 pm)
This addition looks like it really helps bring a scene together. Good job Adam!
#13
05/03/2013 (11:38 pm)
@Adam; Perhaps using dds files with alpha channel instead of png for the cubemap can solve the issue with materials and water. Personally I don't mind creating another version; the files for the skybox are always pretty big, maybe too heavy for use in reflections and all. Will do some more testing...
#14
05/04/2013 (12:55 am)
I had very bad results with dds skyboxes, they do not store gradient of colors good, but since you leave out the sky and only use the mountains and do the gradient with scatter sky this may work, but dds tends to leave ugly artifacts.
#15
05/04/2013 (1:23 am)
@Duion; 1 or 8 bpp dds files are indeed not so good for gradients. With the right settings you can reduce some artefacts; the highest compression quality for example.
#16
05/04/2013 (4:03 am)
Hm I don't have that, I just can chose between dxt1, dxt3 and dxt5 and even dxt5 has artifacts.
#17
05/05/2013 (6:27 am)
Fantastic stuff Adam, Ive been lurking alot lately, getting back into things and might pull this down and start doing some terrains again... still have the eck but its going to need a bit of an overhaul
#18
05/05/2013 (2:30 pm)
ECK! You had to mention that, Andy. Been waiting for that one for a long time. =D
#19
05/12/2013 (1:48 pm)
Awesome Really reminds me of the Cry Engine TOD System :)
#20
06/19/2013 (1:22 pm)
Wasn't there some 'z offset hack' to lower the edges of the skybox iirc? 
Torque Owner Daniel Buckmaster
T3D Steering Committee