initial commit
This commit is contained in:
82
Assets/Shader/AtmosphereLayer.shader
Normal file
82
Assets/Shader/AtmosphereLayer.shader
Normal file
@@ -0,0 +1,82 @@
|
||||
Shader "Custom/AtmosphereLayer"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_RimColor("Rim Color", Color) = (0.4, 0.75, 1.0, 1.0)
|
||||
_CoreColor("Core Color", Color) = (0.0, 0.1, 0.4, 0.3)
|
||||
_RimPower("Rim Power", Range(0.5, 8.0)) = 1.5
|
||||
_RimIntensity("Rim Intensity", Range(0.0, 5.0)) = 2.5
|
||||
_CoreIntensity("Core Intensity", Range(0.0, 2.0)) = 0.4
|
||||
_PulseSpeed("Pulse Speed", Range(0.0, 3.0)) = 0.8
|
||||
_PulseStrength("Pulse Strength", Range(0.0, 1.0)) = 0.15
|
||||
}
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 positionHCS : SV_POSITION;
|
||||
float3 normalWS : TEXCOORD0;
|
||||
float3 viewDirWS : TEXCOORD1;
|
||||
float3 positionWS : TEXCOORD2;
|
||||
};
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
half4 _RimColor;
|
||||
half4 _CoreColor;
|
||||
float _RimPower;
|
||||
float _RimIntensity;
|
||||
float _CoreIntensity;
|
||||
float _PulseSpeed;
|
||||
float _PulseStrength;
|
||||
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);
|
||||
return OUT;
|
||||
}
|
||||
|
||||
half4 frag(Varyings IN) : SV_Target
|
||||
{
|
||||
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 col = lerp(_CoreColor.rgb * core, _RimColor.rgb * rim, fresnel);
|
||||
float alpha = saturate(rim * 0.8 + core * _CoreColor.a);
|
||||
|
||||
return half4(col, alpha);
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user