Skip to content

Instantly share code, notes, and snippets.

@lyuma
Created June 5, 2018 17:43
Show Gist options
  • Save lyuma/c9cc4570300db0205c9538284d636879 to your computer and use it in GitHub Desktop.
Save lyuma/c9cc4570300db0205c9538284d636879 to your computer and use it in GitHub Desktop.
Patch that fixes an an afterimage issue in Cubed's Toon Lite shader
--- FlatLitToonCoreLite.cginc 2018-04-17 22:02:17.000000000 -0700
+++ FlatLitToonCoreLiteFixed.cginc 2018-06-05 02:57:26.000000000 -0700
@@ -29,7 +29,7 @@
float3 bitangentDir : TEXCOORD5;
float4 pos : CLIP_POS;
SHADOW_COORDS(6)
- UNITY_FOG_COORDS(7)
+ //UNITY_FOG_COORDS(7)
};
struct VertexOutput
@@ -44,7 +44,7 @@
float4 col : COLOR;
bool is_outline : IS_OUTLINE;
SHADOW_COORDS(6)
- UNITY_FOG_COORDS(7)
+ //UNITY_FOG_COORDS(7)
};
VertexOutput vert(appdata_full v) {
@@ -60,7 +60,7 @@
o.col = fixed4(1., 1., 1., 0.);
o.pos = UnityObjectToClipPos(v.vertex);
TRANSFER_SHADOW(o);
- UNITY_TRANSFER_FOG(o, o.pos);
+ //UNITY_TRANSFER_FOG(o, o.pos);
return o;
}
float grayscaleSH9(float3 normalDirection)
--- Flat Lit Toon Lite.shader 2018-04-17 22:02:17.000000000 -0700
+++ Flat Lit Toon Lite Fixed.shader 2018-06-05 02:56:37.000000000 -0700
@@ -1,4 +1,4 @@
-Shader "CubedParadox/Flat Lit Toon Lite"
+Shader "CubedParadox/Flat Lit Toon Lite Fixed"
{
Properties
{
@@ -35,7 +35,7 @@
ZWrite [_ZWrite]
CGPROGRAM
- #include "FlatLitToonCoreLite.cginc"
+ #include "FlatLitToonCoreLiteFixed.cginc"
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
#pragma vertex vert
#pragma fragment frag
@@ -43,8 +43,10 @@
#pragma only_renderers d3d11 glcore gles
#pragma target 4.0
#pragma multi_compile_fwdbase
- #pragma multi_compile_fog
+ //#pragma multi_compile_fog
float4 frag(VertexOutput i) : COLOR
{
@@ -89,7 +89,7 @@
float3 directContribution = saturate((1.0 - _Shadow) + floor(saturate(remappedLight) * 2.0));
float3 finalColor = emissive + (baseColor * lerp(indirectLighting, directLighting, directContribution));
fixed4 finalRGBA = fixed4(finalColor * lightmap, baseColor.a);
- UNITY_APPLY_FOG(i.fogCoord, finalRGBA);
+ //UNITY_APPLY_FOG(i.fogCoord, finalRGBA);
return finalRGBA;
}
ENDCG
@@ -104,7 +104,7 @@
CGPROGRAM
#pragma shader_feature NO_OUTLINE TINTED_OUTLINE COLORED_OUTLINE
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
- #include "FlatLitToonCore.cginc"
+ #include "FlatLitToonCoreLiteFixed.cginc" // Previously was Core not CoreLite???
#pragma vertex vert
#pragma fragment frag
@@ -139,34 +139,34 @@
float3 directContribution = floor(saturate(lightContribution) * 2.0);
float3 finalColor = baseColor * lerp(0, _LightColor0.rgb, saturate(directContribution + ((1 - _Shadow) * attenuation)));
fixed4 finalRGBA = fixed4(finalColor,1) * i.col;
- UNITY_APPLY_FOG(i.fogCoord, finalRGBA);
+ //UNITY_APPLY_FOG(i.fogCoord, finalRGBA);
return finalRGBA;
}
ENDCG
}
- Pass
- {
- Name "SHADOW_CASTER"
- Tags{ "LightMode" = "ShadowCaster" }
-
- ZWrite On ZTest LEqual
-
- CGPROGRAM
- #pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
- #include "FlatLitToonShadows.cginc"
-
- #pragma multi_compile_shadowcaster
- #pragma fragmentoption ARB_precision_hint_fastest
-
- #pragma only_renderers d3d11 glcore gles
- #pragma target 4.0
-
- #pragma vertex vertShadowCaster
- #pragma fragment fragShadowCaster
- ENDCG
- }
+// Pass
+// {
+// Name "SHADOW_CASTER"
+// Tags{ "LightMode" = "ShadowCaster" }
+//
+// ZWrite On ZTest LEqual
+//
+// CGPROGRAM
+// #pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
+// #include "FlatLitToonShadows.cginc"
+//
+// #pragma multi_compile_shadowcaster
+// #pragma fragmentoption ARB_precision_hint_fastest
+//
+// #pragma only_renderers d3d11 glcore gles
+// #pragma target 4.0
+//
+// #pragma vertex vertShadowCaster
+// #pragma fragment fragShadowCaster
+// ENDCG
+// }
}
FallBack "Diffuse"
- CustomEditor "FlatLitToonLiteInspector"
+ CustomEditor "FlatLitToonLiteFixedInspector"
}
\ No newline at end of file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment