57 lines
1.5 KiB
Plaintext
57 lines
1.5 KiB
Plaintext
Shader "Hidden/WBOIT/WBOITBlend"
|
|
{
|
|
|
|
SubShader
|
|
{
|
|
ZTest Always Cull Back ZWrite Off Fog { Mode Off }
|
|
Pass
|
|
{
|
|
CGPROGRAM
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
|
|
#include "UnityCG.cginc"
|
|
|
|
struct v2f
|
|
{
|
|
float2 uv : TEXCOORD0;
|
|
float4 vertex : SV_POSITION;
|
|
};
|
|
|
|
sampler2D _CameraColorTex;
|
|
sampler2D _AccumTex;
|
|
sampler2D _RevealageTex;
|
|
|
|
v2f vert (uint vertexID: SV_VertexID)
|
|
{
|
|
v2f o;
|
|
float2 uv = float2((vertexID << 1) & 2, vertexID & 2);
|
|
float4 pos = float4(uv * 2.0 - 1.0, UNITY_NEAR_CLIP_VALUE, 1.0);
|
|
#ifdef UNITY_PRETRANSFORM_TO_DISPLAY_ORIENTATION
|
|
pos = ApplyPretransformRotation(pos);
|
|
#endif
|
|
|
|
#if UNITY_UV_STARTS_AT_TOP
|
|
uv = float2((vertexID << 1) & 2, 1.0 - (vertexID & 2));
|
|
#endif
|
|
|
|
o.vertex = pos;
|
|
o.uv = uv;
|
|
return o;
|
|
}
|
|
|
|
fixed4 frag (v2f i) : SV_Target
|
|
{
|
|
fixed4 background = tex2D(_CameraColorTex, i.uv);
|
|
float4 accum = tex2D(_AccumTex, i.uv);
|
|
float r = tex2D(_RevealageTex, i.uv).r;
|
|
|
|
fixed4 col = float4(accum.rgb / clamp(accum.a, 1e-4, 5e4), r);
|
|
|
|
return (1.0 - col.a) * col + col.a * background;
|
|
}
|
|
ENDCG
|
|
}
|
|
}
|
|
}
|