Пример #1
0
    private void finishDIM()
    {
        string cubePath = AssetDatabase.GetAssetPath(outDIM.cube);

        ps.CONVO.resampleToCube(ref outDIM.cube, 0, outDIM.colorMode, needsGamma(ref outDIM));
        outDIM.locked = false;
        outDIM.setReference(cubePath, false);
        outDIM.setLinear(needsLinearSampling(ref outDIM));
        outDIM.cube.Apply(true);
    }
Пример #2
0
 private void finishSKY()
 {
     if (outSKY.cube && inSKY.input != outSKY.cube)
     {
         ps.IN.resampleToCube(ref outSKY.cube, 0, outSKY.colorMode, needsGamma(ref outSKY));
         outSKY.cube.Apply(true);
         outSKY.locked = false;
         outSKY.setLinear(needsLinearSampling(ref outSKY));
         outSKY.setReference(AssetDatabase.GetAssetPath(outSKY.cube), false);
     }
 }
Пример #3
0
    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(ref 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(ref outSIM));
        outSIM.setReference(cubePath, true);
        ps.finishMetric.end();
    }