RampTexture

Shader "Custom/104_RampTexture"
{
Properties
{

_MainTex ("Albedo (RGB)", 2D) = "white" {}
_RampTex ("RampTex", 2D) = "white" {}

}

 
 

SubShader
{
Tags { "RenderType"="Opaque" }


CGPROGRAM
#pragma surface surf warp noambient

sampler2D _MainTex;
sampler2D _RampTex;

warp관련되서 계속 오류가 있었는데, 이유를 찾지못하다가
알고보니, 밑에 Lightingwarp Lightingtoon으로 해놨었음.
라이트이름만인줄알았지만 라이트설정을 받을때도 쓴다.

 

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;
}

 
 

float4 Lightingwarp( SurfaceOutput s,float3 lightDir, float atten)
{
float ndotl = dot(s.Normal,lightDir); //*0.5+0.5;
//float4 ramp = tex2D(_RampTex, float2(0.1,0.1));
float4 ramp = tex2D(_RampTex, float2
(ndotl,0.5));
return ramp;

}

 
 

ENDCG

}
FallBack "Diffuse"

 

 

유니티 쉐이더 스타트업 자료(정종필저)

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

기본적인 일반텍스쳐+노멀+아웃라인 적용 쉐이더  (0) 2020.10.06
Alpha  (0) 2020.05.24
OUTLINE  (0) 2020.05.17
프레넬 공식  (0) 2020.05.17
Lambert 공식  (0) 2020.05.17