private void finishDIM() { string cubePath = AssetDatabase.GetAssetPath(outDIM.cube); ps.CONVO.resampleToCube(ref outDIM.cube, 0, outDIM.colorMode, needsGamma(outDIM)); outDIM.locked = false; outDIM.setReference(cubePath, false, true); outDIM.setLinear(needsLinearSampling(outDIM)); outDIM.cube.Apply(true); }
private void finishSKY() { if (outSKY.cube && inSKY.input != outSKY.cube) { ps.IN.resampleToCube(ref outSKY.cube, 0, outSKY.colorMode, needsGamma(outSKY), uiExposure); outSKY.cube.Apply(true); outSKY.locked = false; outSKY.setLinear(needsLinearSampling(outSKY)); outSKY.setReference(AssetDatabase.GetAssetPath(outSKY.cube), false, true); } }
private void finishSIM() { ps.finishMetric.begin(); string cubePath = AssetDatabase.GetAssetPath(outSIM.cube); //clear existing mips UnityEngine.Object[] mips = AssetDatabase.LoadAllAssetRepresentationsAtPath(cubePath); for (int i = 0; i < mips.Length; ++i) { if (AssetDatabase.IsSubAsset(mips[i])) { UnityEngine.Object.DestroyImmediate(mips[i], true); } } if (!ps.buildMipChain) { ps.CONVO.resampleToCube(ref outSIM.cube, 0, outSIM.colorMode, needsGamma(outSIM)); outSIM.cube.Apply(true); } AssetDatabase.Refresh(); if (ps.buildMipChain) { AssetDatabase.StartAssetEditing(); int faceSize = outSIM.cube.width; // skip mip level 0, its in the cubemap itself faceSize = faceSize >> 1; for (int mip = 1; faceSize > 0; ++mip) { // extract mipmap faces from a cubemap and add them as textures in the sub image Texture2D tex = new Texture2D(faceSize, faceSize * 6, TextureFormat.ARGB32, false); tex.name = "mip" + mip; for (int face = 0; face < 6; ++face) { tex.SetPixels(0, face * faceSize, faceSize, faceSize, outSIM.cube.GetPixels((CubemapFace)face, mip)); } tex.Apply(); AssetDatabase.AddObjectToAsset(tex, cubePath); AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(tex)); faceSize = faceSize >> 1; } AssetDatabase.StopAssetEditing(); outSIM.cube.filterMode = FilterMode.Trilinear; outSIM.cube.Apply(false); } outSIM.locked = false; outSIM.setLinear(needsLinearSampling(outSIM)); outSIM.setReference(cubePath, true, true); ps.finishMetric.end(); }