새소식

그래픽

[Unity URP Shader] 텍스쳐 섞기

  • -

 

[출처] Unty Shader Training

https://youtu.be/mlNWoROvavY?si=7XpTECHR_CJ5u62d

 

 

 

     VertexOutput vert(VertexInput v)
     {
         VertexOutput o; 	 
         o.vertex = TransformObjectToHClip(v.vertex.xyz);    			     		 
     o.uv = v.uv.xy * _MainTex_ST.xy + _MainTex_ST.zw;
     o.uv2 = v.uv.xy * _MainTex02_ST.xy + _MainTex02_ST.zw;
         return o;    
     }   				 

    half4 frag(VertexOutput i) : SV_Target
    {   	
    
    //텍스쳐 uv에 따른 맞추는 과정
     float4 tex01 = _MainTex.Sample(sampler_MainTex, i.uv);
     float4 tex02 = _MainTex02.Sample(sampler_MainTex, i.uv2);   		
    float4 mask  = _MaskTex.Sample(sampler_MainTex, i.uv);

     //x값에 따른 블렌딩 처리
     //float4 color = lerp(tex01, tex02, i.uv.x);
     //mask 값에 따른 블렌딩
     float4 color = lerp(tex01, tex02, mask.r);

    //color = i.uv.y > 0.5 ? pow(i.uv.x, 2.2) : i.uv.x;

     return color;
     }

 

 

# mask의 r(0 ~ 1)값에 따른 보간

float4 color = lerp(tex01, tex02, mask.r);

 

 

Contents

아핫

땡큐하다