View Single Post
Old 10-29-10, 11:04 PM   #22
THE_MASK
Ace of the deep .
 
THE_MASK's Avatar
 
Join Date: Jan 2006
Posts: 9,226
Downloads: 901
Uploads: 73


Default

Quote:
Originally Posted by Seeadler View Post
it's all in the sky shaders (\Silent Hunter 5\data\Shaders\Sky)
and EnvColors_xxx.cfg's (\Silent Hunter 5\data\Env\)

Code:
// 1. base gradient, from top to bottom    
float heightRatio = pow(In.eyeDir.w / 992.0, g_skyBottomColor.w);    
color  = lerp(g_skyBottomColor.rgb, g_skyTopColor.rgb, heightRatio);
Values for g_skyBottomColor and g_skyTopColor are set in EnvColors_xxx.cfg

Now in the above pixel shader code for each pixel the virtual camera eye is directed on, the color value will be calculated with a linear interpolation (x*(1-s) + y*s) between top- and bottom-color. This is done by the HLSL lerp() function.
You can now implement a different algorithm for example with smoothstep() functions which calculate a smoother intepolation based on the Hermite Interpolation instead of linear interpolation but this can cause lower framerates if alot of smoothstep's are used.
Using a gradient causes the sky banding . I just deleted the bit in green and it seems much better .

Last edited by THE_MASK; 10-30-10 at 12:02 AM.
THE_MASK is offline   Reply With Quote