Skip to content

Commit 874712b

Browse files
committed
Add sun movement and day cycle to atmosphere system
Introduces a dayDurationInSeconds parameter and animates the sun's rotation to simulate a day-night cycle in PlanetAtmosphereSystem.cs. Updates materials to use the new sun direction, modifies scene settings for improved rendering, and adds the system component to the BluePlanetArea scene.
1 parent 1ae8bdc commit 874712b

File tree

5 files changed

+34
-6
lines changed

5 files changed

+34
-6
lines changed

Red Strike/Assets/PlanetAtmosphereSystem/AtmosphereMaterial.mat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Material:
4747
- _GunesYonu: {r: -0.91, g: 0.4, b: 3.24, a: 0}
4848
- _RenkUzak: {r: 0, g: 0.10166844, b: 2.152374, a: 1}
4949
- _RenkYakin: {r: 0, g: 5.670685, b: 8, a: 1}
50-
- _SunDirection: {r: -0, g: 0.4099231, b: -0.9121201, a: 0}
50+
- _SunDirection: {r: 0.17096215, g: 0.1752097, b: -0.96957386, a: 0}
5151
m_BuildTextureStacks: []
5252
m_AllowLocking: 1
5353
--- !u!114 &1522106816477559216

Red Strike/Assets/PlanetAtmosphereSystem/CloudMaterial.mat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Material:
4343
m_Colors:
4444
- _Color: {r: 0, g: 1.0177532, b: 1.5933679, a: 1}
4545
- _GunesYonu: {r: -1, g: 0, b: 0, a: 0}
46-
- _SunDirection: {r: -0, g: 0.4099231, b: -0.9121201, a: 0}
46+
- _SunDirection: {r: 0.17096215, g: 0.1752097, b: -0.96957386, a: 0}
4747
m_BuildTextureStacks: []
4848
m_AllowLocking: 1
4949
--- !u!114 &8499732345945835446

Red Strike/Assets/PlanetAtmosphereSystem/FogMaterial.mat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,6 @@ Material:
5454
- _QueueControl: 0
5555
- _QueueOffset: 0
5656
m_Colors:
57-
- _SunDirection: {r: -0, g: 0.4099231, b: -0.9121201, a: 0}
57+
- _SunDirection: {r: 0.17096215, g: 0.1752097, b: -0.96957386, a: 0}
5858
m_BuildTextureStacks: []
5959
m_AllowLocking: 1

Red Strike/Assets/PlanetAtmosphereSystem/PlanetAtmosphereSystem.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ namespace PlanetAtmosphereSystem
44
{
55
public class PlanetAtmosphereSystem : MonoBehaviour
66
{
7+
[Header("Sun Settings")]
78
public Light sunLight;
9+
public float dayDurationInSeconds = 120f;
10+
private float timeElapsed = 0f;
11+
12+
[Header("Materials")]
813
public Material atmosphereMaterial;
914
public Material cloudMaterial;
1015
public Material fogMaterial;
@@ -17,7 +22,13 @@ private void Update()
1722
atmosphereMaterial.SetVector("_SunDirection", sunDirection);
1823
cloudMaterial.SetVector("_SunDirection", sunDirection);
1924
fogMaterial.SetVector("_SunDirection", sunDirection);
25+
26+
timeElapsed += Time.deltaTime;
27+
float normalizedTime = (timeElapsed % dayDurationInSeconds) / dayDurationInSeconds;
28+
29+
float sunAngle = normalizedTime * 360f - 90f;
30+
sunLight.transform.rotation = Quaternion.Euler(new Vector3(sunAngle, 170f, 0f));
2031
}
21-
}
32+
}
2233
}
2334
}

Red Strike/Assets/Scenes/BluePlanetArea.unity

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ Camera:
344344
width: 1
345345
height: 1
346346
near clip plane: 0.01
347-
far clip plane: 1200
347+
far clip plane: 500000
348348
field of view: 60
349349
orthographic: 0
350350
orthographic size: 5
@@ -401,7 +401,7 @@ MonoBehaviour:
401401
m_Bits: 1
402402
m_VolumeTrigger: {fileID: 0}
403403
m_VolumeFrameworkUpdateModeOption: 2
404-
m_RenderPostProcessing: 0
404+
m_RenderPostProcessing: 1
405405
m_Antialiasing: 0
406406
m_AntialiasingQuality: 2
407407
m_StopNaN: 0
@@ -5673,6 +5673,7 @@ GameObject:
56735673
- component: {fileID: 1936849620}
56745674
- component: {fileID: 1936849619}
56755675
- component: {fileID: 1936849621}
5676+
- component: {fileID: 1936849622}
56765677
m_Layer: 0
56775678
m_Name: SunLight
56785679
m_TagString: Untagged
@@ -5783,6 +5784,21 @@ MonoBehaviour:
57835784
m_LightCookieSize: {x: 1, y: 1}
57845785
m_LightCookieOffset: {x: 0, y: 0}
57855786
m_SoftShadowQuality: 0
5787+
--- !u!114 &1936849622
5788+
MonoBehaviour:
5789+
m_ObjectHideFlags: 0
5790+
m_CorrespondingSourceObject: {fileID: 0}
5791+
m_PrefabInstance: {fileID: 0}
5792+
m_PrefabAsset: {fileID: 0}
5793+
m_GameObject: {fileID: 1936849618}
5794+
m_Enabled: 1
5795+
m_EditorHideFlags: 0
5796+
m_Script: {fileID: 11500000, guid: 902d3dd2f52a3ac4ab39f0e3bb13d3df, type: 3}
5797+
m_Name:
5798+
m_EditorClassIdentifier:
5799+
sunLight: {fileID: 0}
5800+
dayDurationInSeconds: 120
5801+
timeElapsed: 0
57865802
--- !u!1 &2126698095
57875803
GameObject:
57885804
m_ObjectHideFlags: 0
@@ -5873,6 +5889,7 @@ MonoBehaviour:
58735889
m_Name:
58745890
m_EditorClassIdentifier:
58755891
sunLight: {fileID: 1936849619}
5892+
dayDurationInSeconds: 60
58765893
atmosphereMaterial: {fileID: 2100000, guid: 2408ec61631a3e24db680f86b5b150a7, type: 2}
58775894
cloudMaterial: {fileID: 2100000, guid: 452202a9af21f504594d57e7b894652a, type: 2}
58785895
fogMaterial: {fileID: 2100000, guid: cb5b62743c9506845aa26111364535f4, type: 2}

0 commit comments

Comments
 (0)