Shader "Custom/toon"
     {
     Properties
     {

         _MainTex ("Albedo (RGB)", 2D) = "white" {}
         _Thickness ("thickness", Range(0, 1)) = 0.01
         _OutlineColor("outline color", Color) = (1,1,1,1)
         _OutlineTex("outlint texture", 2D) = "white"{}
     }
   	  SubShader
     {
    	 Tags { "RenderType"="Opaque" }
    	
        Cull Front
   
   //1pass 
     CGPROGRAM
     #pragma surface surf _NoLight vertex:vert noshadow noambient
     
     sampler2D _MainTex;
     sampler2D _OutlineTex;
     
     float _Thickness;
     float4 _OutlineColor;
     
     void vert(inout appdata_full v) 
     {   
   		 v.vertex.xyz = v.vertex.xyz + (v.normal.xyz * _Thickness);
     }
     	
        struct Input
     {
     	float4 color : COLOR;
     	float2 uv_OutlineTex;
     };
     
     void surf (Input IN, inout SurfaceOutput o)
     {   
    	fixed4 c = tex2D(_OutlineTex, IN.uv_OutlineTex);
     	
        o.Emission = c.rgb; 
     	o.Alpha = c.a;
     }
     
         float4 Lighting_NoLight(SurfaceOutput s, float3 lightDir, float atten) {
         float4 final;
         final.rgb = s.Emission * _OutlineColor;
         final.a = s.Alpha;
         return final;
     }
   	  ENDCG
     Cull Back
  
  //2pass
     CGPROGRAM
  	 #pragma surface surf Lambert
    	
        sampler2D _MainTex;
     	struct Input
     {
     float2 uv_MainTex;
     };

void surf(Input IN, inout SurfaceOutput o)
     {
     	fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
	    
        o.Albedo = c.rgb;
    	 o.Alpha = c.a;
     }
     ENDCG
     }
     FallBack "Diffuse"
     }

 

 

 

CGPROGRAM 2개 만들기 

컬 프론트로 앞 뒤 바꾸기  Cull Front 


커스텀 라이트 선언  #pragma surface surf _NoLight vertex:vert noshadow noambient 


버텍스 확장하기  

void vert(inout appdata_full v) {   
v.vertex.xyz = v.vertex.xyz + (v.normal.xyz * _Thickness);
 } 


커스텀 라이트 만들기 
 float4 Lighting_NoLight(SurfaceOutput s, float3 lightDir, float atten) 

{
 float4 final;
 final.rgb = s.Emission * _OutlineColor;
 final.a = s.Alpha;
 return final;
 } 

2번째 텍스쳐 바로 하기  Cull Back 

'게임 그래픽 프로그래밍' 카테고리의 다른 글

바디  (0) 2024.09.07
도끼  (0) 2024.09.06
셰이더: 2pass 두께, 색 변경  (0) 2024.09.05
셰이더: 골렘?  (1) 2024.09.04
셰이더: lerpf로 텍스쳐 섞기  (1) 2024.09.04

+ Recent posts