Fixing ScatterSky
by Daniel Buckmaster · in Torque 3D Professional · 11/27/2014 (9:35 pm) · 10 replies
For a while now, people have been asking to add the ScatterSky z-offset hack into the engine to fix their ScatterSky issues. It's never been added. I can't speak for previous committees but for myself I know I don't want to add a hack into the engine. I'd prefer a proper solution.

This illustrates the problem: ScatterSky is just an umbrella, and if you fly high enough, you can see its edges. This is bad. The z-offset hack simply changes the height the sky is rendered at, if I understand it correctly, dropping it down so the edges sit beneath your horizon again. The change touches this line:
Interestingly, there are also constants for the earth's radius and atmosphere thickness, as well as the viewer height, which is a fixed constant 1m. It's used to pass additional parameters into the shader:
What I'd feel best about is having the ScatterSky capable of rendering a full sphere. This would not only fix this issue, but also be useful for people making games without a terrain (think of floating Marble Blast levels, for example). Of course, there should be an option to not render the full dome if you don't want to (performance?).
If that's not feasible, I think we should review the use of the constant 1m height, and the use of camPos2. The z-offset hack touches that line of code, so let's see if we can fix it without making a 'hack'.
If worst comes to worst and no other solutions eventuate, let's add the hack into the main repo, and there will be much weeping and gnashing of teeth, mostly by me.
EDIT: Screenshots (and more) thanks to Azaezel.

You can clearly see the mesh which is generated, and only covers a small portion of a sphere. It looks like it's just a warped grid, too, though it might make a UVsphere if it were extended all the way around. It appears this geometry is constructed here-ish, though that's different to what's generated in mSkyPoints, purpose unclear.

This illustrates the problem: ScatterSky is just an umbrella, and if you fly high enough, you can see its edges. This is bad. The z-offset hack simply changes the height the sky is rendered at, if I understand it correctly, dropping it down so the edges sit beneath your horizon again. The change touches this line:
Point3F camPos2 = state->getCameraPosition(); MatrixF xfm(true); xfm.setPosition(camPos2);//-Point3F( 0, 0, 200000.0f));
Interestingly, there are also constants for the earth's radius and atmosphere thickness, as well as the viewer height, which is a fixed constant 1m. It's used to pass additional parameters into the shader:
Point3F camPos( 0, 0, smViewerHeight ); Point4F miscParams( camPos.z, camPos.z * camPos.z, mScale, mScale / mRayleighScaleDepth ); ... mShaderConsts->setSafe( mMiscSC, miscParams ); mShaderConsts->setSafe( mCamPosSC, camPos );
What I'd feel best about is having the ScatterSky capable of rendering a full sphere. This would not only fix this issue, but also be useful for people making games without a terrain (think of floating Marble Blast levels, for example). Of course, there should be an option to not render the full dome if you don't want to (performance?).
If that's not feasible, I think we should review the use of the constant 1m height, and the use of camPos2. The z-offset hack touches that line of code, so let's see if we can fix it without making a 'hack'.
If worst comes to worst and no other solutions eventuate, let's add the hack into the main repo, and there will be much weeping and gnashing of teeth, mostly by me.
EDIT: Screenshots (and more) thanks to Azaezel.

You can clearly see the mesh which is generated, and only covers a small portion of a sphere. It looks like it's just a warped grid, too, though it might make a UVsphere if it were extended all the way around. It appears this geometry is constructed here-ish, though that's different to what's generated in mSkyPoints, purpose unclear.
About the author
Studying mechatronic engineering and computer science at the University of Sydney. Game development is probably my most time-consuming hobby!
#2
Edit: nvm realized the issue it would pose when having a sun thats getting cut off.
11/28/2014 (3:57 am)
What about just adding a fill color to the sky where the scattersky doesn't render? So instead of black you get whatever the scattersky is fading out to.Edit: nvm realized the issue it would pose when having a sun thats getting cut off.
#3
11/28/2014 (4:27 am)
That would be an improvement, especially for users with a static sun.
#4
but this is something new to look forward to so i guess its good enough
11/28/2014 (4:47 am)
i have tested that there's just a slight improvement when transitioning from basic sun to scattersky but correct me if there's more proof. so having a dynamic sun like the scattersky should not be built or default into the engine, but just a mod. unless you got a strong tech like cryengine that can handle this feature with elegance of day/night cycle. if "scattersky" is more like of improving lighting like GI and other stuff then its a keeper!but this is something new to look forward to so i guess its good enough
#5
11/28/2014 (4:54 am)
GamerX: I don't quite understand what you are saying.. Whats wrong with the day/night cycle in the Scattersky? Are you suggesting we rip out Scattersky?
#6
11/28/2014 (4:56 am)
A good way to deal with this is the water plane, or ground plane, it will expand infinite and always cover the ugly area.
#7
if you look at UDK and Unity, its not built-in and can be easily done with mods and scripting, the day/night in particular. i just don't see any major improvements between the two. so my suggestion is merge the two and have some settings to tweak.
when i got started in setup with basic sun, then i thought of testing my settings to scattersky. soooo i have to replicate my settings when testing back and forth which works best with my lighting setup.. it kinda sucks.
thats just me.
11/28/2014 (5:13 am)
Lukas, im just saying its just redundant to have two sun environment. why not just have one sun system and apply performance settings to it?if you look at UDK and Unity, its not built-in and can be easily done with mods and scripting, the day/night in particular. i just don't see any major improvements between the two. so my suggestion is merge the two and have some settings to tweak.
when i got started in setup with basic sun, then i thought of testing my settings to scattersky. soooo i have to replicate my settings when testing back and forth which works best with my lighting setup.. it kinda sucks.
thats just me.
#8
I don't think they can be merged in any meaningful way, the Scattersky is a physically correct procedurally rendered sky. While the basic sun is not a sky in anyway, it's just a vector light with a flare on the sky, meant to be used with a skybox.
You can't have the same settings for the two because it doesn't make any sense. One needs atmospheric information, the other just need a size and a strength.
11/28/2014 (5:29 am)
Well Scattersky doesn't work in basic lighting afaik. So thats why we have the basic sun as well. I like the current split because it makes it easier to differentiate between the two, after all they are two completely different systems with completely different uses.I don't think they can be merged in any meaningful way, the Scattersky is a physically correct procedurally rendered sky. While the basic sun is not a sky in anyway, it's just a vector light with a flare on the sky, meant to be used with a skybox.
You can't have the same settings for the two because it doesn't make any sense. One needs atmospheric information, the other just need a size and a strength.
#9
11/28/2014 (5:34 am)
Exactly as Lukas points out above, the two can't be merged as they are two completely different systems. Personally i think it's a great feature of T3D as it allows more flexibility.
#10
11/28/2014 (8:50 pm)
Why not have the skydome be half a sphere and then skyboxes can be a single image projected onto the dome like in the borealis demo, and if they want two halves, then they can use a second image for the bottom half.
Timmy01
If the problem can't be solved properly than the sphere idea sounds fine :-)