Unity3D/Shader

GrabPass

일등하이 2021. 11. 30. 18:14
반응형

https://docs.unity3d.com/Manual/SL-ZWrite.html

 

Unity - Manual: ShaderLab command: ZWrite

ShaderLab legacy functionality ShaderLab command: ZWrite Sets whether the depth bufferA memory store that holds the z-value depth of each pixel in an image, where the z-value is the depth for each rendered pixel from the projection plane. More infoSee in G

docs.unity3d.com

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

반응형