initial commit
This commit is contained in:
118
Assets/Shader/SaturnAtmosphereLayer.shader
Normal file
118
Assets/Shader/SaturnAtmosphereLayer.shader
Normal file
@@ -0,0 +1,118 @@
|
||||
Shader "Custom/SaturnAtmosphereLayer"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex("Main Texture", 2D) = "white" {}
|
||||
_SecondTex("Second Texture", 2D) = "white" {}
|
||||
_FogTex("Fog Texture", 2D) = "white" {}
|
||||
_RimColor("Rim Color", Color) = (0.9, 0.8, 0.5, 1.0)
|
||||
_CoreColor("Core Color", Color) = (0.7, 0.6, 0.3, 0.3)
|
||||
_FogColor("Fog Color", Color) = (0.95, 0.9, 0.75, 0.2)
|
||||
_RimPower("Rim Power", Range(0.5, 8.0)) = 2.0
|
||||
_RimIntensity("Rim Intensity", Range(0.0, 5.0)) = 1.5
|
||||
_CoreIntensity("Core Intensity", Range(0.0, 2.0)) = 0.3
|
||||
_ScrollSpeed1("Scroll Speed 1", Range(-1.0, 1.0)) = 0.01
|
||||
_ScrollSpeed2("Scroll Speed 2", Range(-1.0, 1.0)) = -0.007
|
||||
_FogScrollSpeed("Fog Scroll Speed", Range(-1.0, 1.0)) = 0.003
|
||||
_PulseSpeed("Pulse Speed", Range(0.0, 3.0)) = 0.4
|
||||
_PulseStrength("Pulse Strength", Range(0.0, 1.0)) = 0.08
|
||||
_TextureBlend("Texture Blend", Range(0.0, 1.0)) = 0.5
|
||||
_TextureInfluence("Texture Influence", Range(0.0, 1.0)) = 0.5
|
||||
_FogInfluence("Fog Influence", Range(0.0, 1.0)) = 0.3
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "Queue" = "Transparent" "RenderType" = "Transparent" "RenderPipeline" = "UniversalPipeline" }
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ZWrite Off
|
||||
Cull Back
|
||||
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;
|
||||
float3 viewDirWS : TEXCOORD1;
|
||||
float3 positionWS : TEXCOORD2;
|
||||
float2 uv : TEXCOORD3;
|
||||
};
|
||||
|
||||
TEXTURE2D(_MainTex);
|
||||
SAMPLER(sampler_MainTex);
|
||||
TEXTURE2D(_SecondTex);
|
||||
SAMPLER(sampler_SecondTex);
|
||||
TEXTURE2D(_FogTex);
|
||||
SAMPLER(sampler_FogTex);
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
float4 _MainTex_ST;
|
||||
float4 _SecondTex_ST;
|
||||
float4 _FogTex_ST;
|
||||
half4 _RimColor;
|
||||
half4 _CoreColor;
|
||||
half4 _FogColor;
|
||||
float _RimPower;
|
||||
float _RimIntensity;
|
||||
float _CoreIntensity;
|
||||
float _ScrollSpeed1;
|
||||
float _ScrollSpeed2;
|
||||
float _FogScrollSpeed;
|
||||
float _PulseSpeed;
|
||||
float _PulseStrength;
|
||||
float _TextureBlend;
|
||||
float _TextureInfluence;
|
||||
float _FogInfluence;
|
||||
CBUFFER_END
|
||||
|
||||
Varyings vert(Attributes IN)
|
||||
{
|
||||
Varyings OUT;
|
||||
OUT.positionHCS = TransformObjectToHClip(IN.positionOS.xyz);
|
||||
OUT.normalWS = TransformObjectToWorldNormal(IN.normalOS);
|
||||
OUT.positionWS = TransformObjectToWorld(IN.positionOS.xyz);
|
||||
OUT.viewDirWS = normalize(_WorldSpaceCameraPos - OUT.positionWS);
|
||||
OUT.uv = TRANSFORM_TEX(IN.uv, _MainTex);
|
||||
return OUT;
|
||||
}
|
||||
|
||||
half4 frag(Varyings IN) : SV_Target
|
||||
{
|
||||
float2 uv1 = IN.uv + float2(_ScrollSpeed1 * _Time.y, 0);
|
||||
float2 uv2 = IN.uv + float2(_ScrollSpeed2 * _Time.y, 0);
|
||||
float2 uvFog = IN.uv + float2(0, _FogScrollSpeed * _Time.y);
|
||||
|
||||
half4 tex1 = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, uv1);
|
||||
half4 tex2 = SAMPLE_TEXTURE2D(_SecondTex, sampler_SecondTex, uv2);
|
||||
half4 texFog = SAMPLE_TEXTURE2D(_FogTex, sampler_FogTex, uvFog);
|
||||
half4 texBlended = lerp(tex1, tex2, _TextureBlend);
|
||||
|
||||
float3 normal = normalize(IN.normalWS);
|
||||
float3 viewDir = normalize(IN.viewDirWS);
|
||||
float fresnel = 1.0 - saturate(dot(normal, viewDir));
|
||||
float pulse = 1.0 + sin(_Time.y * _PulseSpeed) * _PulseStrength;
|
||||
float rim = pow(fresnel, _RimPower) * _RimIntensity * pulse;
|
||||
float core = (1.0 - fresnel) * _CoreIntensity;
|
||||
|
||||
half3 baseCol = lerp(_CoreColor.rgb * core, _RimColor.rgb * rim, fresnel);
|
||||
half3 texCol = lerp(baseCol, texBlended.rgb * rim, _TextureInfluence);
|
||||
half3 finalCol = lerp(texCol, texFog.rgb * _FogColor.rgb, _FogInfluence * (1.0 - fresnel));
|
||||
|
||||
float alpha = saturate(rim * 0.8 + core * _CoreColor.a);
|
||||
return half4(finalCol, alpha);
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user