|
|
|
Shader "Custom/20_Lambert_lim1" { Properties { _MainTex ("Albedo (RGB)", 2D) = "white" {} _RimColor ("RimColor", Color) = (1,1,1,1) _RimPower ("RimPower", Range(1,10)) = 3
}
|
|
SubShader { Tags { "RenderType"="Opaque" }
CGPROGRAM
#pragma surface surf Lambert noambient
sampler2D _MainTex;
struct Input { float2 uv_MainTex; float3 viewDir; // 버텍스가 카메라 방향을 보는 방향 };
|
|
SubShader { Tags { "RenderType"="Opaque" }
CGPROGRAM
#pragma surface surf Lambert noambient
sampler2D _MainTex; float4 _RimColor; float _RimPower;
struct Input { float2 uv_MainTex; float3 viewDir; // 버텍스가 카메라 방향을 보는 방향 };
|
|
void surf (Input IN, inout SurfaceOutput o) {
fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
float rim = dot(o.Normal, IN.viewDir);
o.Emission = pow(1- rim, 3);
o.Albedo = c.rgb; //0으로 놓고 하면 까만 초기 상태가 된다. o.Alpha = c.a; }
|
o.Emission = 1- rim 이렇게 하면 그래프로 보면 직각이된다.
그래서 pow(exponet, 지수)를 써서 그래프가 산모양으로 되게 만들어서 림 굵기를 얇게 하는것이다.
pow연산은 비교적 무겁다.
|
void surf (Input IN, inout SurfaceOutput o) {
fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
o.Albedo = 0;//0으로 놓고 하면 까만 초기 상태가 된다. float rim = dot(o.Normal, IN.viewDir); o.Emission = pow(1- rim, _RimPower)*_RimColor.rgb; o.Alpha = c.a; }
|