diff options
| author | tylermurphy534 <tylermurphy534@gmail.com> | 2022-11-06 15:12:42 -0500 |
|---|---|---|
| committer | tylermurphy534 <tylermurphy534@gmail.com> | 2022-11-06 15:12:42 -0500 |
| commit | eb84bb298d2b95aec7b2ae12cbf25ac64f25379a (patch) | |
| tree | efd616a157df06ab661c6d56651853431ac6b08b /VRCSDK3Worlds/Assets/MeshBaker/scripts/TextureBlenders/TextureBlenderLegacyDiffuse.cs | |
| download | unityprojects-eb84bb298d2b95aec7b2ae12cbf25ac64f25379a.tar.gz unityprojects-eb84bb298d2b95aec7b2ae12cbf25ac64f25379a.tar.bz2 unityprojects-eb84bb298d2b95aec7b2ae12cbf25ac64f25379a.zip | |
move to self host
Diffstat (limited to 'VRCSDK3Worlds/Assets/MeshBaker/scripts/TextureBlenders/TextureBlenderLegacyDiffuse.cs')
| -rw-r--r-- | VRCSDK3Worlds/Assets/MeshBaker/scripts/TextureBlenders/TextureBlenderLegacyDiffuse.cs | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/VRCSDK3Worlds/Assets/MeshBaker/scripts/TextureBlenders/TextureBlenderLegacyDiffuse.cs b/VRCSDK3Worlds/Assets/MeshBaker/scripts/TextureBlenders/TextureBlenderLegacyDiffuse.cs new file mode 100644 index 00000000..b1c3305c --- /dev/null +++ b/VRCSDK3Worlds/Assets/MeshBaker/scripts/TextureBlenders/TextureBlenderLegacyDiffuse.cs @@ -0,0 +1,71 @@ +using UnityEngine; +using System.Collections; +using System.Collections.Generic; +using System; + +namespace DigitalOpus.MB.Core +{ + public class TextureBlenderLegacyDiffuse : TextureBlender + { + bool doColor; + Color m_tintColor; + Color m_defaultTintColor = Color.white; + + public bool DoesShaderNameMatch(string shaderName) + { + if (shaderName.Equals ("Legacy Shaders/Diffuse")) { + return true; + } else if (shaderName.Equals ("Diffuse")) { + return true; + } + return false; + } + + public void OnBeforeTintTexture(Material sourceMat, string shaderTexturePropertyName) + { + if (shaderTexturePropertyName.EndsWith("_MainTex")) + { + doColor = true; + m_tintColor = sourceMat.GetColor("_Color"); + } else + { + doColor = false; + } + } + + public Color OnBlendTexturePixel(string propertyToDoshaderPropertyName, Color pixelColor) + { + if (doColor) + { + return new Color(pixelColor.r * m_tintColor.r, pixelColor.g * m_tintColor.g, pixelColor.b * m_tintColor.b, pixelColor.a * m_tintColor.a); + } + return pixelColor; + } + + public bool NonTexturePropertiesAreEqual(Material a, Material b) + { + return TextureBlenderFallback._compareColor(a, b, m_defaultTintColor, "_Color"); + } + + public void SetNonTexturePropertyValuesOnResultMaterial(Material resultMaterial) + { + resultMaterial.SetColor("_Color", Color.white); + } + + public Color GetColorIfNoTexture(Material m, ShaderTextureProperty texPropertyName) + { + if (texPropertyName.name.Equals("_MainTex")) + { + if (m != null && m.HasProperty("_Color")) + { + try + { //need try because can't garantee _Color is a color + return m.GetColor("_Color"); + } + catch (Exception) { } + } + } + return new Color(1,1,1,0); + } + } +} |