Notice
Recent Posts
Recent Comments
Link
스토리지
[5.6] Light 연산 연습 본문
Shader "Custom/Test"
{
Properties
{
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_BumpTex ("Albedo (RGB)", 2D) = "bump" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
CGPROGRAM
#pragma surface surf Test noambient
sampler2D _MainTex;
sampler2D _BumpTex;
struct Input
{
float2 uv_MainTex;
float2 uv_BumpTex;
};
void surf (Input IN, inout SurfaceOutput o)
{
fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
fixed4 n = tex2D (_BumpTex, IN.uv_BumpTex);
o.Albedo = c.rgb;
o.Normal = UnpackNormal(n);
o.Alpha = c.a;
}
float4 LightingTest(SurfaceOutput s, float3 lightDir, float atten)
{
//Lambert Light
//float ndotl = saturate(dot(s.Normal, lightDir));
//return ndotl;
//Half-Lambert
float ndotl = dot(s.Normal, lightDir) * 0.5 + 0.5;
float4 final;
final.rgb = ndotl * s.Albedo * _LightColor0.rgb * atten;
final.a = s.Alpha;
return final;
}
ENDCG
}
FallBack "Diffuse"
}
'Unity > Shader' 카테고리의 다른 글
[5.6] 홀로그램 만들기 (0) | 2021.05.06 |
---|---|
[5.6] Rim Light - 역광 (0) | 2021.05.06 |
[5.6] Light 연산 정리 (0) | 2021.05.06 |
[5.6] Light 연산 (Lambert, Half-Lambert) (0) | 2021.05.06 |
[5.6] Lightening 계산 (0) | 2021.05.06 |
Comments