티스토리 뷰

게임클라이언트 프로그래밍/Unity

Shader(홀로그램)

Game Client Lee Hwanguk 2023. 3. 16. 14:25
Shader "Custom/holo"
{
    Properties
    {
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        _HoloColor("holo color",Color)=(1,1,1,1) //color추가
        _BumpMap("BumpMap",2D) = "bump"{}
    }
    SubShader
    {
        Tags { "RenderType"="Transparent""Queue"="Transparent"} //"Transparent" } 반투명 옵션

        CGPROGRAM
        #pragma surface surf nolight noambient alpha:fade //alpha:fade 반투명 옵션

        #pragma target 3.0

        sampler2D _MainTex;
         sampler2D _BumpMap;
        float4 _HoloColor; //color추가

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

        void surf (Input IN, inout SurfaceOutput o)
        {
            //노멀맵적용
            float3 n = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
            o.Normal = n;

           //프레넬
            float ndotv = max(0,dot(o.Normal, IN.viewDir));
            float rim = pow(1 - ndotv,3); //프래넬 반전
            
            //움직이는 라인만들기
            rim += pow(frac(IN.worldPos.g * 10 - _Time.y), 30);
            //컬러 적용
            o.Emission = _HoloColor.rgb; //0~0.99 // _HoloColor;

            
            //알파
            //o.Alpha = rim;  // rim;
            o.Alpha = rim;
        }
        float4 Lightingnolight(SurfaceOutput s, float3 lightDir, float atten)
        {
            return float4(0, 0, 0, s.Alpha);
        }
        ENDCG
    }
    FallBack "Diffuse"
}

 

 

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/07   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
글 보관함