public JsonMaterial(Material mat, ResourceMapper resMap) { name = mat.name; //TODO: Further investigation shows that this is likely going to return -1 for all new materials. id = resMap.findMaterialId(mat); //exp.materials.findId(mat); renderQueue = mat.renderQueue; var path = AssetDatabase.GetAssetPath(mat); this.path = path; shader = mat.shader.name; supportedShader = isSupportedShaderName(shader); mainTexture = resMap.getTextureId(mat.mainTexture); mainTextureOffset = mat.mainTextureOffset; mainTextureScale = mat.mainTextureScale; color = getColor(mat, ParamNames.mainColor, Color.white); //mat.color; useNormalMap = mat.IsKeywordEnabled(Keywords.normalMap); //"_NORMALMAP"); useAlphaTest = mat.IsKeywordEnabled(Keywords.alphaTestOn); //"_ALPHATEST_ON"); useAlphaBlend = mat.IsKeywordEnabled(Keywords.alphaBlendOn); //"_ALPHABLEND_ON"); useAlphaPremultiply = mat.IsKeywordEnabled(Keywords.alphaPremultiplyOn); //"_ALPHAPREMULTIPLY_ON"); useEmission = mat.IsKeywordEnabled(Keywords.emission); //"_EMISSION"); useParallax = mat.IsKeywordEnabled(Keywords.parallaxMap); //"_PARALLAXMAP"); useDetailMap = mat.IsKeywordEnabled(Keywords.detailMulX2); //"_DETAIL_MULX2"); useMetallic = mat.IsKeywordEnabled(Keywords.metallicGlossMap); //"_METALLICGLOSSMAP"); useSpecular = mat.IsKeywordEnabled(Keywords.specGlossMap); //"_SPECCGLOSSMAP"); albedoTex = getTexId(mat, TexParamNames.main, resMap); specularTex = getTexId(mat, TexParamNames.specular, resMap); metallicTex = getTexId(mat, TexParamNames.metallic, resMap); normalMapTex = getTexId(mat, TexParamNames.normal, resMap); occlusionTex = getTexId(mat, TexParamNames.occlusion, resMap); parallaxTex = getTexId(mat, TexParamNames.parallax, resMap); emissionTex = getTexId(mat, TexParamNames.emission, resMap); detailMaskTex = getTexId(mat, TexParamNames.detailMask, resMap); detailAlbedoTex = getTexId(mat, TexParamNames.detailAlbedo, resMap); detailNormalMapTex = getTexId(mat, TexParamNames.detailNormal, resMap); detailAlbedoScale = getTextureScale(mat, TexParamNames.detailAlbedo); //mat.GetTextureScale(TexParamNames.detailAlbedo); detailAlbedoOffset = getTextureOffset(mat, TexParamNames.detailAlbedo); //mat.GetTextureOffset(TexParamNames.detailAlbedo); detailNormalMapScale = getFloat(mat, ParamNames.detailNormalMapScale, 1.0f); alphaCutoff = getFloat(mat, ParamNames.cutoff, 1.0f); smoothness = getFloat(mat, ParamNames.glossiness, 0.5f); smoothnessScale = getFloat(mat, ParamNames.glossinessScale, 1.0f); specularColor = getColor(mat, ParamNames.specularColor, Color.white); metallic = getFloat(mat, ParamNames.metallic, 0.5f); bumpScale = getFloat(mat, ParamNames.bumpScale, 1.0f); parallaxScale = getFloat(mat, ParamNames.parallax, 1.0f); occlusionStrength = getFloat(mat, ParamNames.occlusionStrength, 1.0f); emissionColor = getColor(mat, ParamNames.emissionColor, Color.black); detailMapScale = getFloat(mat, ParamNames.detailNormalMapScale, 1.0f); secondaryUv = getFloat(mat, ParamNames.secondaryUv, 1.0f); blendMode = Mathf.RoundToInt(getFloat(mat, ParamNames.blendMode, 0.0f)); smoothnessMapChannel = (int)getFloat(mat, ParamNames.smoothnessMapChannel, 0.0f); specularHighlights = getFloat(mat, ParamNames.specularHighlights, 1.0f); glossyReflections = getFloat(mat, ParamNames.glossyReflections, 1.0f); hasMetallic = mat.HasProperty(ParamNames.metallic) && mat.HasProperty(TexParamNames.metallic); hasSpecular = mat.HasProperty(TexParamNames.specular) && mat.HasProperty(ParamNames.specularColor); hasEmissionColor = mat.HasProperty(ParamNames.emissionColor) && (emissionColor.maxColorComponent > 0.01f); hasEmission = hasEmissionColor || ExportUtility.isValidId(emissionTex); //(emissionTex >= 0); }