From 60e4231ff60852251d66e956ee8dbc095af6f63f Mon Sep 17 00:00:00 2001 From: Xiexe Date: Sat, 4 Jul 2020 21:07:53 -0400 Subject: [PATCH] v2.2.4 - Added: Halftone / Stippling effect options - Added: Matcap tint to diffuse - Fixed: Black vertex lights should no longer affect light direction. --- Editor/XSStyles.cs | 2 +- Editor/XSToonInspector.cs | 33 ++- Main/CGIncludes/XSDefines.cginc | 4 +- Main/CGIncludes/XSHelperFunctions.cginc | 90 ++++---- Main/CGIncludes/XSLighting.cginc | 20 +- Main/CGIncludes/XSLightingFunctions.cginc | 12 +- Main/Shaders/XSToon2.0 Cutout.shader | 9 +- .../XSToon2.0 CutoutA2C Outlined.shader | 9 +- Main/Shaders/XSToon2.0 CutoutA2C.shader | 9 +- Main/Shaders/XSToon2.0 CutoutA2CMasked.shader | 9 +- .../XSToon2.0 Dithered Outlined.shader | 9 +- Main/Shaders/XSToon2.0 Dithered.shader | 9 +- Main/Shaders/XSToon2.0 Fade.shader | 9 +- Main/Shaders/XSToon2.0 Outlined.shader | 9 +- ...parent RecieveShadowsFromUnderneath.shader | 198 ++++++++++++++++++ ...t RecieveShadowsFromUnderneath.shader.meta | 23 ++ Main/Shaders/XSToon2.0 Transparent.shader | 9 +- Main/Shaders/XSToon2.0.shader | 11 +- Main/Shaders/XSToonStenciler.shader | 2 +- 19 files changed, 389 insertions(+), 87 deletions(-) create mode 100644 Main/Shaders/XSToon2.0 Transparent RecieveShadowsFromUnderneath.shader create mode 100644 Main/Shaders/XSToon2.0 Transparent RecieveShadowsFromUnderneath.shader.meta diff --git a/Editor/XSStyles.cs b/Editor/XSStyles.cs index 0076320..ebca23c 100644 --- a/Editor/XSStyles.cs +++ b/Editor/XSStyles.cs @@ -6,7 +6,7 @@ [InitializeOnLoad] public class XSStyles : MonoBehaviour { - public static string ver = "2.2.3"; + public static string ver = "2.2.4"; //Help URLs public static string mainURL = "https://docs.google.com/document/d/1xJ4PID_nwqVm_UCsO2c2gEdiEoWoCGeM_GDK_L8-aZE/edit#bookmark=id.xh0nk8x7ws1g"; diff --git a/Editor/XSToonInspector.cs b/Editor/XSToonInspector.cs index ca55133..de96668 100644 --- a/Editor/XSToonInspector.cs +++ b/Editor/XSToonInspector.cs @@ -36,6 +36,7 @@ public class XSToonInspector : ShaderGUI MaterialProperty _MetallicGlossMap = null; MaterialProperty _BakedCubemap = null; MaterialProperty _Matcap = null; + MaterialProperty _MatcapTintToDiffuse = null; MaterialProperty _MatcapTint = null; MaterialProperty _ReflectivityMask = null; MaterialProperty _Metallic = null; @@ -79,9 +80,11 @@ public class XSToonInspector : ShaderGUI MaterialProperty _SSDistortion = null; MaterialProperty _SSPower = null; MaterialProperty _SSScale = null; - //MaterialProperty _HalftoneDotSize = null; - //MaterialProperty _HalftoneDotAmount = null; - //MaterialProperty _HalftoneLineAmount = null; + MaterialProperty _HalftoneDotSize = null; + MaterialProperty _HalftoneDotAmount = null; + MaterialProperty _HalftoneLineAmount = null; + MaterialProperty _HalftoneLineIntensity = null; + MaterialProperty _HalftoneType = null; MaterialProperty _UVSetAlbedo = null; MaterialProperty _UVSetNormal = null; MaterialProperty _UVSetDetNormal = null; @@ -122,6 +125,7 @@ public class XSToonInspector : ShaderGUI static bool showSpecular = false; static bool showReflection = false; static bool showRimlight = false; + static bool showHalftones = false; static bool showSubsurface = false; static bool showOutlines = false; static bool showEmission = false; @@ -177,6 +181,7 @@ public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] pro DrawReflectionsSettings(materialEditor, material); DrawEmissionSettings(materialEditor); DrawRimlightSettings(materialEditor); + DrawHalfToneSettings(materialEditor); DrawTransmissionSettings(materialEditor); DrawAdvancedSettings(materialEditor); DrawPatreonSettings(materialEditor); @@ -369,6 +374,7 @@ private void DrawReflectionsSettings(MaterialEditor materialEditor, Material mat XSStyles.SeparatorThin(); materialEditor.TexturePropertySingleLine(new GUIContent("Matcap", "Matcap Texture"), _Matcap, _MatcapTint); materialEditor.ShaderProperty(_Glossiness, new GUIContent("Matcap Blur", "Matcap blur, blurs the Matcap, set to 1 for full clarity"), 2); + materialEditor.ShaderProperty(_MatcapTintToDiffuse, new GUIContent("Tint To Diffuse", "Tints matcap to diffuse color."), 2); material.SetFloat("_Metallic", 0); material.SetFloat("_ClearCoat", 0); material.SetTexture("_MetallicGlossMap", null); @@ -423,6 +429,27 @@ private void DrawRimlightSettings(MaterialEditor materialEditor) } } + private void DrawHalfToneSettings(MaterialEditor materialEditor) + { + showHalftones = XSStyles.ShurikenFoldout("Halftones", showHalftones); + if (showHalftones) + { + materialEditor.ShaderProperty(_HalftoneType, new GUIContent("Halftone Style", "Controls where halftone and stippling effects are drawn.")); + + if(_HalftoneType.floatValue == 1 || _HalftoneType.floatValue == 2) + { + materialEditor.ShaderProperty(_HalftoneDotSize, new GUIContent("Stippling Scale", "How large should the stippling pattern be?")); + materialEditor.ShaderProperty(_HalftoneDotAmount, new GUIContent("Stippling Density", "How dense is the stippling effect?")); + } + + if(_HalftoneType.floatValue == 0 || _HalftoneType.floatValue == 2) + { + materialEditor.ShaderProperty(_HalftoneLineAmount, new GUIContent("Halftone Line Count", "How many lines should the halftone shadows have?")); + materialEditor.ShaderProperty(_HalftoneLineIntensity, new GUIContent("Halftone Line Intensity", "How dark should the halftone lines be?")); + } + } + } + private void DrawTransmissionSettings(MaterialEditor materialEditor) { showSubsurface = XSStyles.ShurikenFoldout("Transmission", showSubsurface); diff --git a/Main/CGIncludes/XSDefines.cginc b/Main/CGIncludes/XSDefines.cginc index 754238b..18b47f2 100644 --- a/Main/CGIncludes/XSDefines.cginc +++ b/Main/CGIncludes/XSDefines.cginc @@ -152,6 +152,7 @@ half4 _Color, _ShadowRim, _OutlineColor, _SSColor, _OcclusionColor, _EmissionColor, _MatcapTint, _RimColor; +half _MatcapTintToDiffuse; half _Cutoff; half _FadeDitherDistance; half _EmissionToDiffuse, _ScaleWithLightSensitivity; @@ -166,6 +167,7 @@ half _ShadowRimRange, _ShadowRimThreshold, _ShadowRimSharpness, _ShadowSharpness half _SSDistortion, _SSPower, _SSScale; half _OutlineWidth; +int _HalftoneType; int _FadeDither; int _SpecMode, _SpecularStyle, _ReflectionMode, _ReflectionBlendMode, _ClearCoat; int _TilingMode, _VertexColorAlbedo, _ScaleWithLight; @@ -175,7 +177,7 @@ int _UVSetAlbedo, _UVSetNormal, _UVSetDetNormal, _UVSetThickness, _UVSetOcclusion, _UVSetReflectivity, _UVSetEmission; -// half _HalftoneDotSize, _HalftoneDotAmount, _HalftoneLineAmount; +half _HalftoneDotSize, _HalftoneDotAmount, _HalftoneLineAmount, _HalftoneLineIntensity; //Defines for helper functions #define grayscaleVec float3(0.2125, 0.7154, 0.0721) \ No newline at end of file diff --git a/Main/CGIncludes/XSHelperFunctions.cginc b/Main/CGIncludes/XSHelperFunctions.cginc index 192045c..1b8c6d0 100644 --- a/Main/CGIncludes/XSHelperFunctions.cginc +++ b/Main/CGIncludes/XSHelperFunctions.cginc @@ -243,48 +243,50 @@ void calcAlpha(inout XSLighting i) } // //Halftone functions, finish implementing later.. Not correct right now. -// half2 rotateUV(half2 uv, half rotation) -// { -// half mid = 0.5; -// return half2( -// cos(rotation) * (uv.x - mid) + sin(rotation) * (uv.y - mid) + mid, -// cos(rotation) * (uv.y - mid) - sin(rotation) * (uv.x - mid) + mid -// ); -// } - -// half DotHalftone(XSLighting i, half scalar) //Scalar can be anything from attenuation to a dot product -// { -// bool inMirror = IsInMirror(); -// half2 uv = i.screenUV; -// #if UNITY_SINGLE_PASS_STEREO -// uv *= 2; -// #endif - -// half2 nearest = 2 * frac(100 * uv) - 1; -// half dist = length(nearest); -// half dotSize = 10 * scalar; -// half dotMask = step(dotSize, dist); - -// return dotMask; -// } - -// half LineHalftone(XSLighting i, half scalar) -// { -// // #if defined(DIRECTIONAL) -// // scalar = saturate(scalar + ((1-i.attenuation) * 0.2)); -// // #endif -// bool inMirror = IsInMirror(); -// half2 uv = i.screenUV; -// uv = rotateUV(uv, -0.785398); -// #if UNITY_SINGLE_PASS_STEREO -// _HalftoneLineAmount = _HalftoneLineAmount * 2; - -// #endif -// uv.x = sin(uv.x * _HalftoneLineAmount); - -// half2 steppedUV = smoothstep(0,0.2,uv.x); -// half lineMask = steppedUV * 0.2 * scalar; - -// return saturate(lineMask); -// } +float2 SphereUV( float3 coords /*viewDir?*/) +{ + float3 nc = normalize(coords); + float lat = acos(nc.y); + float lon = atan2(nc.z, nc.x); + float2 coord = 1.0 - (float2(lon, lat) * float2(1.0/UNITY_PI, 1.0/UNITY_PI)); + return (coord + float4(0, 1-unity_StereoEyeIndex,1,1.0).xy) * float4(0, 1-unity_StereoEyeIndex,1,1.0).zw; +} + +half2 rotateUV(half2 uv, half rotation) +{ + half mid = 0.5; + return half2( + cos(rotation) * (uv.x - mid) + sin(rotation) * (uv.y - mid) + mid, + cos(rotation) * (uv.y - mid) - sin(rotation) * (uv.x - mid) + mid + ); +} + +half DotHalftone(XSLighting i, half scalar) //Scalar can be anything from attenuation to a dot product +{ + bool inMirror = IsInMirror(); + half2 uv = SphereUV(calcViewDir(i.worldPos)); + uv.xy *= _HalftoneDotAmount; + half2 nearest = 2 * frac(100 * uv) - 1; + half dist = length(nearest); + half dotSize = 100 * _HalftoneDotSize * scalar; + half dotMask = step(dotSize, dist); + + return lerp(1, 1-dotMask, smoothstep(0, 0.4, 1/distance(i.worldPos, _WorldSpaceCameraPos)));; +} + +half LineHalftone(XSLighting i, half scalar) +{ + // #if defined(DIRECTIONAL) + // scalar = saturate(scalar + ((1-i.attenuation) * 0.2)); + // #endif + bool inMirror = IsInMirror(); + half2 uv = SphereUV(calcViewDir(i.worldPos)); + uv = rotateUV(uv, -0.785398); + uv.x = sin(uv.x * _HalftoneLineAmount * scalar); + + half2 steppedUV = smoothstep(0,0.2,uv.x); + half lineMask = lerp(1, steppedUV, smoothstep(0, 0.4, 1/distance(i.worldPos, _WorldSpaceCameraPos))); + + return saturate(lineMask); +} // \ No newline at end of file diff --git a/Main/CGIncludes/XSLighting.cginc b/Main/CGIncludes/XSLighting.cginc index 2bc71e1..98b969c 100644 --- a/Main/CGIncludes/XSLighting.cginc +++ b/Main/CGIncludes/XSLighting.cginc @@ -50,6 +50,23 @@ half4 BRDF_XSLighting(XSLighting i) half4 occlusion = lerp(_OcclusionColor, 1, i.occlusion.r); half4 outlineColor = calcOutlineColor(i, d, indirectDiffuse, lightCol); + half lineHalftone = 0; + half stippling = 0; + bool usingLineHalftone = 0; + if(_HalftoneType == 0 || _HalftoneType == 2) + { + lineHalftone = lerp(1, LineHalftone(i, 1), 1-saturate(dot(shadowRim * ramp, grayscaleVec))); + usingLineHalftone = 1; + } + + if(_HalftoneType == 1 || _HalftoneType == 2) + { + stippling = DotHalftone(i, saturate(dot(directSpecular + rimLight + directSpecular, grayscaleVec))) * saturate(dot(shadowRim * ramp, grayscaleVec)); + directSpecular *= stippling; + indirectSpecular *= lerp(0.5, 1, stippling); // Don't want these to go completely black, looks weird + rimLight *= stippling; + } + half4 col; col = diffuse * shadowRim; calcReflectionBlending(i, col, indirectSpecular.xyzz); @@ -59,6 +76,7 @@ half4 BRDF_XSLighting(XSLighting i) calcClearcoat(col, i, d, untouchedNormal, indirectDiffuse, lightCol, viewDir, lightDir, ramp); col += calcEmission(i, lightAvg); - float4 finalColor = lerp(col, outlineColor, i.isOutline); + float4 finalColor = lerp(col, outlineColor, i.isOutline) * lerp(1, lineHalftone, _HalftoneLineIntensity * usingLineHalftone); + //finalColor = lerp(finalColor, stippling, 0.9999); return finalColor; } \ No newline at end of file diff --git a/Main/CGIncludes/XSLightingFunctions.cginc b/Main/CGIncludes/XSLightingFunctions.cginc index 284a609..a4edc82 100644 --- a/Main/CGIncludes/XSLightingFunctions.cginc +++ b/Main/CGIncludes/XSLightingFunctions.cginc @@ -55,10 +55,10 @@ half3 getVertexLightsDir(XSLighting i, half4 vertexLightAtten) half3 dirZ = toLightZ - i.worldPos; half3 dirW = toLightW - i.worldPos; - dirX *= length(toLightX) * vertexLightAtten.x; - dirY *= length(toLightY) * vertexLightAtten.y; - dirZ *= length(toLightZ) * vertexLightAtten.z; - dirW *= length(toLightW) * vertexLightAtten.w; + dirX *= length(toLightX) * vertexLightAtten.x * unity_LightColor[0]; + dirY *= length(toLightY) * vertexLightAtten.y * unity_LightColor[1]; + dirZ *= length(toLightZ) * vertexLightAtten.z * unity_LightColor[2]; + dirW *= length(toLightW) * vertexLightAtten.w * unity_LightColor[3]; half3 dir = (dirX + dirY + dirZ + dirW) / 4; return dir; @@ -263,6 +263,8 @@ half3 calcIndirectSpecular(XSLighting i, DotProducts d, half4 metallicSmoothness { spec *= (indirectLight + (_LightColor0 * i.attenuation) * 0.5); } + + spec *= lerp(1, i.diffuseColor, _MatcapTintToDiffuse); } spec = lerp(spec, spec * ramp, metallicSmoothness.w); // should only not see shadows on a perfect mirror. return spec; @@ -296,7 +298,7 @@ half4 calcRamp(XSLighting i, DotProducts d) half3 calcIndirectDiffuse(XSLighting i) {// We don't care about anything other than the color from probes for toon lighting. - half3 indirectDiffuse = ShadeSH9(float4(0,1,0,1));//half3(unity_SHAr.w, unity_SHAg.w, unity_SHAb.w); + half3 indirectDiffuse = ShadeSH9(float4(0,0.5,0,1));//half3(unity_SHAr.w, unity_SHAg.w, unity_SHAb.w); return indirectDiffuse; } diff --git a/Main/Shaders/XSToon2.0 Cutout.shader b/Main/Shaders/XSToon2.0 Cutout.shader index 72406be..147bb9b 100644 --- a/Main/Shaders/XSToon2.0 Cutout.shader +++ b/Main/Shaders/XSToon2.0 Cutout.shader @@ -24,6 +24,7 @@ _BakedCubemap("Baked Cubemap", CUBE) = "black" {} _Matcap("Matcap", 2D) = "black" {} [HDR]_MatcapTint("Matcap Tint", Color) = (1,1,1,1) + _MatcapTintToDiffuse("Matcap Tint To Diffuse", Range(0,1)) = 0 _ReflectivityMask("Reflection Mask" , 2D) = "white" {} _Metallic("Metallic", Range(0,1)) = 0 _Glossiness("Smoothness", Range(0,1)) = 0 @@ -79,9 +80,11 @@ _SSPower("Subsurface Power", Range(0,3)) = 1 _SSScale("Subsurface Scale", Range(0,3)) = 1 - _HalftoneDotSize("Halftone Dot Size", Float) = 1.7 - _HalftoneDotAmount("Halftone Dot Amount", Float) = 50 - _HalftoneLineAmount("Halftone Line Amount", Float) = 150 + [Enum(Shadows, 0, Highlights, 1, Shadows And Highlights, 2, Off, 3)] _HalftoneType("Halftones Type", Int) = 3 + _HalftoneDotSize("Halftone Dot Size", Float) = 0.5 + _HalftoneDotAmount("Halftone Dot Amount", Float) = 5 + _HalftoneLineAmount("Halftone Line Amount", Float) = 2000 + _HalftoneLineIntensity("Halftone Line Intensity", Range(0,1)) = 1 [Enum(UV1,0,UV2,1)] _UVSetAlbedo("Albedo UVs", Int) = 0 [Enum(UV1,0,UV2,1)] _UVSetNormal("Normal Map UVs", Int) = 0 diff --git a/Main/Shaders/XSToon2.0 CutoutA2C Outlined.shader b/Main/Shaders/XSToon2.0 CutoutA2C Outlined.shader index b00fd5f..9a559e3 100644 --- a/Main/Shaders/XSToon2.0 CutoutA2C Outlined.shader +++ b/Main/Shaders/XSToon2.0 CutoutA2C Outlined.shader @@ -24,6 +24,7 @@ _BakedCubemap("Baked Cubemap", CUBE) = "black" {} _Matcap("Matcap", 2D) = "black" {} [HDR]_MatcapTint("Matcap Tint", Color) = (1,1,1,1) + _MatcapTintToDiffuse("Matcap Tint To Diffuse", Range(0,1)) = 0 _ReflectivityMask("Reflection Mask" , 2D) = "white" {} _Metallic("Metallic", Range(0,1)) = 0 _Glossiness("Smoothness", Range(0,1)) = 0 @@ -79,9 +80,11 @@ _SSPower("Subsurface Power", Range(0,3)) = 1 _SSScale("Subsurface Scale", Range(0,3)) = 1 - _HalftoneDotSize("Halftone Dot Size", Float) = 1.7 - _HalftoneDotAmount("Halftone Dot Amount", Float) = 50 - _HalftoneLineAmount("Halftone Line Amount", Float) = 150 + [Enum(Shadows, 0, Highlights, 1, Shadows And Highlights, 2, Off, 3)] _HalftoneType("Halftones Type", Int) = 3 + _HalftoneDotSize("Halftone Dot Size", Float) = 0.5 + _HalftoneDotAmount("Halftone Dot Amount", Float) = 5 + _HalftoneLineAmount("Halftone Line Amount", Float) = 2000 + _HalftoneLineIntensity("Halftone Line Intensity", Range(0,1)) = 1 [Enum(UV1,0,UV2,1)] _UVSetAlbedo("Albedo UVs", Int) = 0 [Enum(UV1,0,UV2,1)] _UVSetNormal("Normal Map UVs", Int) = 0 diff --git a/Main/Shaders/XSToon2.0 CutoutA2C.shader b/Main/Shaders/XSToon2.0 CutoutA2C.shader index e5e107e..5ec47af 100644 --- a/Main/Shaders/XSToon2.0 CutoutA2C.shader +++ b/Main/Shaders/XSToon2.0 CutoutA2C.shader @@ -24,6 +24,7 @@ _BakedCubemap("Baked Cubemap", CUBE) = "black" {} _Matcap("Matcap", 2D) = "black" {} [HDR]_MatcapTint("Matcap Tint", Color) = (1,1,1,1) + _MatcapTintToDiffuse("Matcap Tint To Diffuse", Range(0,1)) = 0 _ReflectivityMask("Reflection Mask" , 2D) = "white" {} _Metallic("Metallic", Range(0,1)) = 0 _Glossiness("Smoothness", Range(0,1)) = 0 @@ -79,9 +80,11 @@ _SSPower("Subsurface Power", Range(0,3)) = 1 _SSScale("Subsurface Scale", Range(0,3)) = 1 - _HalftoneDotSize("Halftone Dot Size", Float) = 1.7 - _HalftoneDotAmount("Halftone Dot Amount", Float) = 50 - _HalftoneLineAmount("Halftone Line Amount", Float) = 150 + [Enum(Shadows, 0, Highlights, 1, Shadows And Highlights, 2, Off, 3)] _HalftoneType("Halftones Type", Int) = 3 + _HalftoneDotSize("Halftone Dot Size", Float) = 0.5 + _HalftoneDotAmount("Halftone Dot Amount", Float) = 5 + _HalftoneLineAmount("Halftone Line Amount", Float) = 2000 + _HalftoneLineIntensity("Halftone Line Intensity", Range(0,1)) = 1 [Enum(UV1,0,UV2,1)] _UVSetAlbedo("Albedo UVs", Int) = 0 [Enum(UV1,0,UV2,1)] _UVSetNormal("Normal Map UVs", Int) = 0 diff --git a/Main/Shaders/XSToon2.0 CutoutA2CMasked.shader b/Main/Shaders/XSToon2.0 CutoutA2CMasked.shader index 0bc02ad..c218c1e 100644 --- a/Main/Shaders/XSToon2.0 CutoutA2CMasked.shader +++ b/Main/Shaders/XSToon2.0 CutoutA2CMasked.shader @@ -25,6 +25,7 @@ _BakedCubemap("Baked Cubemap", CUBE) = "black" {} _Matcap("Matcap", 2D) = "black" {} [HDR]_MatcapTint("Matcap Tint", Color) = (1,1,1,1) + _MatcapTintToDiffuse("Matcap Tint To Diffuse", Range(0,1)) = 0 _ReflectivityMask("Reflection Mask" , 2D) = "white" {} _Metallic("Metallic", Range(0,1)) = 0 _Glossiness("Smoothness", Range(0,1)) = 0 @@ -80,9 +81,11 @@ _SSPower("Subsurface Power", Range(0,3)) = 1 _SSScale("Subsurface Scale", Range(0,3)) = 1 - _HalftoneDotSize("Halftone Dot Size", Float) = 1.7 - _HalftoneDotAmount("Halftone Dot Amount", Float) = 50 - _HalftoneLineAmount("Halftone Line Amount", Float) = 150 + [Enum(Shadows, 0, Highlights, 1, Shadows And Highlights, 2, Off, 3)] _HalftoneType("Halftones Type", Int) = 3 + _HalftoneDotSize("Halftone Dot Size", Float) = 0.5 + _HalftoneDotAmount("Halftone Dot Amount", Float) = 5 + _HalftoneLineAmount("Halftone Line Amount", Float) = 2000 + _HalftoneLineIntensity("Halftone Line Intensity", Range(0,1)) = 1 [Enum(UV1,0,UV2,1)] _UVSetAlbedo("Albedo UVs", Int) = 0 [Enum(UV1,0,UV2,1)] _UVSetNormal("Normal Map UVs", Int) = 0 diff --git a/Main/Shaders/XSToon2.0 Dithered Outlined.shader b/Main/Shaders/XSToon2.0 Dithered Outlined.shader index 63cdf41..92cff8c 100644 --- a/Main/Shaders/XSToon2.0 Dithered Outlined.shader +++ b/Main/Shaders/XSToon2.0 Dithered Outlined.shader @@ -28,6 +28,7 @@ _BakedCubemap("Baked Cubemap", CUBE) = "black" {} _Matcap("Matcap", 2D) = "black" {} [HDR]_MatcapTint("Matcap Tint", Color) = (1,1,1,1) + _MatcapTintToDiffuse("Matcap Tint To Diffuse", Range(0,1)) = 0 _ReflectivityMask("Reflection Mask" , 2D) = "white" {} _Metallic("Metallic", Range(0,1)) = 0 _Glossiness("Smoothness", Range(0,1)) = 0 @@ -83,9 +84,11 @@ _SSPower("Subsurface Power", Range(0,3)) = 1 _SSScale("Subsurface Scale", Range(0,3)) = 1 - _HalftoneDotSize("Halftone Dot Size", Float) = 1.7 - _HalftoneDotAmount("Halftone Dot Amount", Float) = 50 - _HalftoneLineAmount("Halftone Line Amount", Float) = 150 + [Enum(Shadows, 0, Highlights, 1, Shadows And Highlights, 2, Off, 3)] _HalftoneType("Halftones Type", Int) = 3 + _HalftoneDotSize("Halftone Dot Size", Float) = 0.5 + _HalftoneDotAmount("Halftone Dot Amount", Float) = 5 + _HalftoneLineAmount("Halftone Line Amount", Float) = 2000 + _HalftoneLineIntensity("Halftone Line Intensity", Range(0,1)) = 1 [Enum(UV1,0,UV2,1)] _UVSetAlbedo("Albedo UVs", Int) = 0 [Enum(UV1,0,UV2,1)] _UVSetNormal("Normal Map UVs", Int) = 0 diff --git a/Main/Shaders/XSToon2.0 Dithered.shader b/Main/Shaders/XSToon2.0 Dithered.shader index c9226a5..c9e73bf 100644 --- a/Main/Shaders/XSToon2.0 Dithered.shader +++ b/Main/Shaders/XSToon2.0 Dithered.shader @@ -28,6 +28,7 @@ _BakedCubemap("Baked Cubemap", CUBE) = "black" {} _Matcap("Matcap", 2D) = "black" {} [HDR]_MatcapTint("Matcap Tint", Color) = (1,1,1,1) + _MatcapTintToDiffuse("Matcap Tint To Diffuse", Range(0,1)) = 0 _ReflectivityMask("Reflection Mask" , 2D) = "white" {} _Metallic("Metallic", Range(0,1)) = 0 _Glossiness("Smoothness", Range(0,1)) = 0 @@ -83,9 +84,11 @@ _SSPower("Subsurface Power", Range(0,3)) = 1 _SSScale("Subsurface Scale", Range(0,3)) = 1 - _HalftoneDotSize("Halftone Dot Size", Float) = 1.7 - _HalftoneDotAmount("Halftone Dot Amount", Float) = 50 - _HalftoneLineAmount("Halftone Line Amount", Float) = 150 + [Enum(Shadows, 0, Highlights, 1, Shadows And Highlights, 2, Off, 3)] _HalftoneType("Halftones Type", Int) = 3 + _HalftoneDotSize("Halftone Dot Size", Float) = 0.5 + _HalftoneDotAmount("Halftone Dot Amount", Float) = 5 + _HalftoneLineAmount("Halftone Line Amount", Float) = 2000 + _HalftoneLineIntensity("Halftone Line Intensity", Range(0,1)) = 1 [Enum(UV1,0,UV2,1)] _UVSetAlbedo("Albedo UVs", Int) = 0 [Enum(UV1,0,UV2,1)] _UVSetNormal("Normal Map UVs", Int) = 0 diff --git a/Main/Shaders/XSToon2.0 Fade.shader b/Main/Shaders/XSToon2.0 Fade.shader index 2d2989b..17bfacc 100644 --- a/Main/Shaders/XSToon2.0 Fade.shader +++ b/Main/Shaders/XSToon2.0 Fade.shader @@ -24,6 +24,7 @@ _BakedCubemap("Baked Cubemap", CUBE) = "black" {} _Matcap("Matcap", 2D) = "black" {} [HDR]_MatcapTint("Matcap Tint", Color) = (1,1,1,1) + _MatcapTintToDiffuse("Matcap Tint To Diffuse", Range(0,1)) = 0 _ReflectivityMask("Reflection Mask" , 2D) = "white" {} _Metallic("Metallic", Range(0,1)) = 0 _Glossiness("Smoothness", Range(0,1)) = 0 @@ -79,9 +80,11 @@ _SSPower("Subsurface Power", Range(0,3)) = 1 _SSScale("Subsurface Scale", Range(0,3)) = 1 - _HalftoneDotSize("Halftone Dot Size", Float) = 1.7 - _HalftoneDotAmount("Halftone Dot Amount", Float) = 50 - _HalftoneLineAmount("Halftone Line Amount", Float) = 150 + [Enum(Shadows, 0, Highlights, 1, Shadows And Highlights, 2, Off, 3)] _HalftoneType("Halftones Type", Int) = 3 + _HalftoneDotSize("Halftone Dot Size", Float) = 0.5 + _HalftoneDotAmount("Halftone Dot Amount", Float) = 5 + _HalftoneLineAmount("Halftone Line Amount", Float) = 2000 + _HalftoneLineIntensity("Halftone Line Intensity", Range(0,1)) = 1 [Enum(UV1,0,UV2,1)] _UVSetAlbedo("Albedo UVs", Int) = 0 [Enum(UV1,0,UV2,1)] _UVSetNormal("Normal Map UVs", Int) = 0 diff --git a/Main/Shaders/XSToon2.0 Outlined.shader b/Main/Shaders/XSToon2.0 Outlined.shader index 44c022a..1f64094 100644 --- a/Main/Shaders/XSToon2.0 Outlined.shader +++ b/Main/Shaders/XSToon2.0 Outlined.shader @@ -24,6 +24,7 @@ _BakedCubemap("Baked Cubemap", CUBE) = "black" {} _Matcap("Matcap", 2D) = "black" {} [HDR]_MatcapTint("Matcap Tint", Color) = (1,1,1,1) + _MatcapTintToDiffuse("Matcap Tint To Diffuse", Range(0,1)) = 0 _ReflectivityMask("Reflection Mask" , 2D) = "white" {} _Metallic("Metallic", Range(0,1)) = 0 _Glossiness("Smoothness", Range(0,1)) = 0 @@ -79,9 +80,11 @@ _SSPower("Subsurface Power", Range(0,3)) = 1 _SSScale("Subsurface Scale", Range(0,3)) = 1 - _HalftoneDotSize("Halftone Dot Size", Float) = 1.7 - _HalftoneDotAmount("Halftone Dot Amount", Float) = 50 - _HalftoneLineAmount("Halftone Line Amount", Float) = 150 + [Enum(Shadows, 0, Highlights, 1, Shadows And Highlights, 2, Off, 3)] _HalftoneType("Halftones Type", Int) = 3 + _HalftoneDotSize("Halftone Dot Size", Float) = 0.5 + _HalftoneDotAmount("Halftone Dot Amount", Float) = 5 + _HalftoneLineAmount("Halftone Line Amount", Float) = 2000 + _HalftoneLineIntensity("Halftone Line Intensity", Range(0,1)) = 1 [Enum(UV1,0,UV2,1)] _UVSetAlbedo("Albedo UVs", Int) = 0 [Enum(UV1,0,UV2,1)] _UVSetNormal("Normal Map UVs", Int) = 0 diff --git a/Main/Shaders/XSToon2.0 Transparent RecieveShadowsFromUnderneath.shader b/Main/Shaders/XSToon2.0 Transparent RecieveShadowsFromUnderneath.shader new file mode 100644 index 0000000..d4cbba2 --- /dev/null +++ b/Main/Shaders/XSToon2.0 Transparent RecieveShadowsFromUnderneath.shader @@ -0,0 +1,198 @@ +Shader "Xiexe/Toon2.0/XSToon2.0_Transparent_ShadowFromUnderneath_Hack" +{ + Properties + { + [Enum(Off, 0, On, 1)] _VertexColorAlbedo ("Vertex Color Albedo", Int) = 0 + [Enum(Separated, 0, Merged, 1)] _TilingMode ("Tiling Mode", Int) = 0 + [Enum(Off,0,Front,1,Back,2)] _Culling ("Culling Mode", Int) = 2 + _MainTex("Texture", 2D) = "white" {} + _Saturation("Main Texture Saturation", Range(0,10)) = 1 + _Color("Color Tint", Color) = (1,1,1,1) + _Cutoff("Cutoff", Float) = 0.5 + + _BumpMap("Normal Map", 2D) = "bump" {} + _BumpScale("Normal Scale", Range(-2,2)) = 1 + + _DetailNormalMap("Detail Normal Map", 2D) = "bump" {} + _DetailMask("Detail Mask", 2D) = "white" {} + _DetailNormalMapScale("Detail Normal Scale", Range(-2,2)) = 1.0 + + [Enum(PBR(Unity Metallic Standard),0,Baked Cubemap,1,Matcap,2,Off,3)] _ReflectionMode ("Reflection Mode", Int) = 3 + [Enum(Disabled,0, Enabled, 1)]_ClearCoat("ClearCoat", Int) = 0 + [Enum(Additive,0,Multiply,1,Subtract,2)] _ReflectionBlendMode("Reflection Blend Mode", Int) = 0 + _MetallicGlossMap("Metallic", 2D) = "white" {} //Metallic, 0, 0, Smoothness + _BakedCubemap("Baked Cubemap", CUBE) = "black" {} + _Matcap("Matcap", 2D) = "black" {} + [HDR]_MatcapTint("Matcap Tint", Color) = (1,1,1,1) + _MatcapTintToDiffuse("Matcap Tint To Diffuse", Range(0,1)) = 0 + _ReflectivityMask("Reflection Mask" , 2D) = "white" {} + _Metallic("Metallic", Range(0,1)) = 0 + _Glossiness("Smoothness", Range(0,1)) = 0 + _Reflectivity("Reflectivity", Range(0,1)) = 1 + _ClearcoatStrength("Clearcoat Reflectivity", Range(0, 1)) = 1 + _ClearcoatSmoothness("Clearcoat Smoothness", Range(0, 1)) = 0.8 + + [Enum(Yes,0, No,1)] _ScaleWithLight("Emission Scale w/ Light", Int) = 1 + _EmissionMap("Emission Map", 2D) = "white" {} + [HDR]_EmissionColor("Emission Color", Color) = (0,0,0,0) + _EmissionToDiffuse("Emission Tint To Diffuse", Range(0,1)) = 0 + _ScaleWithLightSensitivity("Scaling Sensitivity", Range(0,1)) = 1 + + _RimColor("Rimlight Tint", Color) = (1,1,1,1) + _RimAlbedoTint("Rim Albedo Tint", Range(0,1)) = 0 + _RimCubemapTint("Rim Environment Tint", Range(0,1)) = 0 + _RimAttenEffect("Rim Attenuation Effect", Range(0,1)) = 1 + _RimIntensity("Rimlight Intensity", Float) = 0 + _RimRange("Rim Range", Range(0,1)) = 0.7 + _RimThreshold("Rim Threshold", Range(0, 1)) = 0.1 + _RimSharpness("Rim Sharpness", Range(0,1)) = 0.1 + + [Enum(Blinn Phong, 0, Anisotropic, 1, GGX, 2)]_SpecMode("Specular Mode", Int) = 0 + [Enum(Smooth, 0, Sharp, 1)]_SpecularStyle("Specular Style", Int) = 0 + _SpecularMap("Specular Map", 2D) = "white" {} + _SpecularIntensity("Specular Intensity", Float) = 0 + _SpecularArea("Specular Smoothness", Range(0,1)) = 0.5 + _AnisotropicAX("Anisotropic X", Range(0,1)) = 0.25 + _AnisotropicAY("Anisotripic Y", Range(0,1)) = 0.75 + _SpecularAlbedoTint("Specular Albedo Tint", Range(0,1)) = 1 + + _RampSelectionMask("Ramp Mask", 2D) = "black" {} + _Ramp("Shadow Ramp", 2D) = "white" {} + _ShadowSharpness("Received Shadow Sharpness", Range(0,1)) = 0.5 + _ShadowRim("Shadow Rim Tint", Color) = (1,1,1,1) + _ShadowRimRange("Shadow Rim Range", Range(0,1)) = 0.7 + _ShadowRimThreshold("Shadow Rim Threshold", Range(0, 1)) = 0.1 + _ShadowRimSharpness("Shadow Rim Sharpness", Range(0,1)) = 0.3 + _ShadowRimAlbedoTint("Shadow Rim Albedo Tint", Range(0, 1)) = 0 + + _OcclusionMap("Occlusion", 2D) = "white" {} + _OcclusionColor("Occlusion Color", Color) = (0,0,0,0) + + [Enum(Off, 0, On, 1)]_OutlineAlbedoTint("Outline Albedo Tint", Int) = 0 + [Enum(Lit, 0, Emissive, 1)]_OutlineLighting("Outline Lighting", Int) = 0 + _OutlineMask("Outline Mask", 2D) = "white" {} + _OutlineWidth("Outline Width", Range(0, 5)) = 1 + [HDR]_OutlineColor("Outline Color", Color) = (0,0,0,1) + + _ThicknessMap("Thickness Map", 2D) = "white" {} + _SSColor ("Subsurface Color", Color) = (0,0,0,0) + _SSDistortion("Normal Distortion", Range(0,3)) = 1 + _SSPower("Subsurface Power", Range(0,3)) = 1 + _SSScale("Subsurface Scale", Range(0,3)) = 1 + + [Enum(Shadows, 0, Highlights, 1, Shadows And Highlights, 2, Off, 3)] _HalftoneType("Halftones Type", Int) = 3 + _HalftoneDotSize("Halftone Dot Size", Float) = 0.5 + _HalftoneDotAmount("Halftone Dot Amount", Float) = 5 + _HalftoneLineAmount("Halftone Line Amount", Float) = 2000 + _HalftoneLineIntensity("Halftone Line Intensity", Range(0,1)) = 1 + + [Enum(UV1,0,UV2,1)] _UVSetAlbedo("Albedo UVs", Int) = 0 + [Enum(UV1,0,UV2,1)] _UVSetNormal("Normal Map UVs", Int) = 0 + [Enum(UV1,0,UV2,1)] _UVSetDetNormal("Detail Normal UVs", Int) = 0 + [Enum(UV1,0,UV2,1)] _UVSetDetMask("Detail Mask UVs", Int) = 0 + [Enum(UV1,0,UV2,1)] _UVSetMetallic("Metallic Map UVs", Int) = 0 + [Enum(UV1,0,UV2,1)] _UVSetSpecular("Specular Map UVs", Int) = 0 + [Enum(UV1,0,UV2,1)] _UVSetReflectivity("Reflection Mask UVs", Int) = 0 + [Enum(UV1,0,UV2,1)] _UVSetThickness("Thickness Map UVs", Int) = 0 + [Enum(UV1,0,UV2,1)] _UVSetOcclusion("Occlusion Map UVs", Int) = 0 + [Enum(UV1,0,UV2,1)] _UVSetEmission("Emission Map UVs", Int) = 0 + + [HideInInspector][Enum(Basic, 0, Advanced, 1)]_AdvMode("Shader Mode", Int) = 0 + [IntRange] _Stencil ("Stencil ID [0;255]", Range(0,255)) = 0 + [Enum(UnityEngine.Rendering.CompareFunction)] _StencilComp ("Stencil Comparison", Int) = 0 + [Enum(UnityEngine.Rendering.StencilOp)] _StencilOp ("Stencil Operation", Int) = 0 + } + + SubShader + { + Tags { "RenderType"="Transparent" "Queue"="AlphaTest+49" } + Cull [_Culling] + Stencil + { + Ref [_Stencil] + Comp [_StencilComp] + Pass [_StencilOp] + } + Blend SrcAlpha OneMinusSrcAlpha + ZWrite Off + Pass + { + Name "FORWARD" + Tags { "LightMode" = "ForwardBase" } + + CGPROGRAM + #pragma target 3.0 + #pragma vertex vert + #pragma fragment frag + + #pragma multi_compile _ VERTEXLIGHT_ON + #pragma multi_compile_fog + #pragma multi_compile_fwdbase + + #ifndef UNITY_PASS_FORWARDBASE + #define UNITY_PASS_FORWARDBASE + #endif + + #define Transparent + + #include "../CGIncludes/XSDefines.cginc" + #include "../CGIncludes/XSHelperFunctions.cginc" + #include "../CGIncludes/XSLightingFunctions.cginc" + #include "../CGIncludes/XSLighting.cginc" + #include "../CGIncludes/XSVert.cginc" + #include "../CGIncludes/XSGeom.cginc" + #include "../CGIncludes/XSFrag.cginc" + ENDCG + } + + Pass + { + Name "FWDADD" + Tags { "LightMode" = "ForwardAdd" } + Blend SrcAlpha One + + CGPROGRAM + #pragma target 3.0 + #pragma vertex vert + #pragma fragment frag + + #pragma multi_compile_fog + #pragma multi_compile_fwdadd_fullshadows + #ifndef UNITY_PASS_FORWARDADD + #define UNITY_PASS_FORWARDADD + #endif + #define Transparent + + #include "../CGIncludes/XSDefines.cginc" + #include "../CGIncludes/XSHelperFunctions.cginc" + #include "../CGIncludes/XSLightingFunctions.cginc" + #include "../CGIncludes/XSLighting.cginc" + #include "../CGIncludes/XSVert.cginc" + #include "../CGIncludes/XSGeom.cginc" + #include "../CGIncludes/XSFrag.cginc" + ENDCG + } + + // Pass + // { + // Name "ShadowCaster" + // Tags{ "LightMode" = "ShadowCaster" } + // ZWrite On ZTest LEqual + // CGPROGRAM + // #pragma vertex vertShadowCaster + // #pragma fragment fragShadowCaster + // #pragma target 3.0 + // #pragma multi_compile_shadowcaster + // #ifndef UNITY_PASS_SHADOWCASTER + // #define UNITY_PASS_SHADOWCASTER + // #endif + // #pragma skip_variants FOG_LINEAR FOG_EXP FOG_EXP2 + // #define Transparent + + // #include "../CGIncludes/XSShadowCaster.cginc" + // ENDCG + // } + } + Fallback "Transparent/Diffuse" + CustomEditor "XSToonInspector" +} diff --git a/Main/Shaders/XSToon2.0 Transparent RecieveShadowsFromUnderneath.shader.meta b/Main/Shaders/XSToon2.0 Transparent RecieveShadowsFromUnderneath.shader.meta new file mode 100644 index 0000000..5a140da --- /dev/null +++ b/Main/Shaders/XSToon2.0 Transparent RecieveShadowsFromUnderneath.shader.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: 62a1e86cebad79d4395e32051831724e +ShaderImporter: + externalObjects: {} + defaultTextures: + - _MainTex: {instanceID: 0} + - _BumpMap: {instanceID: 0} + - _DetailNormalMap: {instanceID: 0} + - _DetailMask: {instanceID: 0} + - _MetallicGlossMap: {instanceID: 0} + - _BakedCubemap: {instanceID: 0} + - _Matcap: {instanceID: 0} + - _ReflectivityMask: {instanceID: 0} + - _EmissionMap: {instanceID: 0} + - _SpecularMap: {instanceID: 0} + - _RampSelectionMask: {instanceID: 0} + - _Ramp: {instanceID: 0} + - _OcclusionMap: {instanceID: 0} + - _OutlineMask: {instanceID: 0} + - _ThicknessMap: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Main/Shaders/XSToon2.0 Transparent.shader b/Main/Shaders/XSToon2.0 Transparent.shader index 33d083d..a025d59 100644 --- a/Main/Shaders/XSToon2.0 Transparent.shader +++ b/Main/Shaders/XSToon2.0 Transparent.shader @@ -24,6 +24,7 @@ _BakedCubemap("Baked Cubemap", CUBE) = "black" {} _Matcap("Matcap", 2D) = "black" {} [HDR]_MatcapTint("Matcap Tint", Color) = (1,1,1,1) + _MatcapTintToDiffuse("Matcap Tint To Diffuse", Range(0,1)) = 0 _ReflectivityMask("Reflection Mask" , 2D) = "white" {} _Metallic("Metallic", Range(0,1)) = 0 _Glossiness("Smoothness", Range(0,1)) = 0 @@ -79,9 +80,11 @@ _SSPower("Subsurface Power", Range(0,3)) = 1 _SSScale("Subsurface Scale", Range(0,3)) = 1 - _HalftoneDotSize("Halftone Dot Size", Float) = 1.7 - _HalftoneDotAmount("Halftone Dot Amount", Float) = 50 - _HalftoneLineAmount("Halftone Line Amount", Float) = 150 + [Enum(Shadows, 0, Highlights, 1, Shadows And Highlights, 2, Off, 3)] _HalftoneType("Halftones Type", Int) = 3 + _HalftoneDotSize("Halftone Dot Size", Float) = 0.5 + _HalftoneDotAmount("Halftone Dot Amount", Float) = 5 + _HalftoneLineAmount("Halftone Line Amount", Float) = 2000 + _HalftoneLineIntensity("Halftone Line Intensity", Range(0,1)) = 1 [Enum(UV1,0,UV2,1)] _UVSetAlbedo("Albedo UVs", Int) = 0 [Enum(UV1,0,UV2,1)] _UVSetNormal("Normal Map UVs", Int) = 0 diff --git a/Main/Shaders/XSToon2.0.shader b/Main/Shaders/XSToon2.0.shader index 0989946..5a1fa5f 100644 --- a/Main/Shaders/XSToon2.0.shader +++ b/Main/Shaders/XSToon2.0.shader @@ -24,6 +24,7 @@ _BakedCubemap("Baked Cubemap", CUBE) = "black" {} _Matcap("Matcap", 2D) = "black" {} [HDR]_MatcapTint("Matcap Tint", Color) = (1,1,1,1) + _MatcapTintToDiffuse("Matcap Tint To Diffuse", Range(0,1)) = 0 _ReflectivityMask("Reflection Mask" , 2D) = "white" {} _Metallic("Metallic", Range(0,1)) = 0 _Glossiness("Smoothness", Range(0,1)) = 0 @@ -79,9 +80,11 @@ _SSPower("Subsurface Power", Range(0,3)) = 1 _SSScale("Subsurface Scale", Range(0,3)) = 1 - _HalftoneDotSize("Halftone Dot Size", Float) = 1.7 - _HalftoneDotAmount("Halftone Dot Amount", Float) = 50 - _HalftoneLineAmount("Halftone Line Amount", Float) = 150 + [Enum(Shadows, 0, Highlights, 1, Shadows And Highlights, 2, Off, 3)] _HalftoneType("Halftones Type", Int) = 3 + _HalftoneDotSize("Halftone Dot Size", Float) = 0.5 + _HalftoneDotAmount("Halftone Dot Amount", Float) = 5 + _HalftoneLineAmount("Halftone Line Amount", Float) = 2000 + _HalftoneLineIntensity("Halftone Line Intensity", Range(0,1)) = 1 [Enum(UV1,0,UV2,1)] _UVSetAlbedo("Albedo UVs", Int) = 0 [Enum(UV1,0,UV2,1)] _UVSetNormal("Normal Map UVs", Int) = 0 @@ -102,7 +105,7 @@ SubShader { - Tags { "RenderType"="Opaque" "Queue"="Geometry" } + Tags { "RenderType"="Opaque" "Queue"="Geometry" "DisableBatching"="true"} Cull [_Culling] Stencil { diff --git a/Main/Shaders/XSToonStenciler.shader b/Main/Shaders/XSToonStenciler.shader index f28624f..03e15cb 100644 --- a/Main/Shaders/XSToonStenciler.shader +++ b/Main/Shaders/XSToonStenciler.shader @@ -18,7 +18,7 @@ } SubShader { - Tags { "RenderType"="" "Queue" = "AlphaTest+1" } + Tags { "RenderType"="" "Queue" = "Geometry-1" } LOD 100 Cull [_Culling]