public static void CopyTexture(Texture2D src, Texture2D des) { RenderTexture rt = new RenderTexture(des.width, des.height, 0, RenderTextureFormat.ARGBFloat, RenderTextureReadWrite.Default); CopyToRT(src, rt); CopyFromRT(des, rt); rt.Release(); JUtilities.DestroyObject(rt); }
public static void FillTexture(RenderTexture rt, Color c) { Texture2D tex = new Texture2D(1, 1, TextureFormat.ARGB32, false); tex.SetPixel(0, 0, c); tex.Apply(); CopyToRT(tex, rt); JUtilities.DestroyObject(tex); }
private void CleanUp() { if (environmentProbe != null) { JUtilities.DestroyGameobject(environmentProbe.gameObject); } if (environmentReflection != null) { JUtilities.DestroyObject(environmentReflection); } }
private void ExportFace(Cubemap cube, CubemapFace face) { Texture2D tex = new Texture2D(cube.width, cube.height); Color[] data = cube.GetPixels(face); Color[] flipData = new Color[data.Length]; for (int y = 0; y < Resolution; ++y) { for (int x = 0; x < Resolution; ++x) { flipData[JUtilities.To1DIndex(x, y, Resolution)] = data[JUtilities.To1DIndex(Resolution - 1 - x, Resolution - 1 - y, Resolution)]; } } tex.SetPixels(flipData); tex.Apply(); byte[] bytes = tex.EncodeToPNG(); string fileName = Path.Combine(Directory, cube.name + "-" + face.ToString() + ".png"); File.WriteAllBytes(fileName, bytes); JUtilities.DestroyObject(tex); }