149 lines
4.1 KiB
Plaintext
149 lines
4.1 KiB
Plaintext
|
|
Shader "OIT/MOIT/MOITSimpleTranspatent"
|
||
|
|
{
|
||
|
|
Properties
|
||
|
|
{
|
||
|
|
_Color ("Color Tint", Color) = (1, 1, 1, 1)
|
||
|
|
_MainTex ("Main Tex", 2D) = "white" {}
|
||
|
|
|
||
|
|
[Enum(Off, 0, Front, 1, Back, 2)]
|
||
|
|
_Cull("Cull", Float) = 2.0
|
||
|
|
}
|
||
|
|
SubShader
|
||
|
|
{
|
||
|
|
Tags
|
||
|
|
{
|
||
|
|
"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"
|
||
|
|
}
|
||
|
|
|
||
|
|
Pass
|
||
|
|
{
|
||
|
|
Name "GenerateMoments"
|
||
|
|
Tags
|
||
|
|
{
|
||
|
|
"LightMode" = "GenerateMoments"
|
||
|
|
}
|
||
|
|
Blend One One
|
||
|
|
ZWrite Off
|
||
|
|
Cull[_Cull]
|
||
|
|
|
||
|
|
HLSLPROGRAM
|
||
|
|
#pragma vertex vert
|
||
|
|
#pragma fragment frag
|
||
|
|
#pragma target 4.5
|
||
|
|
|
||
|
|
#pragma multi_compile _MOMENT4 _MOMENT6 _MOMENT8
|
||
|
|
#pragma multi_compile _ _TRIGONOMETRIC
|
||
|
|
#pragma shader_feature _MOMENT_HALF_PRECISION _MOMENT_SINGLE_PRECISION
|
||
|
|
|
||
|
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||
|
|
#if _MOMENT_HALF_PRECISION
|
||
|
|
#include "Quantization.hlsl"
|
||
|
|
#endif
|
||
|
|
#include "WarpDepth.hlsl"
|
||
|
|
#include "GenerateMoments.hlsl"
|
||
|
|
|
||
|
|
struct appdata
|
||
|
|
{
|
||
|
|
float4 vertex : POSITION;
|
||
|
|
float2 uv : TEXCOORD0;
|
||
|
|
};
|
||
|
|
|
||
|
|
struct v2f
|
||
|
|
{
|
||
|
|
float2 uv : TEXCOORD0;
|
||
|
|
float4 vertex : SV_POSITION;
|
||
|
|
};
|
||
|
|
|
||
|
|
sampler2D _MainTex;
|
||
|
|
float4 _MainTex_ST;
|
||
|
|
half4 _Color;
|
||
|
|
|
||
|
|
v2f vert(appdata v)
|
||
|
|
{
|
||
|
|
v2f o;
|
||
|
|
o.vertex = TransformObjectToHClip(v.vertex.xyz);
|
||
|
|
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
|
||
|
|
return o;
|
||
|
|
}
|
||
|
|
|
||
|
|
MomentOutput frag(v2f i)
|
||
|
|
{
|
||
|
|
float4 col = tex2D(_MainTex, i.uv) * _Color;
|
||
|
|
float positionCSZ = LinearEyeDepth(i.vertex.z, _ZBufferParams);
|
||
|
|
return GenerateMoments(positionCSZ, 1 - col.a);
|
||
|
|
}
|
||
|
|
ENDHLSL
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
Pass
|
||
|
|
{
|
||
|
|
Name "ResolveMoments"
|
||
|
|
Tags
|
||
|
|
{
|
||
|
|
"LightMode" = "ResolveMoments"
|
||
|
|
}
|
||
|
|
Blend One One
|
||
|
|
ZWrite Off
|
||
|
|
Cull[_Cull]
|
||
|
|
|
||
|
|
HLSLPROGRAM
|
||
|
|
#pragma vertex vert
|
||
|
|
#pragma fragment frag
|
||
|
|
#pragma target 4.5
|
||
|
|
|
||
|
|
#pragma multi_compile _MOMENT4 _MOMENT6 _MOMENT8
|
||
|
|
#pragma multi_compile _ _TRIGONOMETRIC
|
||
|
|
#pragma shader_feature _MOMENT_HALF_PRECISION _MOMENT_SINGLE_PRECISION
|
||
|
|
|
||
|
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||
|
|
|
||
|
|
|
||
|
|
SAMPLER(sampler_LinearClamp);
|
||
|
|
#if _MOMENT_HALF_PRECISION
|
||
|
|
#include "Quantization.hlsl"
|
||
|
|
#endif
|
||
|
|
#include "MomentMath.hlsl"
|
||
|
|
#include "TrigonometricMomentMath.hlsl"
|
||
|
|
#include "WarpDepth.hlsl"
|
||
|
|
#include "ResolveMoments.hlsl"
|
||
|
|
|
||
|
|
struct appdata
|
||
|
|
{
|
||
|
|
float4 vertex : POSITION;
|
||
|
|
float2 uv : TEXCOORD0;
|
||
|
|
};
|
||
|
|
|
||
|
|
struct v2f
|
||
|
|
{
|
||
|
|
float2 uv : TEXCOORD0;
|
||
|
|
float4 vertex : SV_POSITION;
|
||
|
|
};
|
||
|
|
|
||
|
|
sampler2D _MainTex;
|
||
|
|
float4 _MainTex_ST;
|
||
|
|
half4 _Color;
|
||
|
|
|
||
|
|
|
||
|
|
v2f vert(appdata v)
|
||
|
|
{
|
||
|
|
v2f o;
|
||
|
|
o.vertex = TransformObjectToHClip(v.vertex.xyz);
|
||
|
|
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
|
||
|
|
return o;
|
||
|
|
}
|
||
|
|
|
||
|
|
half4 frag(v2f i) : SV_Target
|
||
|
|
{
|
||
|
|
float4 col = tex2D(_MainTex, i.uv) * _Color;
|
||
|
|
float positionCSZ = LinearEyeDepth(i.vertex.z, _ZBufferParams);
|
||
|
|
float td, tt;
|
||
|
|
_Overestimation = 0.25f;
|
||
|
|
ResolveMoments(td, tt, positionCSZ, i.vertex.xy * _B0_TexelSize.xy);
|
||
|
|
col.rgb *= col.a;
|
||
|
|
return col * td;
|
||
|
|
}
|
||
|
|
ENDHLSL
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|