Skip to content

Commit

Permalink
Big Update - Read Below!
Browse files Browse the repository at this point in the history
-Poiyomi 7.3 and any others that used the shadowcaster include now have shadows decrypted correctly
-Support for Poiyomi 9.0 has been added, and is now easy to add support for future Poiyomi builds despite the shader name not including the version.
  • Loading branch information
MistressPlague committed Jun 1, 2024
1 parent dbf66a7 commit b245098
Showing 1 changed file with 14 additions and 21 deletions.
35 changes: 14 additions & 21 deletions Scripts/KannaProteccMaterial.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using UnityEditor;
using UnityEngine;
using Random = UnityEngine.Random;

Expand All @@ -22,6 +25,7 @@ public class KannaReplaceText
}

public string[] ShaderName_StartsWith;
public string[] FileContentsRegexMatch;

public KannaReplaceText UV;
public KannaReplaceText Vert;
Expand Down Expand Up @@ -108,7 +112,7 @@ public static string GenerateDecodeShader(KannaProteccData data, bool[] keys)

public static bool IsShaderSupported(Shader shader, out KannaDynamicShaderData shaderData)
{
shaderData = Shaders.FirstOrDefault(o => o.ShaderName_StartsWith.Any(p => shader.name.Replace("Hidden/Locked/", "").StartsWith(p)));
shaderData = Shaders.FirstOrDefault(o => o.ShaderName_StartsWith.Any(p => shader.name.Replace("Hidden/Locked/", "").StartsWith(p)) || (o.FileContentsRegexMatch?.Length > 0 && o.FileContentsRegexMatch.Any(p => Regex.IsMatch(File.ReadAllText(AssetDatabase.GetAssetPath(shader)), p))) );

if (shaderData == null)
{
Expand All @@ -126,26 +130,23 @@ public static bool IsShaderSupported(Shader shader, out KannaDynamicShaderData s

UV = new KannaDynamicShaderData.KannaReplaceText
{
TextToFind = new [] { "float2 uv3 : TEXCOORD3;" },
TextToFind = new [] { "float2 uv3 : TEXCOORD3;", "float2 uv3: TEXCOORD3;" },
TextToReplaceWith = "{OrigText}\r\nfloat3 uv6: TEXCOORD6;\r\nfloat3 uv7: TEXCOORD7;",
ApplyToIncludes = true,
ExcludeIncludes = new [] { "CGI_PoiShadowVert" }
},

Vert = new KannaDynamicShaderData.KannaReplaceText
{
TextToFind = new [] { "v2f vert(", "v2f vert (" },
TextToFind = new [] { "v2f vert(", "v2f vert (", "V2FShadow vertShadowCaster(" },
TextToReplaceWith = "#include \"KannaModelDecode.cginc\"\r\n{OrigText}",
ApplyToIncludes = true,
ExcludeIncludes = new [] { "CGI_PoiShadowVert" }
},

VertexSetup = new KannaDynamicShaderData.KannaReplaceText
{
TextToFind = new [] { "UNITY_SETUP_INSTANCE_ID(v);" },
TextToReplaceWith = "v.vertex = modelDecode(v.vertex, v.normal, v.uv6, v.uv7);\r\n{OrigText}",
ApplyToIncludes = true,
ExcludeIncludes = new [] { "CGI_PoiShadowVert" }
}
},

Expand All @@ -155,26 +156,23 @@ public static bool IsShaderSupported(Shader shader, out KannaDynamicShaderData s

UV = new KannaDynamicShaderData.KannaReplaceText
{
TextToFind = new [] { "float2 uv3 : TEXCOORD3;" },
TextToFind = new [] { "float2 uv3 : TEXCOORD3;", "float2 uv3: TEXCOORD3;" },
TextToReplaceWith = "{OrigText}\r\nfloat3 uv6: TEXCOORD6;\r\nfloat3 uv7: TEXCOORD7;",
ApplyToIncludes = true,
ExcludeIncludes = new [] { "CGI_PoiShadowVert" }
},

Vert = new KannaDynamicShaderData.KannaReplaceText
{
TextToFind = new [] { "v2f vert(", "v2f vert (" },
TextToFind = new [] { "v2f vert(", "v2f vert (", "V2FShadow vertShadowCaster(" },
TextToReplaceWith = "#include \"KannaModelDecode.cginc\"\r\n{OrigText}",
ApplyToIncludes = true,
ExcludeIncludes = new [] { "CGI_PoiShadowVert" }
},

VertexSetup = new KannaDynamicShaderData.KannaReplaceText
{
TextToFind = new [] { "UNITY_SETUP_INSTANCE_ID(v);" },
TextToReplaceWith = "v.vertex = modelDecode(v.vertex, v.normal, v.uv6, v.uv7);\r\n{OrigText}",
ApplyToIncludes = true,
ExcludeIncludes = new [] { "CGI_PoiShadowVert" }
}
},

Expand All @@ -184,55 +182,50 @@ public static bool IsShaderSupported(Shader shader, out KannaDynamicShaderData s

UV = new KannaDynamicShaderData.KannaReplaceText
{
TextToFind = new [] { "float2 uv3 : TEXCOORD3;" },
TextToFind = new [] { "float2 uv3 : TEXCOORD3;", "float2 uv3: TEXCOORD3;" },
TextToReplaceWith = "{OrigText}\r\nfloat3 uv6: TEXCOORD6;\r\nfloat3 uv7: TEXCOORD7;",
ApplyToIncludes = true,
ExcludeIncludes = new [] { "CGI_PoiShadowVert" }
},

Vert = new KannaDynamicShaderData.KannaReplaceText
{
TextToFind = new [] { "VertexOut vert(", "VertexOut vert (" },
TextToFind = new [] { "VertexOut vert(", "VertexOut vert (", "V2FShadow vertShadowCaster(" },
TextToReplaceWith = "#include \"KannaModelDecode.cginc\"\r\n{OrigText}",
ApplyToIncludes = true,
ExcludeIncludes = new [] { "CGI_PoiShadowVert" }
},

VertexSetup = new KannaDynamicShaderData.KannaReplaceText
{
TextToFind = new [] { "UNITY_SETUP_INSTANCE_ID(v);" },
TextToReplaceWith = "v.vertex = modelDecode(v.vertex, v.normal, v.uv6, v.uv7);\r\n{OrigText}",
ApplyToIncludes = true,
ExcludeIncludes = new [] { "CGI_PoiShadowVert" }
}
},

new KannaDynamicShaderData
{
ShaderName_StartsWith = new [] { ".poiyomi/Poiyomi 8.2", ".poiyomi/Old Versions/8.2" },
FileContentsRegexMatch = new [] { @"shader_master_label.*Poiyomi 8\.2", @"shader_master_label.*Poiyomi 9\.0" },

UV = new KannaDynamicShaderData.KannaReplaceText
{
TextToFind = new [] { "float2 uv3 : TEXCOORD3;" },
TextToFind = new [] { "float2 uv3 : TEXCOORD3;", "float2 uv3: TEXCOORD3;" },
TextToReplaceWith = "{OrigText}\r\nfloat3 uv6: TEXCOORD6;\r\nfloat3 uv7: TEXCOORD7;",
ApplyToIncludes = true,
ExcludeIncludes = new [] { "CGI_PoiShadowVert" }
},

Vert = new KannaDynamicShaderData.KannaReplaceText
{
TextToFind = new [] { "VertexOut vert(", "VertexOut vert (" },
TextToFind = new [] { "VertexOut vert(", "VertexOut vert (", "V2FShadow vertShadowCaster(" },
TextToReplaceWith = "#include \"KannaModelDecode.cginc\"\r\n{OrigText}",
ApplyToIncludes = true,
ExcludeIncludes = new [] { "CGI_PoiShadowVert" }
},

VertexSetup = new KannaDynamicShaderData.KannaReplaceText
{
TextToFind = new [] { "UNITY_SETUP_INSTANCE_ID(v);" },
TextToReplaceWith = "v.vertex = modelDecode(v.vertex, v.normal, v.uv6, v.uv7);\r\n{OrigText}",
ApplyToIncludes = true,
ExcludeIncludes = new [] { "CGI_PoiShadowVert" }
}
},

Expand Down

0 comments on commit b245098

Please sign in to comment.