Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Debugging 3D Render Textures

Discussion in 'General Graphics' started by starstriker1, Jun 18, 2015.

  1. starstriker1

    starstriker1

    Joined:
    Jul 15, 2012
    Posts:
    38
    Hey guys, I was wondering if anyone knows how to get the pixels or otherwise do a debug rendering of a 3D render texture. I need to verify the values inside a render texture I've created but I'm at my wits end here. As best I can tell, I can't get the pixel values of my render texture unless I can convert it to a Texture3D first, but AFAIK there's no way to actually convert it over! ReadPixels, the function used to translate a 2D render texture to a Texture2D, doesn't exist for a Texture3D.

    How can I get the data in my 3D render texture out into a human-readable format?
     
  2. ronjart

    ronjart

    Joined:
    May 16, 2013
    Posts:
    100
    Bump, I'm having the same problem.
     
  3. starstriker1

    starstriker1

    Joined:
    Jul 15, 2012
    Posts:
    38
    Well, here's the solution that I ended up using:

    Build (or generate) a 3D model with a set of small triangles evenly spaced out across a cubic volume, from the coordinates 0,0,0 to 1,1,1 (in unity space). Write a test shader for the material you'll apply to this texture. This test shader should pass the position of the vertex (in model space) into the fragment shader, which you can then use to determine the colour of the triangle by sampling from the 3D texture.

    This was good enough for my purposes; however, it has some downsides. Chief among them is that the mesh vertex limit puts an upper limit on the resolution of this technique. 16x16x16 sample is possible. 32x32x32 is too much. It's also a little difficult to parse at a glance, but it's a heck of a lot better than nothing!
     
  4. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    If you are using Windows, you can inspect 3d textures (and any other graphic resource) in 3rd party software like Nvidia NSight, Visual Studio Graphics Debugger, RenderDoc... Some may even work in Unity editor, but ti is generally safer to build standalone exe and use that.