SUBSIM Radio Room Forums



SUBSIM: The Web's #1 resource for all submarine & naval simulations since 1997

Go Back   SUBSIM Radio Room Forums > Silent Hunter 3 - 4 - 5 > Silent Hunter 5
Forget password? Reset here

Reply
 
Thread Tools Display Modes
Old 10-29-10, 11:04 PM   #1
THE_MASK
Ace of the deep .
 
THE_MASK's Avatar
 
Join Date: Jan 2006
Posts: 9,153
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
Old 10-30-10, 07:35 AM   #2
panosrxo
Planesman
 
Join Date: Jan 2010
Location: Greece
Posts: 188
Downloads: 115
Uploads: 0
Default

Quote:
Originally Posted by sober View Post
Using a gradient causes the sky banding . I just deleted the bit in green and it seems much better .
pow is a power function, if you are to remove the function you should also remove this part: , g_skyBottomColor.w

power function is pow(x,y)=x^y
panosrxo is offline   Reply With Quote
Old 10-30-10, 10:28 AM   #3
Sailor Steve
Eternal Patrol
 
Sailor Steve's Avatar
 
Join Date: Nov 2002
Location: High in the mountains of Utah
Posts: 44,456
Downloads: 745
Uploads: 249


Default

I see it in SH4, and not in SH3. I have no idea about anything involved with this, I'm just sayin'.
__________________
“Never do anything you can't take back.”
—Rocky Russo
Sailor Steve is offline   Reply With Quote
Old 10-30-10, 11:47 AM   #4
divittor
Bosun
 
Join Date: Oct 2010
Location: UK
Posts: 65
Downloads: 56
Uploads: 0
Default

I get the banding in sh5 didn't notice it so much in 3 and 4.

I have an i7 quad core so i guess it's not something cpu related.

My cards are 2 x NVIDIA GTX 470 in SLI althought i read somewhere SLI
does not work in game ?

4gb RAM Windows 7 64 bit

Screen is a Samsung Syncmaster P2450

My res in game is 1900x1080 i think (not got it running at moment )
and have maxed most graphics options in game.

I personally think the latest nvidia cards accenctuate the banding maybe?

TDW uses a Nvidia GTX480 do you get the banding TDW?

Which enviroment MOD available at the moment best deals with this issue?

I don't really want to mess with stock files and I'm guessing i could reduce the banding by tweaking my personal settings.

Any ideas to reduce or eliminate it would be most welcome.
__________________
Don't dive, ram .
divittor is offline   Reply With Quote
Old 10-31-10, 08:12 PM   #5
the_tyrant
Admiral
 
Join Date: Jun 2010
Location: Canada
Posts: 2,241
Downloads: 58
Uploads: 0
Default

the best explanation is that it is the video card
just like how games designed for nvidia cards are horrible on ati cards
Ubisoft optimizes for ATI, so that is probably why
the_tyrant is offline   Reply With Quote
Old 10-31-10, 11:53 PM   #6
rik007
Grey Wolf
 
Join Date: Jan 2002
Location: Holland
Posts: 818
Downloads: 126
Uploads: 0
Default

Quote:
Originally Posted by sober View Post
Using a gradient causes the sky banding . I just deleted the bit in green and it seems much better .
You can adapt the shader but it will still be called 992 times by SH-5 each time a screen is drawn. You would have liked that the shader is called 1984 (2 * 992) or more but therefore you need to change the code unfortunately.
rik007 is offline   Reply With Quote
Old 11-01-10, 12:46 AM   #7
THE_MASK
Ace of the deep .
 
THE_MASK's Avatar
 
Join Date: Jan 2006
Posts: 9,153
Downloads: 901
Uploads: 73


Default

I can get rid of the banding completely by deleting the gradiant but it deletes the sun as well .
THE_MASK is offline   Reply With Quote
Old 11-01-10, 08:02 AM   #8
Seeadler
Pacific Aces Dev Team
 
Join Date: Mar 2001
Location: Northern Germany
Posts: 1,096
Downloads: 169
Uploads: 0


Default

Quote:
Originally Posted by sober View Post
I can get rid of the banding completely by deleting the gradiant but it deletes the sun as well .
based on the posted shader function above, set the interpolate value in the lerp() function to a constant value. That ought to repeal the individual gradients but does not affect the pixel color for the sun.

change from:
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);
to:

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, 1 /*heightRatio*/);
I can not say if it work and/or how it will look in the game, I have SH5 not installed on my PC.
__________________
--
Vapor-ware is always easier to sell because there's no limit what it can do!
Seeadler is offline   Reply With Quote
Old 11-01-10, 02:10 PM   #9
THE_MASK
Ace of the deep .
 
THE_MASK's Avatar
 
Join Date: Jan 2006
Posts: 9,153
Downloads: 901
Uploads: 73


Default

How it looks in game . The pic was auto enhanced so the banding is easier seen . Doesnt look quite so bad ingame . Thanks seeadler .


Last edited by THE_MASK; 11-01-10 at 02:55 PM.
THE_MASK is offline   Reply With Quote
Old 11-01-10, 10:04 PM   #10
Seeadler
Pacific Aces Dev Team
 
Join Date: Mar 2001
Location: Northern Germany
Posts: 1,096
Downloads: 169
Uploads: 0


Default

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.
__________________
--
Vapor-ware is always easier to sell because there's no limit what it can do!
Seeadler is offline   Reply With Quote
Old 11-01-10, 10:16 PM   #11
THE_MASK
Ace of the deep .
 
THE_MASK's Avatar
 
Join Date: Jan 2006
Posts: 9,153
Downloads: 901
Uploads: 73


Default

Quote:
Originally Posted by Seeadler View Post
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.
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);
}
THE_MASK is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 03:36 PM.


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