카테고리 없음

셰이더: 줄무늬 홀로그램

101won 2024. 9. 4. 22:44

> input구조체
https://docs.unity3d.com/Manual/SL-SurfaceShaders.html

 

Unity - Manual: Writing Surface Shaders

Surface Shaders and rendering paths Writing Surface Shaders In the Built-in Render PipelineA series of operations that take the contents of a Scene, and displays them on a screen. Unity lets you choose from pre-built render pipelines, or write your own. Mo

docs.unity3d.com

 

> frac: 소수점 부분의 0~0.999까지 반복

 

Shader "Custom/holo"
{
    Properties
    {
       _MainTex ("Albedo (RGB)", 2D) = "white" {}
       _Color("Color", Color) = (1,1,1,1)
       // _Speed("Speed", Range(1.5)) = 1
    }
    SubShader
    {
        Tags { "RenderType"="Transparent" "Queue" ="Transparent"}

        CGPROGRAM
        #pragma surface surf Lambert alpha:fade
        #pragma target 3.0

        sampler2D _MainTex;
        float4 _Color;

        struct Input
        {
            float2 uv_MainTex;
            float3 viewDir;
            float3 worldPos;
        };

        void surf (Input IN, inout SurfaceOutput o)
        {
            fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
            o.Albedo = 0;

            //프레넬 n dot v
           float rim = saturate(dot(o.Normal, IN.viewDir));
           float reverseRim = pow(1-rim,1);
            
          // o.Emission = _Color.rgb;
           o.Alpha = reverseRim;//  * abs(sin(_Time.y* 10)); // 일정한 속도로 깜빡이기 // 시간 * 속도

           o.Emission = pow(frac(IN.worldPos.g * 10 - _Time.y), 30); // 프랙을 시간에 따라 이동 시킴
           //   o.Alpha = reverseRim;

        }
        ENDCG
    }
    FallBack "Diffuse"
}