스토리지

[5.3] UV 본문

Unity/Shader

[5.3] UV

ljw4104 2021. 5. 3. 16:04

색상정보를 저장하고 있는 테이블이다.

UV데이터가 없는 텍스쳐는 그냥 메모리에 올라가 있는 색 없는 텍스쳐에 불과하다.

그래서 변수 형식도 sample2D이다.


U, V값 따로 움직임 / U, V값이 동시에 움직임

Shader "Custom/Test"
{
    Properties
    {
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        _V ("V Value", Range(-1,1)) = 0 
        _U ("U Value", Range(-1,1)) = 0
        _UV ("UV Value", Range(-1,1)) = 0
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 200

        CGPROGRAM
        // Physically based Standard lighting model, and enable shadows on all light types
        #pragma surface surf Standard fullforwardshadows

        sampler2D _MainTex;
        float _V;
        float _U;
        float _UV;

        struct Input
        {
            float2 uv_MainTex;
        };

        void surf (Input IN, inout SurfaceOutputStandard o)
        {
            // Albedo comes from a texture tinted by color
            fixed4 c = tex2D (_MainTex, IN.uv_MainTex + _UV);
            o.Emission = c.rgb;
        }
        ENDCG
    }
    FallBack "Diffuse"
}

'Unity > Shader' 카테고리의 다른 글

[5.3] 불 이펙트 만들기  (0) 2021.05.03
[5.3] UV _Time  (0) 2021.05.03
[5.3] Shader 연습 1  (0) 2021.05.03
[5.3] Shader, Texture 받아오기  (0) 2021.05.03
[5.3] ShaderLab  (0) 2021.05.03
Comments