-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
50 changed files
with
1,538 additions
and
67 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using Anatawa12.AvatarOptimizer.API; | ||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
namespace Anatawa12.AvatarOptimizer.APIInternal; | ||
|
||
// Unity builtin "Standard" shader | ||
// https://github.com/TwoTailsGames/Unity-Built-in-Shaders/blob/master/DefaultResourcesExtra/Standard.shader | ||
[InitializeOnLoad] | ||
class StandardShaderInformation : ShaderInformation | ||
{ | ||
static StandardShaderInformation() | ||
{ | ||
Register(); | ||
} | ||
|
||
private static void Register() | ||
{ | ||
var information = new StandardShaderInformation(); | ||
if (!GlobalObjectId.TryParse("GlobalObjectId_V1-4-0000000000000000f000000000000000-46-0", out var id)) return; | ||
var shader = GlobalObjectId.GlobalObjectIdentifierToObjectSlow(id) as Shader; | ||
if (shader == null) return; | ||
ShaderInformationRegistry.RegisterShaderInformation(shader, information); | ||
} | ||
|
||
public override ShaderInformationKind SupportedInformationKind => | ||
ShaderInformationKind.VertexIndexUsage | ShaderInformationKind.TextureAndUVUsage; | ||
public override void GetMaterialInformation(MaterialInformationCallback matInfo) | ||
{ | ||
var mainTexST = matInfo.GetVector("_MainTex_ST"); | ||
Matrix2x3? mainTexSTMat = mainTexST is { } st ? Matrix2x3.NewScaleOffset(st) : null; | ||
var mainTexSTMatParallex = mainTexSTMat; | ||
if (matInfo.IsShaderKeywordEnabled("_PARALLAXMAP") != false) | ||
mainTexSTMat = null; | ||
|
||
matInfo.RegisterTextureUVUsage("_ParallaxMap", "_ParallaxMap", UsingUVChannels.UV0, mainTexSTMatParallex); | ||
|
||
matInfo.RegisterTextureUVUsage("_MainTex", "_MainTex", UsingUVChannels.UV0, mainTexSTMat); | ||
matInfo.RegisterTextureUVUsage("_MetallicGlossMap", "_MetallicGlossMap", UsingUVChannels.UV0, mainTexSTMat); | ||
matInfo.RegisterTextureUVUsage("_BumpMap", "_BumpMap", UsingUVChannels.UV0, mainTexSTMat); | ||
matInfo.RegisterTextureUVUsage("_OcclusionMap", "_OcclusionMap", UsingUVChannels.UV0, mainTexSTMat); | ||
matInfo.RegisterTextureUVUsage("_EmissionMap", "_EmissionMap", UsingUVChannels.UV0, mainTexSTMat); | ||
matInfo.RegisterTextureUVUsage("_DetailMask", "_DetailMask", UsingUVChannels.UV0, mainTexSTMat); | ||
|
||
var detailMapST = matInfo.GetVector("_DetailAlbedoMap_ST"); | ||
Matrix2x3? detailMapSTMat = detailMapST is { } st2 ? Matrix2x3.NewScaleOffset(st2) : null; | ||
|
||
if (matInfo.IsShaderKeywordEnabled("_PARALLAXMAP") != false) | ||
detailMapSTMat = null; | ||
|
||
var detailMapUV = matInfo.GetFloat("_UVSec") switch | ||
{ | ||
null => UsingUVChannels.UV0 | UsingUVChannels.UV1, | ||
0 => UsingUVChannels.UV0, | ||
_ => UsingUVChannels.UV1, | ||
}; | ||
|
||
matInfo.RegisterTextureUVUsage("_DetailAlbedoMap", "_DetailAlbedoMap", detailMapUV, detailMapSTMat); | ||
matInfo.RegisterTextureUVUsage("_DetailNormalMap", "_DetailNormalMap", detailMapUV, detailMapSTMat); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
using Anatawa12.AvatarOptimizer.API; | ||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
namespace Anatawa12.AvatarOptimizer.APIInternal; | ||
|
||
// VRChat SDK Mobile Shaders | ||
|
||
[InitializeOnLoad] | ||
class VRCSDKStandardLiteShaderInformation : ShaderInformation | ||
{ | ||
static VRCSDKStandardLiteShaderInformation() | ||
{ | ||
Register(); | ||
} | ||
|
||
private static void Register() | ||
{ | ||
var information = new VRCSDKStandardLiteShaderInformation(); | ||
ShaderInformationRegistry.RegisterShaderInformationWithGUID("0b7113dea2069fc4e8943843eff19f70", information); | ||
} | ||
|
||
public override ShaderInformationKind SupportedInformationKind => | ||
ShaderInformationKind.VertexIndexUsage | ShaderInformationKind.TextureAndUVUsage; | ||
public override void GetMaterialInformation(MaterialInformationCallback matInfo) | ||
{ | ||
var mainTexST = matInfo.GetVector("_MainTex_ST"); | ||
Matrix2x3? mainTexSTMat = mainTexST is { } st ? Matrix2x3.NewScaleOffset(st) : null; | ||
|
||
matInfo.RegisterTextureUVUsage("_MetallicGlossMap", "_MetallicGlossMap", UsingUVChannels.UV0, mainTexSTMat); | ||
matInfo.RegisterTextureUVUsage("_MainTex", "_MainTex", UsingUVChannels.UV0, mainTexSTMat); | ||
matInfo.RegisterTextureUVUsage("_BumpMap", "_BumpMap", UsingUVChannels.UV0, mainTexSTMat); | ||
matInfo.RegisterTextureUVUsage("_OcclusionMap", "_OcclusionMap", UsingUVChannels.UV0, mainTexSTMat); | ||
matInfo.RegisterTextureUVUsage("_EmissionMap", "_EmissionMap", UsingUVChannels.UV0, mainTexSTMat); | ||
matInfo.RegisterTextureUVUsage("_DetailMask", "_DetailMask", UsingUVChannels.UV0, mainTexSTMat); | ||
|
||
var detailMapST = matInfo.GetVector("_DetailAlbedoMap_ST"); | ||
Matrix2x3? detailMapSTMat = detailMapST is { } st2 ? Matrix2x3.NewScaleOffset(st2) : null; | ||
matInfo.RegisterTextureUVUsage("_DetailAlbedoMap", "_DetailAlbedoMap", UsingUVChannels.UV0, mainTexSTMat); | ||
|
||
var detailMapUV = matInfo.GetFloat("_UVSec") switch | ||
{ | ||
null => UsingUVChannels.UV0 | UsingUVChannels.UV1, | ||
0 => UsingUVChannels.UV0, | ||
_ => UsingUVChannels.UV1, | ||
}; | ||
|
||
matInfo.RegisterTextureUVUsage("_DetailAlbedoMap", "_DetailAlbedoMap", detailMapUV, detailMapSTMat); | ||
matInfo.RegisterTextureUVUsage("_DetailNormalMap", "_DetailNormalMap", detailMapUV, detailMapSTMat); | ||
} | ||
} | ||
|
||
[InitializeOnLoad] | ||
class VRCSDKToonLitShaderInformation : ShaderInformation | ||
{ | ||
static VRCSDKToonLitShaderInformation() | ||
{ | ||
Register(); | ||
} | ||
|
||
private static void Register() | ||
{ | ||
var information = new VRCSDKToonLitShaderInformation(); | ||
ShaderInformationRegistry.RegisterShaderInformationWithGUID("affc81f3d164d734d8f13053effb1c5c", information); | ||
} | ||
|
||
public override ShaderInformationKind SupportedInformationKind => | ||
ShaderInformationKind.VertexIndexUsage | ShaderInformationKind.TextureAndUVUsage; | ||
public override void GetMaterialInformation(MaterialInformationCallback matInfo) | ||
{ | ||
var mainTexST = matInfo.GetVector("_MainTex_ST"); | ||
Matrix2x3? mainTexSTMat = mainTexST is { } st ? Matrix2x3.NewScaleOffset(st) : null; | ||
matInfo.RegisterTextureUVUsage("_MainTex", "_MainTex", UsingUVChannels.UV0, mainTexSTMat); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Oops, something went wrong.