Search Unity

CreateAsset Rendertexture / 3DTexture

Discussion in 'Editor & General Support' started by fleity, Feb 10, 2017.

  1. fleity

    fleity

    Joined:
    Oct 13, 2015
    Posts:
    345
    Hey Everyone

    I have a 3d texture which I'd like to pass to a shader, which somewhat currently works but could be nicer.
    The way I am doing this right now is keeping the texture in a big 1d .asset array which I convert to a 3DTexture and then pass to the shader. However this has the big disadvantage that you have to do this after every time you saved the scene in the editor (and in the start function, but that is ok).

    It would be a lot more convienent if you would not have to call the convertTex3DandPass function after every save, so I was wondering if I could put the texture into the asset folder in another way that is properly serialized and which I could just assign to the shader. But so far I was not successful with AssetDatabase.CreateAsset(), a 2d texture always ends up being entirely black, not to mention serializing a 3d rendertexture (occording to the documentation it can be also 3d but only if it's created from script).

    How do I use CreateAsset correctly with a (3D) Rendertexture?
     
  2. barbelot

    barbelot

    Joined:
    Jul 18, 2017
    Posts:
    38
    A bit late but I still have the same problem.
    I am trying to save a 3D RenderTexture to disk using CreateAsset but it seems to save an all black texture.