TGE Sky Tweaks
by Chris Haigler · 09/27/2010 (5:55 pm) · 4 comments
Due to the number of changes I've posted the modified versions of sky.cc and sky.h here:
URL Removed - Outdated Code
While working on a side project I couldn't quite get the sky to look like I wanted and noticed a few problems:
* The cloud layers were 'shearing' off into the far clipping plane. Changing visible distance and fog distance did nothing to solve this.
* The cloudHeightPer field seemed to only adjust the height of the cloud layers by their middle points causing them to 'warp' horribly at the horizon/cloud edges.
* There was no way of changing the scale of the cloud textures from within the editor.
This resource represents my effort to solve those issues. After applying the changes you'll be able to change the shape, size and height of the cloud layers, adjust depth and detail of the fog 'render bans' and tweak the far clipping plane.
This resource also includes some miscellaneous cleanups I made along the way. Namely, the removal of the unused cloudText field, unecessary #defines, and console spam when stormfog is active.
Important Notes:
* The old cloudHeightPer field has been replaced by something called cloudHeightL. Instead of a single value like cloudHeightPer, cloudHeightL accepts 3 floats. The first float changes the cloud layer's center point height. Increasing or decreasing this value has the same effect as changing the old cloudHeightPer field (i.e. you'll only 'pull' the clouds by their centers). The second float changes the cloud layer's inner point height. Increasing or decreasing this value will adjust the inner shape of the cloud layers. The third float changes the cloud layer's edge height. Increasing or decreasing this value will adjust the height of the outer edges of the cloud layers.
* The new horizonTweak field is actually a scalar that adjusts the visible distance of the cloud layers relative to the far clipping plane. The standard/default Sky class had this hardcoded to 0.95 which causes the cloud layers to stop rendering just before the far clipping plane. For me this caused the clouds to 'shear' off at certain view angles. I found setting horizonTweak to 0.71 resolve that issue at the default FoV.
* The new renderBanHorizon field sets the beginning height of the fog bans. Previously this was hardcoded to 0.0 and can probably be left alone in most cases.
* The new renderBanHorizonOffset field sets the depth of the fog bans (or how 'high' the fog bans go). Previously this was hardcoded to 60.0.
* The new renderBanDetail field adjusts the shape of the fog bans. Previously this was hardcoded to 8 and can probably be left alone in most cases. The value is clamped between (2, 9). Going above a detail level of 9 causes the game to crash (and I didn't spend any time investigating why - I'll leave that to someone else!).
* There's more work to be done in cleaning up the code. The Sky class has an unfortunate dependency on the particle engine that could be removed, there are a few structs that define cloud-related stuff that could be moved into the Cloud class, etc. Definitely room for improvement!
URL Removed - Outdated Code
While working on a side project I couldn't quite get the sky to look like I wanted and noticed a few problems:
* The cloud layers were 'shearing' off into the far clipping plane. Changing visible distance and fog distance did nothing to solve this.
* The cloudHeightPer field seemed to only adjust the height of the cloud layers by their middle points causing them to 'warp' horribly at the horizon/cloud edges.
* There was no way of changing the scale of the cloud textures from within the editor.
This resource represents my effort to solve those issues. After applying the changes you'll be able to change the shape, size and height of the cloud layers, adjust depth and detail of the fog 'render bans' and tweak the far clipping plane.
This resource also includes some miscellaneous cleanups I made along the way. Namely, the removal of the unused cloudText field, unecessary #defines, and console spam when stormfog is active.
Important Notes:
* The old cloudHeightPer field has been replaced by something called cloudHeightL. Instead of a single value like cloudHeightPer, cloudHeightL accepts 3 floats. The first float changes the cloud layer's center point height. Increasing or decreasing this value has the same effect as changing the old cloudHeightPer field (i.e. you'll only 'pull' the clouds by their centers). The second float changes the cloud layer's inner point height. Increasing or decreasing this value will adjust the inner shape of the cloud layers. The third float changes the cloud layer's edge height. Increasing or decreasing this value will adjust the height of the outer edges of the cloud layers.
* The new horizonTweak field is actually a scalar that adjusts the visible distance of the cloud layers relative to the far clipping plane. The standard/default Sky class had this hardcoded to 0.95 which causes the cloud layers to stop rendering just before the far clipping plane. For me this caused the clouds to 'shear' off at certain view angles. I found setting horizonTweak to 0.71 resolve that issue at the default FoV.
* The new renderBanHorizon field sets the beginning height of the fog bans. Previously this was hardcoded to 0.0 and can probably be left alone in most cases.
* The new renderBanHorizonOffset field sets the depth of the fog bans (or how 'high' the fog bans go). Previously this was hardcoded to 60.0.
* The new renderBanDetail field adjusts the shape of the fog bans. Previously this was hardcoded to 8 and can probably be left alone in most cases. The value is clamped between (2, 9). Going above a detail level of 9 causes the game to crash (and I didn't spend any time investigating why - I'll leave that to someone else!).
* There's more work to be done in cleaning up the code. The Sky class has an unfortunate dependency on the particle engine that could be removed, there are a few structs that define cloud-related stuff that could be moved into the Cloud class, etc. Definitely room for improvement!
About the author
#3
Thanks for all of your contributions... I've implemented all of them, but would be interested to see your before/after datablocks for the 'starter.racing' screenshot, as I'm still not sure how to implement your changes in TorqueScripts...
12/10/2010 (1:39 am)
Chris:Thanks for all of your contributions... I've implemented all of them, but would be interested to see your before/after datablocks for the 'starter.racing' screenshot, as I'm still not sure how to implement your changes in TorqueScripts...
#4
Glad you're getting some use out of my quick hacks. :)
Regarding the new sky fields, all of these should be editable in the editor (under the Sky object, obviously :)).
If you're really keen on editing the fields outside of the editor, it should be a simple case of adding them to the Sky object declaration inside your .mis file.
12/17/2010 (6:59 am)
Gibby:Glad you're getting some use out of my quick hacks. :)
Regarding the new sky fields, all of these should be editable in the editor (under the Sky object, obviously :)).
If you're really keen on editing the fields outside of the editor, it should be a simple case of adding them to the Sky object declaration inside your .mis file.

Torque Owner CSMP
MP Studios