86 lines
3.8 KiB
Plaintext
86 lines
3.8 KiB
Plaintext
Shader "Unheimlich/Portal Fog"
|
|
{
|
|
Properties
|
|
{
|
|
_ColorA ("Fog shadow", Color) = (0.18,0.25,0.28,0.38)
|
|
_ColorB ("Fog light", Color) = (0.42,0.52,0.54,0.38)
|
|
_DepthAtten ("Depth attenuation", Range(0,1)) = 1
|
|
_Density ("Density", Range(0,2)) = 0.8
|
|
_Curvature ("Curvature", Float) = 0.006
|
|
_StartDistance ("Start distance", Float) = 6
|
|
_HorizontalInfluence ("Horizontal influence", Float) = 0.12
|
|
_BendAngle ("Bend angle", Float) = 180
|
|
[Enum(Default,0,Outside,1,Inside,2)] _MaskID ("Portal mask", Float) = 0
|
|
}
|
|
SubShader
|
|
{
|
|
Tags { "RenderPipeline"="UniversalPipeline" "Queue"="Transparent" "RenderType"="Transparent" }
|
|
Pass
|
|
{
|
|
Name "PortalFog"
|
|
Tags { "LightMode"="SRPDefaultUnlit" }
|
|
Blend SrcAlpha OneMinusSrcAlpha
|
|
ZWrite Off
|
|
Cull Off
|
|
HLSLPROGRAM
|
|
#pragma vertex Vert
|
|
#pragma fragment Frag
|
|
#pragma target 3.5
|
|
#pragma multi_compile_instancing
|
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
|
#include "Assets/_Content/Shaders/Include/CurvedWorld.hlsl"
|
|
#include "Assets/_Content/Models/VFX/Fog/ShadersA/Fog.hlsl"
|
|
#include "Assets/_Content/Shaders/EnkiBilal/Include/Mask.hlsl"
|
|
CBUFFER_START(UnityPerMaterial)
|
|
float4 _ColorA, _ColorB;
|
|
float _DepthAtten, _Density;
|
|
float _Curvature, _StartDistance, _HorizontalInfluence, _BendAngle;
|
|
float _MaskID;
|
|
CBUFFER_END
|
|
float4x4 _Mask0, _Mask1, _Mask2;
|
|
struct Attributes { float3 positionOS : POSITION; UNITY_VERTEX_INPUT_INSTANCE_ID };
|
|
struct Varyings
|
|
{
|
|
float4 positionCS : SV_POSITION;
|
|
float3 originalWS : TEXCOORD0;
|
|
float3 originalOS : TEXCOORD1;
|
|
float3 bentWS : TEXCOORD2;
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
};
|
|
Varyings Vert(Attributes input)
|
|
{
|
|
Varyings output = (Varyings)0;
|
|
UNITY_SETUP_INSTANCE_ID(input);
|
|
UNITY_TRANSFER_INSTANCE_ID(input, output);
|
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
|
output.originalOS = input.positionOS;
|
|
output.originalWS = TransformObjectToWorld(input.positionOS);
|
|
float3 bent;
|
|
CurvedWorld_float(input.positionOS, _Curvature, _StartDistance, _HorizontalInfluence, _BendAngle, bent);
|
|
output.bentWS = TransformObjectToWorld(bent);
|
|
output.positionCS = TransformWorldToHClip(output.bentWS);
|
|
return output;
|
|
}
|
|
half4 Frag(Varyings input) : SV_Target
|
|
{
|
|
UNITY_SETUP_INSTANCE_ID(input);
|
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
|
|
// The mask is a camera projection, so it uses the displayed (bent) position.
|
|
float maskAlpha;
|
|
Mask_float(input.bentWS, _MaskID, _Mask0, _Mask1, _Mask2, maskAlpha);
|
|
clip(maskAlpha - 0.5);
|
|
float3 color; float alpha;
|
|
float3 scale = float3(length(TransformObjectToWorldDir(float3(1,0,0), false)),
|
|
length(TransformObjectToWorldDir(float3(0,1,0), false)),
|
|
length(TransformObjectToWorldDir(float3(0,0,1), false)));
|
|
// Keep the noise anchored in the world while the curtains follow the player.
|
|
Fog_float(_ColorA, _ColorB, _DepthAtten, input.originalWS, input.originalOS,
|
|
float3(0,0,0), scale, color, alpha);
|
|
return half4(color, saturate(alpha * _Density));
|
|
}
|
|
ENDHLSL
|
|
}
|
|
}
|
|
}
|