Skip to content

Commit 688d0cd

Browse files
Updated 2 files to make the sunset and sunrise more realistic
1 parent ef8a553 commit 688d0cd

File tree

2 files changed

+32
-7
lines changed

2 files changed

+32
-7
lines changed

Source/RunActivity/Content/ParticleEmitterShader.fx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ void _PSApplyDay2Night(inout float3 Color)
141141
// The following constants define the beginning and the end conditions of the day-night transition
142142
const float startNightTrans = 0.1; // The "NightTrans" values refer to the Y postion of LightVector
143143
const float finishNightTrans = -0.1;
144-
const float minDarknessCoeff = 0.15;
144+
const float minDarknessCoeff = 0.03;
145145

146146
// Internal variables
147147
// The following two are used to interpoate between day and night lighting (y = mx + b)

Source/RunActivity/Content/SkyShader.fx

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ VERTEX_OUTPUT VSMoon(VERTEX_INPUT In)
147147

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

175176
// Adjust sky color brightness for time of day
176-
skyColor *= SkyColor.x;
177+
skyColor *= SkyColor.y;
177178

178-
// Stars
179-
skyColor = lerp(starColor, skyColor, SkyColor.y);
179+
// Stars (power function keeps stars hidden until after sunset)
180+
skyColor = lerp(starColor, skyColor, pow(SkyColor.y,0.125));
180181

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

192-
// increase orange at sunset - fog limits the effect
193+
// increase orange at sunset and yellow at sunrise - fog limits the effect
193194
if (LightVector.x < 0)
194195
{
195-
skyColor.r += SkyColor.z * angleRcp * Fog.z;
196-
skyColor.g += skyColor.r * Fog.w;
196+
// These if-statements prevent the yellow-flash effect
197+
if (LightVector.y > 0.13)
198+
{
199+
skyColor.rg += SkyColor.z*2 * angleRcp * Fog.z;
200+
skyColor.r += SkyColor.z*2 * angleRcp * Fog.z;
201+
}
202+
203+
else
204+
{
205+
skyColor.rg += angleRcp * 0.075 * SkyColor.y;
206+
skyColor.r += angleRcp * 0.075 * SkyColor.y;
207+
}
208+
}
209+
else
210+
{
211+
if (LightVector.y > 0.15)
212+
{
213+
skyColor.rg += SkyColor.z*3 * angleRcp * Fog.z;
214+
skyColor.r += SkyColor.z * angleRcp * Fog.z;
215+
}
216+
217+
else
218+
{
219+
skyColor.rg += angleRcp * 0.075 * SkyColor.y;
220+
skyColor.r += pow(angleRcp * 0.075 * SkyColor.y,2);
221+
}
197222
}
198223

199224
// Keep alpha opague

0 commit comments

Comments
 (0)