The intensity of the stars gets multiplied with the color from the “_Stars” texture. Note that this property defaults to “black” instead of “white” like we’re used to with other textures this is so that if you don’t provide a texture for the stars the sky won’t glow white (since the stars color is being added to the rest of the color). The phase of the moon allows you to get a crescent moon shape instead of a solid disk. Offsets the start of the top color in the Y axis. Offsets the start of the middle color in the Y axis.ĭetermines how smoothly the middle color will blend with the top color. Let’s talk a bit about the propeties: Propertyĭetermines how smoothly the bottom color will blend with the middle color. SilverLining *= smoothstep(_SunSize * 3.0, 0.0, sunSDF) * _CloudsColor.a įixed4 cloudsCol = lerp(_CloudsColor, _CloudsColor + _SunColor, cloudShading * smoothstep(0.3, 0.0, sunSDF) * _SunCloudIntensity) smoothstep(cloudsThreshold + 0.02, cloudsThreshold + _CloudsSmoothness + 0.02, cloudsTex)) Smoothstep(cloudsThreshold + _CloudsSmoothness + 0.1, cloudsThreshold + _CloudsSmoothness + 0.4, cloudsTex) Ĭlouds = lerp(clouds, cloudShading, 0.5) * middleThreshold * _CloudsColor.a įloat silverLining = (smoothstep(cloudsThreshold, cloudsThreshold + _CloudsSmoothness, cloudsTex) Moon = saturate(moon * -_WorldSpaceLightPos0.y - clouds) įloat cloudShading = smoothstep(cloudsThreshold, cloudsThreshold + _CloudsSmoothness + 0.1, cloudsTex). O.vertex = UnityObjectToClipPos(v.vertex) įloat2 uv = float2(atan2(i.uv.x,i.uv.z) / UNITY_TWO_PI, asin(i.uv.y) / UNITY_HALF_PI) įloat middleThreshold = smoothstep(0.0, 0.5 - (1.0 - _MiddleSmoothness) / 2.0, i.uv.y - _MiddleOffset) įloat topThreshold = smoothstep(0.5, 1.0 - (1.0 - _TopSmoothness) / 2.0, i.uv.y - _TopOffset) įixed4 col = lerp(_ColorBottom, _ColorMiddle, middleThreshold) Ĭol = lerp(col, _ColorTop, topThreshold) įloat cloudsThreshold = i.uv.y - _CloudsThreshold įloat cloudsTex = tex2D(_CloudsTexture, uv * _CloudsTexture_ST.xy + _CloudsTexture_ST.zw + float2(_PanningSpeedX, _PanningSpeedY) * _Time.y) įloat clouds = smoothstep(cloudsThreshold, cloudsThreshold + _CloudsSmoothness, cloudsTex) įloat stars = tex2D(_Stars, (i.uv.xz / i.uv.y) * _Stars_ST.xy) * _StarsIntensity * saturate(-_WorldSpaceLightPos0.y) * (1.0 - clouds) įloat sunSDF = distance(i.uv.xyz, _WorldSpaceLightPos0) įloat sun = max(clouds * _CloudsColor.a, smoothstep(0, _SunSize, sunSDF)) įloat moonSDF = distance(i.uv.xyz, -_WorldSpaceLightPos0) įloat moonPhaseSDF = distance(i.uv.xyz - float3(0.0, 0.0, 0.1) * _MoonPhase, -_WorldSpaceLightPos0) _CloudsTexture("Clouds texture", 2D) = "black" _StarsIntensity("Stars intensity", float) = 0 _MiddleOffset("Middle offset", float) = 0 _MiddleSmoothness("Middle smoothness", Range(0.0,1.0)) = 1 Keep in mind that most of the stuff here are for the operations on the clouds/sun etc which might look a bit complicated but hopefully stuff will make some sense. These effects don’t apply to the moon, but you could easily expand the shader so that they do. The clouds also feature some emission based on the sun’s position, so there’s a silver lining effect as well as a glow when the clouds are covering the sun or are near it. Horizon clouds (the ones you can see far in the distance, not the ones above your head) with adjustable coverage, edge smoothness etc.Small support for a stars texture that appears when the sun is down. Moon with adjustable phase, again positioned based on the scene’s directional light. Sun disc positioned based on the scene’s directional light.
0 Comments
Leave a Reply. |