-
-
Save robert-michels/1272b6f0de41f4409cf4e61fdfbbd622 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // CODE SNIPPET, NOT THE FULL FILE // | |
| //Sets the mood of the environment (skybox, fog, dust, water). Input a value between 0 (beginning: grim) and 1 (ending: bright). | |
| private int startDust = 600; | |
| private int endDust = 0; | |
| private int startFogLimit = 300; | |
| private int endFogLimit = 1250; | |
| private int startFog = 0; | |
| private int endFog = 50; | |
| private void SetEnvironment (float lerp) | |
| { | |
| lerp = Util.capVal(lerp, 0, 1); | |
| Color horizonCol = Color.Lerp(startColors[1], endColors[1], lerp); | |
| //sky | |
| skyBox.SetColor("_TopColor", Color.Lerp(startColors[0], endColors[0], lerp)); | |
| skyBox.SetColor("_HorizonColor", horizonCol); | |
| skyBox.SetColor("_BottomColor", Color.Lerp(startColors[2], endColors[2], lerp)); | |
| //fog | |
| RenderSettings.fogColor = horizonCol; | |
| RenderSettings.fogEndDistance = Util.mapVal(lerp, 0, 1, startFogLimit, endFogLimit); | |
| RenderSettings.fogStartDistance = Util.mapVal(lerp, 0, 1, startFog, endFog); | |
| //dust | |
| int dustCount = (int)Mathf.SmoothStep(startDust, endDust, lerp); | |
| dust1.maxParticles = dustCount; | |
| dust2.maxParticles = dustCount / 12; | |
| //water | |
| waterMat.SetColor("_Color", Color.Lerp(waterColors[0], waterColors[1], lerp)); | |
| //Post Processing (disabled for mobile) | |
| ppBefore.weight = Util.mapVal(lerp, 0, 1, 1, 0); | |
| ppAfter.weight = Util.mapVal(lerp, 0, 1, 0, .4f); | |
| //sun | |
| sun.intensity = Util.mapVal(lerp, 0, 1, 0.5f, 1.1f); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment