Created
August 27, 2023 10:33
-
-
Save babon/e027af971d04e8b4d15d148f18826e7a to your computer and use it in GitHub Desktop.
This file contains 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 characters
//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(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment