SUBSIM Radio Room Forums

SUBSIM Radio Room Forums (https://www.subsim.com/radioroom/index.php)
-   Silent Hunter 5 (https://www.subsim.com/radioroom/forumdisplay.php?f=244)
-   -   Sky comparison. SH2 vs SH5. 2001 vs 2010. (https://www.subsim.com/radioroom/showthread.php?t=166003)

Seeadler 11-01-10 10:04 PM

If i remember right, there are more interpolations for gradients in the sky pixel shader, this was just the base gradient in a chain of 3 or more lerp() functions in that shader file. There must be in addition one for horizon haze gradients and one for around the sun gradients like in other games and perhaps some more...

I'm here at a B&B with only a notebook and no access to the SH5 files, so I can't verify this.:hmmm:

THE_MASK 11-01-10 10:16 PM

Quote:

Originally Posted by Seeadler (Post 1526899)
If i remember right, there are more interpolations for gradients in the sky pixel shader, this was just the base gradient in a chain of 3 or more lerp() functions in that shader file. There must be in addition one for horizon haze gradients and one for around the sun gradients like in other games and perhaps some more...

I'm here at a B&B with only a notebook and no access to the SH5 files, so I can't verify this.:hmmm:

float3 g_sunDir : register(c0);
float3 g_orthogonalSunDir : register(c1);// at a 90 deg angle from sunDir
float3 g_fogColor : register(c2);
float2 g_fogParams : register(c3);
float g_sunDiskVisibility : register(c4);
float g_clipHeightOffset : register(c5);
float g_sunSize : register(c6);
float4 g_skyTopColor : register(c7);// with global sky color multiplier in "w"
float4 g_skyBottomColor : register(c8);// with height in "w"
float3 g_skyAroundSunColor : register(c9);
float3 g_skyAroundSunColor2 : register(c10);
float3 g_skyOppositeSunColor : register(c11);
float3 g_skyHazeColor : register(c12);// color
float3 g_skyHazeHeight : register(c13);// .z is the real height, clamped to max 180
float4 g_sunDisk : register(c14);// color & size
struct PS_IN
{
float4 eyeDir : TEXCOORD0;// eyeDir.w hold Y pos
float3 normal : TEXCOORD1;
};
float fastsin(float x)
{
float3 xx;
float3 coefs = float3(1, -0.1666666, 0.0083333);
float x2 = x*x;
xx.x = x;
xx.y = xx.x * x2;
xx.z = xx.y * x2;
return dot(xx, coefs);
}
float4 main( PS_IN In ) : COLOR
{
float3 color;
clip(In.eyeDir.w + g_clipHeightOffset);

float theta = dot(In.eyeDir.xyz, g_sunDir) / length(In.eyeDir.xyz);
float thetaSquared = theta * theta;

// 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);
// 2. around sun color 1 - haze a larger radius
float aroundSunMask = pow(saturate(theta), 7);
color = lerp(color, g_skyAroundSunColor, aroundSunMask);
// 3. opposite sun color at 90 degrees
//float oppositeMask = saturate(dot(g_orthogonalSunDir, In.eyeDir.xyz));
//oppositeMask = pow(oppositeMask, 3);
//color = lerp(color, g_skyOppositeSunColor, oppositeMask);
// 4. opposite sun color at 180 degrees
//float oppositeMask = pow(-theta * 0.5 + 0.5, 3);
//color = lerp(color, g_skyOppositeSunColor, oppositeMask);
// 5. around sun color 2 - has a smaller radius
// use the vertex normal for cos(alpha) this time, because it deforms the lighting a little on the horizon
float thetaNormal = saturate(dot(In.normal, g_sunDir) / length(In.normal));
aroundSunMask = pow(thetaNormal, 80);
color = lerp(color, g_skyAroundSunColor2, aroundSunMask);

// 6. horizont haze
float hazeMask = smoothstep(1, 0, saturate(In.eyeDir.w * g_skyHazeHeight.x - g_skyHazeHeight.y));
color = lerp(color, g_skyHazeColor, hazeMask);
// 7. multiply by global sky multiplier (in g_skyTopColor.w)
color *= g_skyTopColor.w;
// 8. sun disk
// TODO - pass constants in register
if ( theta > 0.98 )
{
float dotNS = acos(theta);
float diskMask = saturate((dotNS - 0) * g_sunSize);
diskMask = saturate(0.5 - (fastsin(3.14159 *(diskMask - 0.5f)) + 1) * 0.5f);
//float diskMask = saturate((theta - g_sunDisk.w) * g_invSunSize);
float sunShadow = min(1, In.eyeDir.w / g_skyHazeHeight.z);
color = lerp(color, g_sunDisk.rgb, diskMask * g_sunDiskVisibility * sunShadow);
}
float coef = 1.0 - saturate(In.eyeDir.w * g_fogParams.x - g_fogParams.y);
color = lerp(color, g_fogColor, coef);

float shaftsMask = log(theta);
float alpha = 30 + shaftsMask;//lerp(shaftsMask, 0, coef);
return float4(color, alpha);
}


All times are GMT -5. The time now is 07:46 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 1995- 2025 Subsim®
"Subsim" is a registered trademark, all rights reserved.