Search Unity

What is the correct way to use 3D textures to generate cube volumes?

Discussion in 'Scripting' started by theomkarpatil, Jul 5, 2019.

  1. theomkarpatil

    theomkarpatil

    Joined:
    Nov 24, 2016
    Posts:
    1
    I'm trying to create a volume filled cube to output my 3D noise calculations.

    I tried using 3D textures and referred to the script here:
    https://docs.unity3d.com/Manual/class-Texture3D.html

    and also used the shader and script given by Aras here:
    https://forum.unity.com/threads/unity-4-3d-textures-volumes.148605/

    only difference is I do:
    Code (CSharp):
    1.  mat = GetComponent<MeshRenderer>().material;
    2. mat.SetTexture("_Volume", texture);
    in place of Aras' line 32.

    I applied the shader and script on a Cube, I have attached an image of the properties: unity.png

    I don't know if I'm missing something or if I'm doing something wrong.
    Right now I'm just setting the color of each x, y and z to see if the code works before doing my noise calculations, but the result I get is just the very first color I set in the loop.

    I do get positive results if I set the alpha value in the loop instead of the color, and check the results through Scene View -> Alpha Channel, but that too isn't a volume, its just the outer texture.

    I would really appreciate some help and suggestions. Thank You.