Hi, I am working on volume rendering for CT scans. I got volume rendering working(which is kind of slow, but working), and I am trying to write transfer function for this. I am starting with 1D transfer function, which sets RGB values for voxel(volume data). For this, I am trying to upload 1D texture and read it in shader, but I think texture in Unity doesn’t have any 1D texture. Does anybody know any way or work around to load 1D texture?
Today’s graphics hardware doesn’t actually support 1D textures, instead it has been emulated using a 1 pixel high or wide 2D texture, and the latest graphics APIs have dropped support for it entirely. Unity’s lack of a “Texture1D” type reflects this.
Just make a Texture2D and set one dimension of the resolution to 1, then in the shader use:
tex2D(_1DTransferFunction, float2(value, value));
You’ll also need to set the Texture2D to use the Clamped wrap mode, and/or inset your texture UVs by half a pixel.
1 Like