imp. sun system
This commit is contained in:
@@ -0,0 +1,64 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!850595691 &4890085278179872738
|
||||||
|
LightingSettings:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_Name: New Lighting Settings
|
||||||
|
serializedVersion: 4
|
||||||
|
m_GIWorkflowMode: 1
|
||||||
|
m_EnableBakedLightmaps: 1
|
||||||
|
m_EnableRealtimeLightmaps: 0
|
||||||
|
m_RealtimeEnvironmentLighting: 1
|
||||||
|
m_BounceScale: 1
|
||||||
|
m_AlbedoBoost: 1
|
||||||
|
m_IndirectOutputScale: 1
|
||||||
|
m_UsingShadowmask: 1
|
||||||
|
m_BakeBackend: 1
|
||||||
|
m_LightmapMaxSize: 1024
|
||||||
|
m_BakeResolution: 40
|
||||||
|
m_Padding: 2
|
||||||
|
m_LightmapCompression: 3
|
||||||
|
m_AO: 0
|
||||||
|
m_AOMaxDistance: 1
|
||||||
|
m_CompAOExponent: 1
|
||||||
|
m_CompAOExponentDirect: 0
|
||||||
|
m_ExtractAO: 0
|
||||||
|
m_MixedBakeMode: 2
|
||||||
|
m_LightmapsBakeMode: 1
|
||||||
|
m_FilterMode: 1
|
||||||
|
m_LightmapParameters: {fileID: 15204, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
|
m_ExportTrainingData: 0
|
||||||
|
m_TrainingDataDestination: TrainingData
|
||||||
|
m_RealtimeResolution: 2
|
||||||
|
m_ForceWhiteAlbedo: 0
|
||||||
|
m_ForceUpdates: 0
|
||||||
|
m_FinalGather: 0
|
||||||
|
m_FinalGatherRayCount: 256
|
||||||
|
m_FinalGatherFiltering: 1
|
||||||
|
m_PVRCulling: 1
|
||||||
|
m_PVRSampling: 1
|
||||||
|
m_PVRDirectSampleCount: 32
|
||||||
|
m_PVRSampleCount: 512
|
||||||
|
m_PVREnvironmentSampleCount: 256
|
||||||
|
m_PVREnvironmentReferencePointCount: 2048
|
||||||
|
m_LightProbeSampleCountMultiplier: 4
|
||||||
|
m_PVRBounces: 2
|
||||||
|
m_PVRMinBounces: 1
|
||||||
|
m_PVREnvironmentMIS: 1
|
||||||
|
m_PVRFilteringMode: 1
|
||||||
|
m_PVRDenoiserTypeDirect: 1
|
||||||
|
m_PVRDenoiserTypeIndirect: 1
|
||||||
|
m_PVRDenoiserTypeAO: 1
|
||||||
|
m_PVRFilterTypeDirect: 0
|
||||||
|
m_PVRFilterTypeIndirect: 0
|
||||||
|
m_PVRFilterTypeAO: 0
|
||||||
|
m_PVRFilteringGaussRadiusDirect: 1
|
||||||
|
m_PVRFilteringGaussRadiusIndirect: 5
|
||||||
|
m_PVRFilteringGaussRadiusAO: 2
|
||||||
|
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
|
||||||
|
m_PVRFilteringAtrousPositionSigmaIndirect: 2
|
||||||
|
m_PVRFilteringAtrousPositionSigmaAO: 1
|
||||||
|
m_PVRTiledBaking: 0
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0ed2a899ff2cfdd4aaea5de3a75433c2
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 4890085278179872738
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -38,6 +38,7 @@ public class TimeManager : MonoBehaviour
|
|||||||
private TimeSpan _sunsetTime;
|
private TimeSpan _sunsetTime;
|
||||||
|
|
||||||
private float _timer;
|
private float _timer;
|
||||||
|
private float _sunInitialIntensity;
|
||||||
|
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private float _minuteToRealTime = 0.05f;
|
private float _minuteToRealTime = 0.05f;
|
||||||
@@ -48,6 +49,7 @@ public class TimeManager : MonoBehaviour
|
|||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
|
_sunInitialIntensity = _sunLight.intensity;
|
||||||
_timer = _minuteToRealTime;
|
_timer = _minuteToRealTime;
|
||||||
_currentTime = TimeSpan.Zero + TimeSpan.FromHours(_startHour);
|
_currentTime = TimeSpan.Zero + TimeSpan.FromHours(_startHour);
|
||||||
_sunriseTime = TimeSpan.FromHours(_sunriseHour);
|
_sunriseTime = TimeSpan.FromHours(_sunriseHour);
|
||||||
@@ -75,36 +77,23 @@ public class TimeManager : MonoBehaviour
|
|||||||
|
|
||||||
private void RotateSun()
|
private void RotateSun()
|
||||||
{
|
{
|
||||||
|
float intensityMultiplier = 1;
|
||||||
float sunLightRotation;
|
float timeofDay = (float)CurrentTime.TotalSeconds / 86400;
|
||||||
|
_sunLight.transform.localRotation = Quaternion.Euler((timeofDay * 360f) - 90, 170, 0);
|
||||||
if (_currentTime > _sunriseTime && _currentTime < _sunsetTime)
|
if (_currentTime > _sunriseTime && _currentTime < _sunsetTime)
|
||||||
{
|
{
|
||||||
TimeSpan sunriseToSunsetDuration = CalculateTimeDifference(_sunriseTime, _sunsetTime);
|
if (timeofDay <= 0.25f)
|
||||||
TimeSpan timeSinceSunrise = CalculateTimeDifference(_sunriseTime, _currentTime);
|
intensityMultiplier = Mathf.Clamp01((timeofDay - 0.23f) * (1 / 0.02f));
|
||||||
|
if (timeofDay >= 0.73f)
|
||||||
double percentage = timeSinceSunrise.TotalMinutes / sunriseToSunsetDuration.TotalMinutes;
|
intensityMultiplier = Mathf.Clamp01(1 - (timeofDay - 0.73f) * (1 / 0.02f));
|
||||||
|
|
||||||
sunLightRotation = Mathf.Lerp(0, 180, (float)percentage);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TimeSpan nightDuration = CalculateTimeDifference(_sunsetTime, _sunriseTime);
|
intensityMultiplier = 0;
|
||||||
TimeSpan timeSinceSunset = CalculateTimeDifference(_sunsetTime, _currentTime);
|
|
||||||
|
|
||||||
double percentage = timeSinceSunset.TotalMinutes / nightDuration.TotalMinutes;
|
|
||||||
|
|
||||||
sunLightRotation = Mathf.Lerp(180, 360, (float)percentage);
|
|
||||||
}
|
}
|
||||||
_sunLight.transform.rotation = Quaternion.AngleAxis(sunLightRotation, Vector3.right);
|
_sunLight.intensity = _sunInitialIntensity * intensityMultiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateLightSettings()
|
|
||||||
{
|
|
||||||
float dotProduct = Vector3.Dot(_sunLight.transform.forward, Vector3.down);
|
|
||||||
_sunLight.intensity = Mathf.Lerp(0, _maxSunLightIntensity, _lightChangeCurve.Evaluate(dotProduct));
|
|
||||||
_moonLight.intensity = Mathf.Lerp(_maxMoonLightIntensity, 0, _lightChangeCurve.Evaluate(dotProduct));
|
|
||||||
RenderSettings.ambientLight = Color.Lerp(_nightAmbientLight, _dayAmbientLight, _lightChangeCurve.Evaluate(dotProduct));
|
|
||||||
}
|
|
||||||
private TimeSpan CalculateTimeDifference(TimeSpan from, TimeSpan to)
|
private TimeSpan CalculateTimeDifference(TimeSpan from, TimeSpan to)
|
||||||
{
|
{
|
||||||
TimeSpan diff = to - from;
|
TimeSpan diff = to - from;
|
||||||
|
|||||||
Reference in New Issue
Block a user