static int GetTag(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 3 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.Material), typeof(string), typeof(bool))) { UnityEngine.Material obj = (UnityEngine.Material)ToLua.ToObject(L, 1); string arg0 = ToLua.ToString(L, 2); bool arg1 = LuaDLL.lua_toboolean(L, 3); string o = obj.GetTag(arg0, arg1); LuaDLL.lua_pushstring(L, o); return(1); } else if (count == 4 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.Material), typeof(string), typeof(bool), typeof(string))) { UnityEngine.Material obj = (UnityEngine.Material)ToLua.ToObject(L, 1); string arg0 = ToLua.ToString(L, 2); bool arg1 = LuaDLL.lua_toboolean(L, 3); string arg2 = ToLua.ToString(L, 4); string o = obj.GetTag(arg0, arg1, arg2); LuaDLL.lua_pushstring(L, o); return(1); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.Material.GetTag")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int GetTag(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 3) { UnityEngine.Material obj = (UnityEngine.Material)ToLua.CheckObject <UnityEngine.Material>(L, 1); string arg0 = ToLua.CheckString(L, 2); bool arg1 = LuaDLL.luaL_checkboolean(L, 3); string o = obj.GetTag(arg0, arg1); LuaDLL.lua_pushstring(L, o); return(1); } else if (count == 4) { UnityEngine.Material obj = (UnityEngine.Material)ToLua.CheckObject <UnityEngine.Material>(L, 1); string arg0 = ToLua.CheckString(L, 2); bool arg1 = LuaDLL.luaL_checkboolean(L, 3); string arg2 = ToLua.CheckString(L, 4); string o = obj.GetTag(arg0, arg1, arg2); LuaDLL.lua_pushstring(L, o); return(1); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.Material.GetTag")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static public int GetTag(IntPtr l) { try{ if (matchType(l, 2, typeof(System.String), typeof(System.Boolean), typeof(System.String))) { UnityEngine.Material self = (UnityEngine.Material)checkSelf(l); System.String a1; checkType(l, 2, out a1); System.Boolean a2; checkType(l, 3, out a2); System.String a3; checkType(l, 4, out a3); System.String ret = self.GetTag(a1, a2, a3); pushValue(l, ret); return(1); } else if (matchType(l, 2, typeof(System.String), typeof(System.Boolean))) { UnityEngine.Material self = (UnityEngine.Material)checkSelf(l); System.String a1; checkType(l, 2, out a1); System.Boolean a2; checkType(l, 3, out a2); System.String ret = self.GetTag(a1, a2); pushValue(l, ret); return(1); } LuaDLL.luaL_error(l, "No matched override function to call"); return(0); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
public static string CheckMaterial(Material mat, BuildTarget buildTarget) { if (mat == null || mat.shader == null) { return null; } string shaderName = mat.shader.name; int lOD = ShaderUtil.GetLOD(mat.shader); bool flag = Array.Exists<string>(PerformanceChecks.kShadersWithMobileVariants, (string s) => s == shaderName); bool flag2 = PerformanceChecks.IsMobileBuildTarget(buildTarget); if (buildTarget == BuildTarget.Android && ShaderUtil.HasClip(mat.shader)) { return PerformanceChecks.FormattedTextContent("PerformanceChecks.ShaderWithClipAndroid", new object[0]); } if (!(mat.GetTag("PerformanceChecks", true).ToLower() == "false")) { if (flag) { if (flag2 && mat.HasProperty("_Color") && mat.GetColor("_Color") == new Color(1f, 1f, 1f, 1f)) { return PerformanceChecks.FormattedTextContent("PerformanceChecks.ShaderUsesWhiteColor", new object[] { "Mobile/" + shaderName }); } if (flag2 && shaderName.StartsWith("Particles/")) { return PerformanceChecks.FormattedTextContent("PerformanceChecks.ShaderHasMobileVariant", new object[] { "Mobile/" + shaderName }); } if (shaderName == "RenderFX/Skybox" && mat.HasProperty("_Tint") && mat.GetColor("_Tint") == new Color(0.5f, 0.5f, 0.5f, 0.5f)) { return PerformanceChecks.FormattedTextContent("PerformanceChecks.ShaderMobileSkybox", new object[] { "Mobile/Skybox" }); } } if (lOD >= 300 && flag2 && !shaderName.StartsWith("Mobile/")) { return PerformanceChecks.FormattedTextContent("PerformanceChecks.ShaderExpensive", new object[0]); } if (shaderName.Contains("VertexLit") && mat.HasProperty("_Emission")) { Color color = mat.GetColor("_Emission"); if (color.r >= 0.5f && color.g >= 0.5f && color.b >= 0.5f) { return PerformanceChecks.FormattedTextContent("PerformanceChecks.ShaderUseUnlit", new object[0]); } } if (mat.HasProperty("_BumpMap") && mat.GetTexture("_BumpMap") == null) { return PerformanceChecks.FormattedTextContent("PerformanceChecks.ShaderNoNormalMap", new object[0]); } } return null; }
private static MaterialEditor.PreviewType GetPreviewType(Material mat) { if ((UnityEngine.Object) mat == (UnityEngine.Object) null) return MaterialEditor.PreviewType.Mesh; string lower = mat.GetTag("PreviewType", false, string.Empty).ToLower(); if (lower == "plane") return MaterialEditor.PreviewType.Plane; return lower == "skybox" || (UnityEngine.Object) mat.shader != (UnityEngine.Object) null && mat.shader.name.Contains("Skybox") ? MaterialEditor.PreviewType.Skybox : MaterialEditor.PreviewType.Mesh; }
public static string CheckMaterial(Material mat, BuildTarget buildTarget) { // ISSUE: object of a compiler-generated type is created // ISSUE: variable of a compiler-generated type PerformanceChecks.\u003CCheckMaterial\u003Ec__AnonStoreyBE materialCAnonStoreyBe = new PerformanceChecks.\u003CCheckMaterial\u003Ec__AnonStoreyBE(); if ((UnityEngine.Object) mat == (UnityEngine.Object) null || (UnityEngine.Object) mat.shader == (UnityEngine.Object) null) return (string) null; // ISSUE: reference to a compiler-generated field materialCAnonStoreyBe.shaderName = mat.shader.name; int lod = ShaderUtil.GetLOD(mat.shader); // ISSUE: reference to a compiler-generated method bool flag1 = Array.Exists<string>(PerformanceChecks.kShadersWithMobileVariants, new Predicate<string>(materialCAnonStoreyBe.\u003C\u003Em__22D)); bool flag2 = PerformanceChecks.IsMobileBuildTarget(buildTarget); if (!(mat.GetTag("PerformanceChecks", true).ToLower() == "false")) { if (flag1) { if (flag2 && mat.HasProperty("_Color") && mat.GetColor("_Color") == new Color(1f, 1f, 1f, 1f)) { // ISSUE: reference to a compiler-generated field return PerformanceChecks.FormattedTextContent("Shader is using white color which does nothing; Consider using {0} shader for performance.", (object) ("Mobile/" + materialCAnonStoreyBe.shaderName)); } // ISSUE: reference to a compiler-generated field if (flag2 && materialCAnonStoreyBe.shaderName.StartsWith("Particles/")) { // ISSUE: reference to a compiler-generated field return PerformanceChecks.FormattedTextContent("Consider using {0} shader on this platform for performance.", (object) ("Mobile/" + materialCAnonStoreyBe.shaderName)); } // ISSUE: reference to a compiler-generated field if (materialCAnonStoreyBe.shaderName == "RenderFX/Skybox" && mat.HasProperty("_Tint") && mat.GetColor("_Tint") == new Color(0.5f, 0.5f, 0.5f, 0.5f)) return PerformanceChecks.FormattedTextContent("Skybox shader is using gray color which does nothing; Consider using {0} shader for performance.", (object) "Mobile/Skybox"); } // ISSUE: reference to a compiler-generated field if (lod >= 300 && flag2 && !materialCAnonStoreyBe.shaderName.StartsWith("Mobile/")) return PerformanceChecks.FormattedTextContent("Shader might be expensive on this platform. Consider switching to a simpler shader; look under Mobile shaders."); // ISSUE: reference to a compiler-generated field if (materialCAnonStoreyBe.shaderName.Contains("VertexLit") && mat.HasProperty("_Emission")) { Color color = mat.GetColor("_Emission"); if ((double) color.r >= 0.5 && (double) color.g >= 0.5 && (double) color.b >= 0.5) return PerformanceChecks.FormattedTextContent("Looks like you're using VertexLit shader to simulate an unlit object (white emissive). Use one of Unlit shaders instead for performance."); } if (mat.HasProperty("_BumpMap") && (UnityEngine.Object) mat.GetTexture("_BumpMap") == (UnityEngine.Object) null) return PerformanceChecks.FormattedTextContent("Normal mapped shader without a normal map. Consider using a non-normal mapped shader for performance."); } return (string) null; }
/// <summary> /// Applies alpha mode and cutoff /// </summary> /// <param name="uMaterial">Source Unity Material</param> /// <param name="material">glTF material to apply settings on</param> protected static void SetAlphaModeAndCutoff(UnityEngine.Material uMaterial, Material material) { switch (uMaterial.GetTag("RenderType", false, "")) { case "TransparentCutout": if (uMaterial.HasProperty(k_Cutoff)) { material.alphaCutoff = uMaterial.GetFloat(k_Cutoff); } material.alphaModeEnum = Material.AlphaMode.MASK; break; case "Transparent": case "Fade": material.alphaModeEnum = Material.AlphaMode.BLEND; break; default: material.alphaModeEnum = Material.AlphaMode.OPAQUE; break; } }
static public int GetTag(IntPtr l) { try { int argc = LuaDLL.lua_gettop(l); if (argc == 3) { UnityEngine.Material self = (UnityEngine.Material)checkSelf(l); System.String a1; checkType(l, 2, out a1); System.Boolean a2; checkType(l, 3, out a2); var ret = self.GetTag(a1, a2); pushValue(l, true); pushValue(l, ret); return(2); } else if (argc == 4) { UnityEngine.Material self = (UnityEngine.Material)checkSelf(l); System.String a1; checkType(l, 2, out a1); System.Boolean a2; checkType(l, 3, out a2); System.String a3; checkType(l, 4, out a3); var ret = self.GetTag(a1, a2, a3); pushValue(l, true); pushValue(l, ret); return(2); } pushValue(l, false); LuaDLL.lua_pushstring(l, "No matched override function to call"); return(2); } catch (Exception e) { return(error(l, e)); } }
private MaterialId ExportMaterial(UnityEngine.Material materialObj) { MaterialId id = GetMaterialId(_root, materialObj); if (id != null) { return(id); } var material = new GLTF.Schema.Material(); if (ExportNames) { material.Name = materialObj.name; } if (materialObj.HasProperty("_Cutoff")) { material.AlphaCutoff = materialObj.GetFloat("_Cutoff"); } switch (materialObj.GetTag("RenderType", false, "")) { case "TransparentCutout": material.AlphaMode = AlphaMode.MASK; break; case "Transparent": material.AlphaMode = AlphaMode.BLEND; break; default: material.AlphaMode = AlphaMode.OPAQUE; break; } material.DoubleSided = materialObj.HasProperty("_Cull") && materialObj.GetInt("_Cull") == (float)UnityEngine.Rendering.CullMode.Off; if (materialObj.HasProperty("_EmissionColor")) { material.EmissiveFactor = materialObj.GetColor("_EmissionColor").ToNumericsColorRaw(); } if (materialObj.HasProperty("_EmissionMap")) { var emissionTex = materialObj.GetTexture("_EmissionMap"); if (emissionTex != null) { material.EmissiveTexture = ExportTextureInfo(emissionTex); ExportTextureTransform(material.EmissiveTexture, materialObj, "_EmissionMap"); } } if (materialObj.HasProperty("_BumpMap")) { var normalTex = materialObj.GetTexture("_BumpMap"); if (normalTex != null) { material.NormalTexture = ExportNormalTextureInfo(normalTex, materialObj); ExportTextureTransform(material.NormalTexture, materialObj, "_BumpMap"); } } if (materialObj.HasProperty("_OcclusionMap")) { var occTex = materialObj.GetTexture("_OcclusionMap"); if (occTex != null) { material.OcclusionTexture = ExportOcclusionTextureInfo(occTex, materialObj); ExportTextureTransform(material.OcclusionTexture, materialObj, "_OcclusionMap"); } } switch (materialObj.shader.name) { case "Standard": case "GLTF/GLTFStandard": material.PbrMetallicRoughness = ExportPBRMetallicRoughness(materialObj); break; case "GLTF/GLTFConstant": material.CommonConstant = ExportCommonConstant(materialObj); break; } _materials.Add(materialObj); id = new MaterialId { Id = _root.Materials.Count, Root = _root }; _root.Materials.Add(material); return(id); }
private static MaterialEditor.PreviewType GetPreviewType(Material mat) { if (mat == null) { return MaterialEditor.PreviewType.Mesh; } string a = mat.GetTag("PreviewType", false, string.Empty).ToLower(); if (a == "plane") { return MaterialEditor.PreviewType.Plane; } if (a == "skybox") { return MaterialEditor.PreviewType.Skybox; } if (mat.shader != null && mat.shader.name.Contains("Skybox")) { return MaterialEditor.PreviewType.Skybox; } return MaterialEditor.PreviewType.Mesh; }
static VrmLib.PBRMaterial ExportStandard(UnityEngine.Material src, GetOrCreateTextureDelegate map) { var material = new VrmLib.PBRMaterial(src.name) { }; switch (src.GetTag("RenderType", true)) { case "Transparent": material.AlphaMode = VrmLib.AlphaModeType.BLEND; break; case "TransparentCutout": material.AlphaMode = VrmLib.AlphaModeType.MASK; material.AlphaCutoff = src.GetFloat("_Cutoff"); break; default: material.AlphaMode = VrmLib.AlphaModeType.OPAQUE; break; } if (src.HasProperty("_Color")) { material.BaseColorFactor = src.color.linear.FromUnitySrgbToLinear(); } if (src.HasProperty("_MainTex")) { material.BaseColorTexture = map(src, src.GetTexture("_MainTex"), VrmLib.Texture.ColorSpaceTypes.Srgb, VrmLib.Texture.TextureTypes.Default); } if (src.HasProperty("_MetallicGlossMap")) { // float smoothness = 0.0f; // if (m.HasProperty("_GlossMapScale")) // { // smoothness = m.GetFloat("_GlossMapScale"); // } material.MetallicRoughnessTexture = map( src, src.GetTexture("_MetallicGlossMap"), VrmLib.Texture.ColorSpaceTypes.Linear, VrmLib.Texture.TextureTypes.MetallicRoughness)?.Texture; if (material.MetallicRoughnessTexture != null) { material.MetallicFactor = 1.0f; // Set 1.0f as hard-coded. See: https://github.com/vrm-c/UniVRM/issues/212. material.RoughnessFactor = 1.0f; } } if (material.MetallicRoughnessTexture == null) { if (src.HasProperty("_Metallic")) { material.MetallicFactor = src.GetFloat("_Metallic"); } if (src.HasProperty("_Glossiness")) { material.RoughnessFactor = 1.0f - src.GetFloat("_Glossiness"); } } if (src.HasProperty("_BumpMap")) { material.NormalTexture = map(src, src.GetTexture("_BumpMap"), VrmLib.Texture.ColorSpaceTypes.Linear, VrmLib.Texture.TextureTypes.NormalMap)?.Texture; if (src.HasProperty("_BumpScale")) { material.NormalTextureScale = src.GetFloat("_BumpScale"); } } if (src.HasProperty("_OcclusionMap")) { material.OcclusionTexture = map(src, src.GetTexture("_OcclusionMap"), VrmLib.Texture.ColorSpaceTypes.Linear, VrmLib.Texture.TextureTypes.Occlusion)?.Texture; if (src.HasProperty("_OcclusionStrength")) { material.OcclusionTextureStrength = src.GetFloat("_OcclusionStrength"); } } if (src.IsKeywordEnabled("_EMISSION")) { if (src.HasProperty("_EmissionColor")) { var color = src.GetColor("_EmissionColor"); if (color.maxColorComponent > 1) { color /= color.maxColorComponent; } material.EmissiveFactor = new System.Numerics.Vector3(color.r, color.g, color.b); } if (src.HasProperty("_EmissionMap")) { material.EmissiveTexture = map(src, src.GetTexture("_EmissionMap"), VrmLib.Texture.ColorSpaceTypes.Srgb, VrmLib.Texture.TextureTypes.Emissive)?.Texture; } } return(material); }
public override void OnInspectorGUI() { if (isVisible == false) return; targetMaterial = target as Material; keyWords = targetMaterial.shaderKeywords; float controlSize = 64; EditorGUIUtility.LookLikeControls(Screen.width - controlSize - 20); bFParameters = EditorGUILayout.Foldout(bFParameters, "Fragmentum Parameters"); if (bFParameters) { GUILayout.Space(5); ///////////////////////////////////////////////////////////////////////////////// SetTexture("_FragTex", TextureProperty("_FragTex", " Fragment Texture(R)", ShaderUtil.ShaderPropertyTexDim.TexDim2D)); EditorGUILayout.BeginHorizontal(); SetFloat("_FragTexStrength", RangeProperty("_FragTexStrength", " Fragment Texture Strength [" + GetFloat("_FragTexStrength", out hasMixedValue).ToString("F3") + "]", 0.0f, 1.0f)); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); SetFloat("_FragPow", RangeProperty("_FragPow", " Fragment Area Pow [" + GetFloat("_FragPow", out hasMixedValue).ToString("F3") + "]", 1.0f, 10.0f)); EditorGUILayout.EndHorizontal(); SetFloat("_DisAmount", FloatProperty("_DisAmount", " Displace Amount")); SetFloat("_FragmentScale", FloatProperty("_FragmentScale", " Fragment Scale")); //Lock if (keyWords.Contains("V_FR_ACTIVATOR_NONE") == false) { bool bLock = false; if (targetMaterial.GetFloat("_Lock") == 1) bLock = true; bLock = EditorGUILayout.Toggle(" Lock Displace", bLock); targetMaterial.SetFloat("_Lock", bLock ? 1 : 0); if (keyWords.Contains("V_FR_ACTIVATOR_PLANE")) { SetFloat("_DistanceToPlane", FloatProperty("_DistanceToPlane", " Distance To Activator")); } } //Rotation //Removed if (targetMaterial.GetTag("FragmentumTag", false).Contains("_DIS")) { SetTexture("_DissolveTex", TextureProperty("_DissolveTex", " Dissolve Texture(R)", ShaderUtil.ShaderPropertyTexDim.TexDim2D)); EditorGUILayout.BeginHorizontal(); SetFloat("_DissolveAmount", RangeProperty("_DissolveAmount", " Dissolve Amount [" + GetFloat("_DissolveAmount", out hasMixedValue).ToString("F3") + "]", 0.0f, 1.0f)); EditorGUILayout.EndHorizontal(); } GUILayout.Space(6); //Noise //Removed //Additional force //Removed //CS0414: disable if (hasMixedValue){} } CommonParameters(); }
private static PreviewType GetPreviewType(Material mat) { if (mat != null) { switch (mat.GetTag("PreviewType", false, string.Empty).ToLower()) { case "plane": return PreviewType.Plane; case "skybox": return PreviewType.Skybox; } if ((mat.shader != null) && mat.shader.name.Contains("Skybox")) { return PreviewType.Skybox; } } return PreviewType.Mesh; }
/// <summary> /// Converts a Unity material to a glTF material. /// </summary> /// <param name="uMaterial">Source material</param> /// <param name="material">Resulting material</param> /// <param name="gltf">Associated IGltfWriter. Is used for adding images and textures.</param> /// <param name="logger">Logger used for reporting</param> /// <returns>True if no errors occured, false otherwise</returns> internal static bool ConvertMaterial(UnityEngine.Material uMaterial, out Material material, IGltfWritable gltf, ICodeLogger logger) { var success = true; material = new Material { name = uMaterial.name, pbrMetallicRoughness = new PbrMetallicRoughness { metallicFactor = 0, roughnessFactor = 1.0f } }; switch (uMaterial.GetTag("RenderType", false, "")) { case "TransparentCutout": if (uMaterial.HasProperty(k_Cutoff)) { material.alphaCutoff = uMaterial.GetFloat(k_Cutoff); } material.alphaModeEnum = Material.AlphaMode.MASK; break; case "Transparent": case "Fade": material.alphaModeEnum = Material.AlphaMode.BLEND; break; default: material.alphaModeEnum = Material.AlphaMode.OPAQUE; break; } material.doubleSided = uMaterial.HasProperty(k_Cull) && uMaterial.GetInt(k_Cull) == (int)CullMode.Off; if (uMaterial.IsKeywordEnabled("_EMISSION")) { if (uMaterial.HasProperty(k_EmissionColor)) { material.emissive = uMaterial.GetColor(k_EmissionColor); } if (uMaterial.HasProperty(k_EmissionMap)) { // var emissionTex = uMaterial.GetTexture(k_EmissionMap); // // if (emissionTex != null) { // if(emissionTex is Texture2D) { // material.emissiveTexture = ExportTextureInfo(emissionTex, TextureMapType.Emission); // ExportTextureTransform(material.EmissiveTexture, uMaterial, "_EmissionMap"); // } else { // logger?.Error(LogCode.TextureInvalidType, "emission", material.name ); // success = false; // } // } } } if ( uMaterial.HasProperty(k_BumpMap) && (uMaterial.IsKeywordEnabled(Materials.Constants.kwNormalMap) || uMaterial.IsKeywordEnabled(k_KeywordBumpMap)) ) { var normalTex = uMaterial.GetTexture(k_BumpMap); if (normalTex != null) { if (normalTex is Texture2D) { material.normalTexture = ExportNormalTextureInfo(normalTex, TextureMapType.Bump, uMaterial, gltf); ExportTextureTransform(material.normalTexture, uMaterial, k_BumpMap, gltf); } else { logger?.Error(LogCode.TextureInvalidType, "normal", uMaterial.name); success = false; } } } if (uMaterial.HasProperty(k_OcclusionMap)) { var occTex = uMaterial.GetTexture(k_OcclusionMap); if (occTex != null) { // if(occTex is Texture2D) { // material.occlusionTexture = ExportOcclusionTextureInfo(occTex, TextureMapType.Occlusion, uMaterial); // ExportTextureTransform(material.OcclusionTexture, uMaterial, "_OcclusionMap"); // } else { // logger?.Error(LogCode.TextureInvalidType, "occlusion", material.name ); // success = false; // } } } if (IsUnlit(uMaterial)) { ExportUnlit(material, uMaterial, gltf, logger); } else if (IsPbrMetallicRoughness(uMaterial)) { success &= ExportPbrMetallicRoughness(uMaterial, out material.pbrMetallicRoughness, gltf, logger); } else if (IsPbrSpecularGlossiness(uMaterial)) { // ExportPBRSpecularGlossiness(material, uMaterial); } else if (uMaterial.HasProperty(k_BaseMap)) { var mainTex = uMaterial.GetTexture(k_BaseMap); material.pbrMetallicRoughness = new PbrMetallicRoughness { baseColor = uMaterial.HasProperty(k_BaseColor) ? uMaterial.GetColor(k_BaseColor) : Color.white, baseColorTexture = mainTex == null ? null : ExportTextureInfo(mainTex, TextureMapType.Main, gltf) }; } else if (uMaterial.HasProperty(k_ColorTexture)) { var mainTex = uMaterial.GetTexture(k_ColorTexture); material.pbrMetallicRoughness = new PbrMetallicRoughness { baseColor = uMaterial.HasProperty(k_BaseColor) ? uMaterial.GetColor(k_BaseColor) : Color.white, baseColorTexture = mainTex == null ? null : ExportTextureInfo(mainTex, TextureMapType.Main, gltf) }; } else if (uMaterial.HasProperty(k_MainTex)) //else export main texture { var mainTex = uMaterial.GetTexture(k_MainTex); if (mainTex != null) { material.pbrMetallicRoughness = new PbrMetallicRoughness { metallicFactor = 0, roughnessFactor = 1.0f, baseColorTexture = ExportTextureInfo(mainTex, TextureMapType.Main, gltf) }; // ExportTextureTransform(material.pbrMetallicRoughness.baseColorTexture, uMaterial, "_MainTex"); } if (uMaterial.HasProperty(k_TintColor)) { //particles use _TintColor instead of _Color material.pbrMetallicRoughness = material.pbrMetallicRoughness ?? new PbrMetallicRoughness { metallicFactor = 0, roughnessFactor = 1.0f }; material.pbrMetallicRoughness.baseColor = uMaterial.GetColor(k_TintColor); } material.doubleSided = true; } return(success); }
//--------------------------------------------------------------------------------------------------------------------------------------------------- private static bool ValveToStandardSingleMaterial( Material m, Shader destShaderStandard, Shader destShaderStandardSpecular ) { if ( m.shader.name.Equals( "Valve/vr_standard" ) ) { if ( ( m.GetTag( "OriginalShader", true ) != null ) && ( m.GetTag( "OriginalShader", true ).Length > 0 ) ) { Debug.Log( " Converting from \"" + m.shader.name + "\"-->\"" + m.GetTag( "OriginalShader", true ) + "\": " + m.name + "\n" ); m.shader = Shader.Find( m.GetTag( "OriginalShader", true ) ); return true; } else if ( m.GetInt( "_SpecularMode" ) == 2 ) { // Metallic specular Debug.Log( " Converting from \"" + m.shader.name + "\"-->\"" + destShaderStandard.name + "\": " + m.name + "\n" ); m.shader = destShaderStandard; return true; } else { // Regular specular Debug.Log( " Converting from \"" + m.shader.name + "\"-->\"" + destShaderStandardSpecular.name + "\": " + m.name + "\n" ); m.shader = destShaderStandardSpecular; return true; } } return false; }