View Single Post
Old 03-24-10, 11:37 AM   #21
Coldcall
Chief
 
Join Date: Mar 2010
Posts: 325
Downloads: 42
Uploads: 0
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.
Thank you veyr much, though its all a bit ove rmy head. I'll wait for someone smart like you to do a mod :-)
Coldcall is offline   Reply With Quote