Skip to content

Commit

Permalink
Perfected new "toon" lighting model
Browse files Browse the repository at this point in the history
Fixed some issues related to higher toon contrasts. New "Toon" lighting model now looks just as good as the old model, but supports HDR colors better.
  • Loading branch information
morerokk committed Dec 24, 2019
1 parent 1847481 commit 8c2ed84
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Shader "NoeNoe/NoeNoe Toon Shader/Advanced/NoeNoe Toon Vertex Offset" {
_Intensity ("Intensity", Range(0, 10)) = 0.8
_Saturation ("Saturation", Range(0, 1)) = 0.65
_Exposure ("Exposure", Range(0, 1)) = 0.7
_ExposureContrast ("Exposure Toon Ramp Contrast", Range(0, 2)) = 1.15
_ExposureContrast ("Exposure Toon Ramp Contrast", Range(0, 4)) = 2
[Enum(Toon,0,PBR,1,Legacy Toon,2)] _LightingMode ("Lighting Mode", Float) = 0
_NormalMap ("Normal Map", 2D) = "bump" {}
[Enum(None,0,Metallic,1,Specular,2)] _MetallicMode("Metallic Mode", Float) = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Shader "NoeNoe/NoeNoe Toon Shader/Advanced/NoeNoe Toon Eye Tracking" {
_Intensity ("Intensity", Range(0, 10)) = 0.8
_Saturation ("Saturation", Range(0, 1)) = 0.65
_Exposure ("Exposure", Range(0, 1)) = 0.7
_ExposureContrast ("Exposure Toon Ramp Contrast", Range(0, 2)) = 1.15
_ExposureContrast ("Exposure Toon Ramp Contrast", Range(0, 4)) = 2
[Enum(Toon,0,PBR,1,Legacy Toon,2)] _LightingMode ("Lighting Mode", Float) = 0
_NormalMap ("Normal Map", 2D) = "bump" {}
[Toggle(_ALPHATEST_ON)] _Mode ("Cutout", Float) = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Shader "NoeNoe/NoeNoe Toon Shader/NoeNoe Toon Outline" {
_Intensity ("Intensity", Range(0, 10)) = 0.8
_Saturation ("Saturation", Range(0, 1)) = 0.65
_Exposure ("Exposure", Range(0, 1)) = 0.7
_ExposureContrast ("Exposure Toon Ramp Contrast", Range(0, 2)) = 1.15
_ExposureContrast ("Exposure Toon Ramp Contrast", Range(0, 4)) = 2
[Enum(Toon,0,PBR,1,Legacy Toon,2)] _LightingMode ("Lighting Mode", Float) = 0
_NormalMap ("Normal Map", 2D) = "bump" {}
[Enum(None,0,Metallic,1,Specular,2)] _MetallicMode("Metallic Mode", Float) = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Shader "NoeNoe/NoeNoe Toon Shader/NoeNoe Toon Ramp Masked" {
_Intensity ("Default Intensity", Range(0, 10)) = 0.8
_Saturation ("Default Saturation", Range(0, 1)) = 0.65
_Exposure ("Exposure", Range(0, 1)) = 0.7
_ExposureContrast ("Exposure Toon Ramp Contrast", Range(0, 2)) = 1.15
_ExposureContrast ("Exposure Toon Ramp Contrast", Range(0, 4)) = 2
[Enum(Toon,0,PBR,1,Legacy Toon,2)] _LightingMode ("Lighting Mode", Float) = 0
_NormalMap ("Normal Map", 2D) = "bump" {}
[Toggle(_ALPHATEST_ON)] _Mode ("Cutout", Float) = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Shader "NoeNoe/NoeNoe Toon Shader/NoeNoe Toon Transparent" {
_Intensity ("Intensity", Range(0, 10)) = 0.8
_Saturation ("Saturation", Range(0, 1)) = 0.65
_Exposure ("Exposure", Range(0, 1)) = 0.7
_ExposureContrast ("Exposure Toon Ramp Contrast", Range(0, 2)) = 1.15
_ExposureContrast ("Exposure Toon Ramp Contrast", Range(0, 4)) = 2
[Enum(Toon,0,PBR,1,Legacy Toon,2)] _LightingMode ("Lighting Mode", Float) = 0
_Opacity ("Opacity", Range(0, 1)) = 1
_NormalMap ("Normal Map", 2D) = "bump" {}
Expand Down
2 changes: 1 addition & 1 deletion NoeNoe Shaders/NoeNoe Toon Shader/NoeNoe Toon.shader
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Shader "NoeNoe/NoeNoe Toon Shader/NoeNoe Toon" {
_Intensity ("Intensity", Range(0, 10)) = 0.8
_Saturation ("Saturation", Range(0, 1)) = 0.65
_Exposure ("Exposure", Range(0, 1)) = 0.7
_ExposureContrast ("Exposure Toon Ramp Contrast", Range(0, 2)) = 1.15
_ExposureContrast ("Exposure Toon Ramp Contrast", Range(0, 4)) = 2
[Enum(Toon,0,PBR,1,Legacy Toon,2)] _LightingMode ("Lighting Mode", Float) = 0
_NormalMap ("Normal Map", 2D) = "bump" {}
[Toggle(_ALPHATEST_ON)] _Mode ("Cutout", Float) = 0
Expand Down
8 changes: 4 additions & 4 deletions NoeNoe Shaders/NoeNoe Toon Shader/NoeNoeToonEdits.cginc
Original file line number Diff line number Diff line change
Expand Up @@ -489,14 +489,14 @@ float4 frag(VertexOutput i, float facing : VFACE) : COLOR {
float3 finalColor = ((IntensityVar*FlatLighting*Diffuse) > 0.5 ? (1.0-(1.0-2.0*((IntensityVar*FlatLighting*Diffuse)-0.5))*(1.0-lerp(float3(node_424,node_424,node_424),StaticToonLighting,ToonContrast_var))) : (2.0*(IntensityVar*FlatLighting*Diffuse)*lerp(float3(node_424,node_424,node_424),StaticToonLighting,ToonContrast_var)));
#else
// Dim the toon ramp effect as the area gets brighter
float toonContrastModifier = saturate(Luminance(IntensityVar*saturate(FlatLighting)*Diffuse));
float3 toonContrastModifier = (IntensityVar*saturate(FlatLighting)*Diffuse);
toonContrastModifier = (1 - toonContrastModifier) * _ExposureContrast;
toonContrastModifier = smoothstep(0.5, 1, toonContrastModifier);

ToonContrast_var *= toonContrastModifier;
toonContrastModifier *= ToonContrast_var;

//float3 finalColor = ((IntensityVar*FlatLighting*Diffuse) < 0.5 ? (2.0*(IntensityVar*FlatLighting*Diffuse)*lerp(float3(node_424,node_424,node_424),StaticToonLighting,ToonContrast_var)) : (1.0-(1.0-2.0*((IntensityVar*FlatLighting*Diffuse)-0.5))*(1.0-lerp(float3(node_424,node_424,node_424),StaticToonLighting,ToonContrast_var))));
float3 finalColor = (2.0*(IntensityVar*FlatLighting*Diffuse)*lerp(float3(node_424,node_424,node_424),StaticToonLighting,ToonContrast_var));
float3 finalColor = 2 * (IntensityVar*FlatLighting*Diffuse);
finalColor *= lerp(float3(0.5, 0.5, 0.5), StaticToonLighting, toonContrastModifier);
#endif

#if defined(_LIGHTING_LEGACY_ON)
Expand Down

0 comments on commit 8c2ed84

Please sign in to comment.