97 lines
2.9 KiB
Plaintext
97 lines
2.9 KiB
Plaintext
Shader "Cielonos/MeshEffects/Afterimage"
|
|
{
|
|
Properties
|
|
{
|
|
[Header(Color Settings)]
|
|
[HDR] _BaseColor("Base Color", Color) = (0, 0.9, 1, 0.2)
|
|
[HDR] _RimColor("Rim Color (Fresnel)", Color) = (0.5, 0.9, 1, 1)
|
|
_RimPower("Rim Power", Range(0.1, 10)) = 3.0
|
|
_Glow("Glow Intensity", Range(0, 10)) = 2.0
|
|
|
|
[Header(Fade Settings)]
|
|
_Fade("Fade (Alpha)", Range(0, 1)) = 1.0
|
|
}
|
|
|
|
SubShader
|
|
{
|
|
Tags
|
|
{
|
|
"RenderType" = "Transparent"
|
|
"Queue" = "Transparent"
|
|
"RenderPipeline" = "UniversalPipeline"
|
|
"IgnoreProjector" = "True"
|
|
}
|
|
|
|
Blend SrcAlpha One
|
|
ZWrite Off
|
|
Cull Back
|
|
|
|
Pass
|
|
{
|
|
Name "AfterimagePass"
|
|
Tags { "LightMode" = "UniversalForward" }
|
|
|
|
HLSLPROGRAM
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
#pragma prefer_hlslcc gles
|
|
#pragma exclude_renderers d3d11_9x
|
|
|
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
|
|
|
struct Attributes
|
|
{
|
|
float4 positionOS : POSITION;
|
|
float3 normalOS : NORMAL;
|
|
};
|
|
|
|
struct Varyings
|
|
{
|
|
float4 positionCS : SV_POSITION;
|
|
float3 normalWS : TEXCOORD0;
|
|
float3 viewDirWS : TEXCOORD1;
|
|
};
|
|
|
|
CBUFFER_START(UnityPerMaterial)
|
|
float4 _BaseColor;
|
|
float4 _RimColor;
|
|
float _RimPower;
|
|
float _Glow;
|
|
float _Fade;
|
|
CBUFFER_END
|
|
|
|
Varyings vert(Attributes input)
|
|
{
|
|
Varyings output;
|
|
|
|
VertexPositionInputs vertexInput = GetVertexPositionInputs(input.positionOS.xyz);
|
|
output.positionCS = vertexInput.positionCS;
|
|
|
|
float3 positionWS = vertexInput.positionWS;
|
|
output.normalWS = TransformObjectToWorldNormal(input.normalOS);
|
|
output.viewDirWS = GetWorldSpaceViewDir(positionWS);
|
|
|
|
return output;
|
|
}
|
|
|
|
float4 frag(Varyings input) : SV_Target
|
|
{
|
|
float3 normalWS = normalize(input.normalWS);
|
|
float3 viewDirWS = normalize(input.viewDirWS);
|
|
|
|
// Fresnel term
|
|
float ndotv = dot(normalWS, viewDirWS);
|
|
float fresnel = pow(1.0 - saturate(ndotv), _RimPower);
|
|
|
|
// Color composite
|
|
float4 color = _BaseColor + _RimColor * fresnel * _Glow;
|
|
// Fade applied to alpha
|
|
color.a = (_BaseColor.a + fresnel) * _Fade;
|
|
|
|
return color;
|
|
}
|
|
ENDHLSL
|
|
}
|
|
}
|
|
}
|