GrabPass
Unity3D/Shader 2021. 11. 30. 18:14https://docs.unity3d.com/Manual/SL-ZWrite.html
Shader "Custom/Test"
{
Properties
{
_MainTex ("Albedo (RGB)", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Transparent" "Queue"="Transparent"}
//ZWrite Off
GrabPass {}
CGPROGRAM
#pragma surface surf _MyLight alpha:fade
#pragma target 3.0
sampler2D _MainTex;
sampler2D _GrabTexture;
struct Input
{
float2 uv_MainTex;
float4 screenPos;
};
void surf (Input IN, inout SurfaceOutput o)
{
fixed4 c = tex2D (_MainTex, IN.uv_MainTex );
//https://forum.unity.com/threads/unity3-surface-shader-grabpass.56098/
float3 screenUV = IN.screenPos.xyz/IN.screenPos.w;
float4 d = tex2D(_GrabTexture, screenUV.xy);
o.Emission = Luminance(d.rgb);
}
float4 Lighting_MyLight (SurfaceOutput o, float3 lightDir, float atten)
{
return float4(0, 0, 0, 1);
}
ENDCG
}
FallBack "Diffuse"
}
참고
https://docs.unity3d.com/Manual/SL-GrabPass.html
https://docs.unity.cn/2017.2/Documentation/Manual/SL-GrabPass.html
https://sudonull.com/post/9456-Writing-Shaders-in-Unity-GrabPass-PerRendererData
'Unity3D > Shader' 카테고리의 다른 글
Blending (0) | 2022.02.23 |
---|---|
normal map (0) | 2022.02.10 |
alpha:fade (0) | 2021.11.30 |
TRANSFORM_TEX (0) | 2021.11.29 |
SV_POSITION과 POSITION 의 차이? (0) | 2021.11.29 |