Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sky color improvement #630

Merged
merged 2 commits into from
Nov 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Source/RunActivity/Content/ParticleEmitterShader.fx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ void _PSApplyDay2Night(inout float3 Color)
// The following constants define the beginning and the end conditions of the day-night transition
const float startNightTrans = 0.1; // The "NightTrans" values refer to the Y postion of LightVector
const float finishNightTrans = -0.1;
const float minDarknessCoeff = 0.15;
const float minDarknessCoeff = 0.03;

// Internal variables
// The following two are used to interpoate between day and night lighting (y = mx + b)
Expand Down
45 changes: 39 additions & 6 deletions Source/RunActivity/Content/SkyShader.fx
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ VERTEX_OUTPUT VSMoon(VERTEX_INPUT In)

// This function adjusts brightness, saturation and contrast
// By Romain Dura aka Romz
// Colors edit by DR_Aeronautics
float3 ContrastSaturationBrightness(float3 color, float brt, float sat, float con)
{
// Increase or decrease theese values to adjust r, g and b color channels separately
Expand All @@ -173,10 +174,18 @@ float4 PSSky(VERTEX_OUTPUT In) : COLOR
float4 starColor = tex2D(StarMapSampler, TexCoord);

// Adjust sky color brightness for time of day
skyColor *= SkyColor.x;
skyColor *= SkyColor.y;

// Stars
skyColor = lerp(starColor, skyColor, SkyColor.y);
// Stars (power function keeps stars hidden until after sunset)
// if-statement handles astronomical/final stage of twilight
if (LightVector.y < -0.2)
{
skyColor = lerp(starColor, skyColor, LightVector.y*6.6+2.22);
}
else
{
skyColor = lerp(starColor, skyColor, pow(abs(SkyColor.y),0.125));
}

// Fogging
skyColor.rgb = lerp(skyColor.rgb, FogColor.rgb, saturate((1 - In.Normal.y) * Fog.x));
Expand All @@ -189,11 +198,35 @@ float4 PSSky(VERTEX_OUTPUT In) : COLOR
// Coefficients selected by the author to achieve the desired appearance - fot limits the effect
skyColor += angleRcp * Fog.y;

// increase orange at sunset - fog limits the effect
// increase orange at sunset and yellow at sunrise - fog limits the effect
if (LightVector.x < 0)
{
skyColor.r += SkyColor.z * angleRcp * Fog.z;
skyColor.g += skyColor.r * Fog.w;
// These if-statements prevent the yellow-flash effect
if (LightVector.y > 0.13)
{
skyColor.rg += SkyColor.z*2 * angleRcp * Fog.z;
skyColor.r += SkyColor.z*2 * angleRcp * Fog.z;
}

else
{
skyColor.rg += angleRcp * 0.075 * SkyColor.y;
skyColor.r += angleRcp * 0.075 * SkyColor.y;
}
}
else
{
if (LightVector.y > 0.15)
{
skyColor.rg += SkyColor.z*3 * angleRcp * Fog.z;
skyColor.r += SkyColor.z * angleRcp * Fog.z;
}

else
{
skyColor.rg += angleRcp * 0.075 * SkyColor.y;
skyColor.r += pow(angleRcp * 0.075 * SkyColor.y,2);
}
}

// Keep alpha opague
Expand Down