끊어지는 음영
Unity3D/Shader 2020. 12. 21. 17:22반응형
Shader "Custom/VertexShader"
{
Properties{
_MainTex ("Main Texture", 2D) = "white"{}
_NormalLength ("Normal Length", Range(-0.1, 0.1)) = 0
}
SubShader
{
// cull front
// CGPROGRAM
// #pragma surface surf Nolight vertex:vert noshadow noambient
// float _NormalLength;
// void vert(inout appdata_full v){
// v.vertex.xyz = v.vertex.xyz + v.normal.xyz * _NormalLength;
// }
// struct Input{
// float4 color:COLOR;
// };
// void surf(Input i, inout SurfaceOutput o){
// }
// float4 LightingNolight (SurfaceOutput s, float3 lightDir, float attenuation){
// s.Emission = float3(1,0,0);
// return float4(s.Emission, 1);
// }
// ENDCG
cull back
CGPROGRAM
#pragma surface surf Toon noambient
sampler2D _MainTex;
struct Input{
float2 uv_MainTex;
};
void surf(Input i, inout SurfaceOutput o){
fixed4 c = tex2D(_MainTex, i.uv_MainTex);
o.Albedo = c.rgb;
o.Alpha = c.a;
}
float4 LightingToon(SurfaceOutput s, float3 lightDir, float attenuation){
float ndotl = dot(s.Normal, lightDir) * 0.5 + 0.5;
// if(ndotl > 0.5) ndotl = 1;
// else ndotl = 0.3;
//https://darkcatgame.tistory.com/14
ndotl *= 5;
ndotl = ceil(ndotl)/5;
float4 final;
//https://chulin28ho.tistory.com/401
// final.rgb = ndotl;//s.Albedo * ;//_LightColor0.rgb * attenuation;
//final.rgb = s.Albedo * ndotl * attenuation;// * _LightColor0.rgb;
final.rgb = s.Albedo * ndotl * _LightColor0.rgb;
final.a = s.Alpha;
final *= attenuation;
return final;
}
ENDCG
}
}
참고:
chulin28ho.tistory.com/401#footnote_link_401_1
반응형
'Unity3D > Shader' 카테고리의 다른 글
Unity Unlit Shader (vertex & fragment shader) (0) | 2020.12.22 |
---|---|
Diffuse Warping (0) | 2020.12.21 |
Vertex Shader (0) | 2020.12.21 |
Introduction to Shaders in Unity (0) | 2020.06.16 |
Unity Shader 기초강좌 링크 (0) | 2020.05.26 |