Last active
March 7, 2023 10:49
-
-
Save ninpl/f58cbc84fcc30ae3a31225fdcba5b730 to your computer and use it in GitHub Desktop.
Shader Cell - Iluminación personalizada.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shader "NinePlus/CellShading" | |
{ | |
Properties | |
{ | |
_MainTex("Albedo (RGB)", 2D) = "white" {} | |
_RampTex("Ramp", 2D) = "white" {} | |
_CelShadingLevels("Cel Shading Levels", Range(0,15)) = 5 | |
} | |
SubShader | |
{ | |
Tags { "RenderType" = "Opaque" } | |
LOD 200 | |
CGPROGRAM | |
// En lugar de Standart, apunta a una funcion llamada LightingToon() | |
#pragma surface surf Toon | |
#pragma target 3.0 | |
sampler2D _MainTex; | |
sampler2D _RampTex; | |
float _CelShadingLevels; | |
struct Input | |
{ | |
float2 uv_MainTex; | |
}; | |
void surf(Input IN, inout SurfaceOutput o) | |
{ | |
o.Albedo = tex2D(_MainTex, IN.uv_MainTex).rgb; | |
} | |
half4 LightingToon(SurfaceOutput s, half3 lightDir, half atten) | |
{ | |
half NdotL = dot(s.Normal, lightDir); | |
// Ajustar el nivel de iluminacion | |
half cel = floor(NdotL * _CelShadingLevels) / (_CelShadingLevels - 0.5); | |
half4 c; | |
c.rgb = s.Albedo * _LightColor0.rgb * (cel * atten * 1); | |
c.a = s.Alpha; | |
return c; | |
} | |
ENDCG | |
} | |
FallBack "Diffuse" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment