77 lines
2.7 KiB
Plaintext
77 lines
2.7 KiB
Plaintext
Shader "Custom/VenusSurface"
|
|
{
|
|
Properties
|
|
{
|
|
_MainTex("Surface Texture", 2D) = "white" {}
|
|
_TroposphereLevel("Troposphere Level", Range(0, 1)) = 1
|
|
_DayColor("Day Color", Color) = (1.0, 0.3, 0.05, 1)
|
|
_NightColor("Night Color", Color) = (0.02, 0.02, 0.08, 1)
|
|
_SunDirection("Sun Direction", Vector) = (1, 0, 0, 0)
|
|
}
|
|
|
|
SubShader
|
|
{
|
|
Tags { "RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" }
|
|
|
|
Pass
|
|
{
|
|
HLSLPROGRAM
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
|
|
|
struct Attributes
|
|
{
|
|
float4 positionOS : POSITION;
|
|
float3 normalOS : NORMAL;
|
|
float2 uv : TEXCOORD0;
|
|
};
|
|
|
|
struct Varyings
|
|
{
|
|
float4 positionHCS : SV_POSITION;
|
|
float3 normalWS : TEXCOORD0;
|
|
float2 uv : TEXCOORD1;
|
|
};
|
|
|
|
TEXTURE2D(_MainTex);
|
|
SAMPLER(sampler_MainTex);
|
|
|
|
CBUFFER_START(UnityPerMaterial)
|
|
float4 _MainTex_ST;
|
|
float _TroposphereLevel;
|
|
half4 _DayColor;
|
|
half4 _NightColor;
|
|
float4 _SunDirection;
|
|
CBUFFER_END
|
|
|
|
Varyings vert(Attributes IN)
|
|
{
|
|
Varyings OUT;
|
|
OUT.positionHCS = TransformObjectToHClip(IN.positionOS.xyz);
|
|
OUT.normalWS = TransformObjectToWorldNormal(IN.normalOS);
|
|
OUT.uv = TRANSFORM_TEX(IN.uv, _MainTex);
|
|
return OUT;
|
|
}
|
|
|
|
half4 frag(Varyings IN) : SV_Target
|
|
{
|
|
half4 tex = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, IN.uv);
|
|
|
|
float3 normal = normalize(IN.normalWS);
|
|
float3 sunDir = normalize(_SunDirection.xyz);
|
|
float dayFactor = saturate(dot(normal, sunDir));
|
|
|
|
float heatBlend = saturate((1.0 - _TroposphereLevel) * 2.0);
|
|
float contrastFactor = saturate((1.0 - _TroposphereLevel) * 3.0);
|
|
dayFactor = saturate(dayFactor * (1.0 + contrastFactor * 2.0));
|
|
|
|
half3 heatColor = lerp(_NightColor.rgb, _DayColor.rgb, dayFactor);
|
|
half3 finalColor = lerp(tex.rgb, heatColor, heatBlend);
|
|
|
|
return half4(finalColor, 1.0);
|
|
}
|
|
ENDHLSL
|
|
}
|
|
}
|
|
} |