public Shader GetShader(glTFMaterial material) { if (material != null) { if (material.extensions != null && material.extensions.KHR_materials_unlit != null) { // is unlit switch (material.alphaMode) { case "BLEND": return(UnlitTransparent); case "MASK": return(UnlitCutout); default: return(Unlit); // OPAQUE } } } if (m_context != null && m_context.MaterialHasVertexColor(material)) { return(VColor); } return(Default); }
public Shader GetShader(glTFMaterial material) { if (material == null) { return(Default); } if (material.extensions != null && material.extensions.KHR_materials_unlit != null) { var isWhite = material.pbrMetallicRoughness != null && IsWhite(material.pbrMetallicRoughness.baseColorFactor); var hasTexture = material.pbrMetallicRoughness != null && material.pbrMetallicRoughness.baseColorTexture != null; // is unlit switch (material.alphaMode) { case "BLEND": { if (hasTexture) { if (isWhite) { return(UnlitTransparent); } else { Debug.LogWarningFormat("{0}: shader has no color property", UnlitTexture.name); return(UnlitTransparent); } } else { Debug.LogWarningFormat("{0}: shader is opaque", UnlitColor.name); return(UnlitColor); } } case "MASK": { if (hasTexture) { if (isWhite) { return(UnlitCutout); } else { Debug.LogWarningFormat("{0}: shader has no color property", UnlitCutout.name); return(UnlitCutout); } } else { Debug.LogErrorFormat("{0}: alphaMode='MASK' but no texture", UnlitTexture.name); return(UnlitCutout); } } default: { if (hasTexture) { if (isWhite) { return(UnlitTexture); } else { Debug.LogWarningFormat("{0}: shader has no color property", UnlitTexture.name); return(UnlitTexture); } } else { return(UnlitColor); } } } } // custom shader for vertex color if (m_context != null && m_context.MaterialHasVertexColor(material)) { return(VColor); } // standard return(Default); }