Unity Shader Study05 : saturate (value)

//lightDir : 빛의 방향, atten : attanuation (감쇠)의 줄인말 라이트의 거리별 감쇠 현상
//ndotl이라는 float변수를 만들고 노멀 벡터와 라이트 벡터를 내적(dot)연산 해주는 함수를 가동해서 값을 넣습니다.버텍스에서 노말값을 평범하게 받아서 들어가
//있는 상태이기 때문에 s.Normal이라고 제대로 노멀값이 들어오게 됩니다. 원래는 float ndot1으로 해야 됨니다.
//현재의 내적 연산값 dot은 -1에서 1의 범위 를 나타냅니다.
##@!@! 중요 !!!! //saturate (value) : 0~1로 모두 잘라냅니다.
//max (0,value) : 0이나 값중 큰값을 보냅니다.
Shader "Custom/Shader08_CustomLight" {
Properties {
_MainTex ("Albedo (RGB)", 2D) = "white" {}
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
#pragma surface surf Test noambient
// Use shader model 3.0 target, to get nicer looking lighting
#pragma target 3.0
sampler2D _MainTex;
struct Input {
float2 uv_MainTex;
};
// Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
// See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
// #pragma instancing_options assumeuniformscaling
UNITY_INSTANCING_CBUFFER_START(Props)
// put more per-instance properties here
UNITY_INSTANCING_CBUFFER_END
void surf (Input IN, inout SurfaceOutputStandard o) {
// Albedo comes from a texture tinted by color
fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
o.Albedo = c.rgb;
o.Alpha = c.a;
}
float4 LightingTest(SrfaceOutput s, float3 lightDir, float atten) {
return float4(1, 0, 0, 1);
}
ENDCG
}
FallBack "Diffuse"
댓글
댓글 쓰기