/* * Uh, do we even need temporary object with all those fields? * Could just grab reflection probes themselves in this case... */ public JsonReflectionProbe(ReflectionProbe obj, ResourceMapper resMap) { backgroundColor = obj.backgroundColor; blendDistance = obj.blendDistance; boxProjection = obj.boxProjection; center = obj.center; size = obj.size; /*clearType = (obj.clearFlags == UnityEngine.Rendering.ReflectionProbeClearFlags.Skybox) ? * "skybox": "color";*/ clearType = obj.clearFlags.ToString(); cullingMask = obj.cullingMask; hdr = obj.hdr; intensity = obj.intensity; nearClipPlane = obj.nearClipPlane; farClipPlane = obj.farClipPlane; resolution = obj.resolution; mode = obj.mode.ToString(); //getModeString(obj.mode); refreshMode = obj.refreshMode.ToString(); //getModeString(obj.mode); var customCubemap = obj.customBakedTexture as Cubemap; var customTex2d = obj.customBakedTexture as Texture2D; customCubemapId = resMap.getCubemapId(customCubemap); customTex2dId = resMap.getTextureId(customTex2d); }
static ResId getTexId(Material mat, string texName, ResourceMapper resMap) { if (!mat.HasProperty(texName)) { return(ResId.invalid); } return(resMap.getTextureId(mat.GetTexture(texName))); }
public JsonTerrainDetailPrototype(DetailPrototype data_, ResourceMapper resMap) { data = data_; textureId = resMap.getTextureId(data.prototypeTexture); detailPrefabId = resMap.getRootPrefabId(data.prototype, true); detailPrefabObjectId = resMap.getPrefabObjectId(data.prototype, true); meshIdData = new MeshIdData(data.prototype, resMap); //meshId = resMap.getPrefabObjectId }
bool addTextureAsset(AssetInfo asset, bool showGui, Logger logger) { Logger.makeValid(ref logger); AssetDatabase.LoadAllAssetsAtPath(asset.path); var mainAsset = AssetDatabase.LoadMainAssetAtPath(asset.path); var tex2d = mainAsset as Texture2D; if (!mainAsset || !tex2d) { logger.logErrorFormat("Could not load texture at path {0}({1})", asset.path, asset.guid); return(true); } var id = resourceMapper.getTextureId(tex2d); if (!ExportUtility.isValidId(id)) { logger.logWarningFormat("Could not create id for texture {0}({1})", asset.path, asset.guid); } return(true); }
public JsonSplatPrototype(SplatPrototype data_, ResourceMapper resMap) { data = data_; textureId = resMap.getTextureId(data.texture); normalMapId = resMap.getTextureId(data.normalMap); }
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); }