Created
August 27, 2023 10:33
-
-
Save babon/e027af971d04e8b4d15d148f18826e7a to your computer and use it in GitHub Desktop.
Revisions
-
babon created this gist
Aug 27, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ //input RenderTexture 'rt3D' Texture3D output = new Texture3D(width, height, depth, rt3D.graphicsFormat, TextureCreationFlags.None); //assuming rt3D format to be 8 bits var a = new NativeArray<byte>(width * height * depth, Allocator.Persistent, NativeArrayOptions.UninitializedMemory); AsyncGPUReadback.RequestIntoNativeArray(ref a, rt3D, 0, (_) => { output.SetPixelData(a, 0); output.Apply(updateMipmaps: false, makeNoLongerReadable: true); AssetDatabase.CreateAsset(output, "Assets/3dtex.asset"); a.Dispose(); });