I am building a 3d texture in Unity like so:
volumeTex = new Texture3D(volumeWidth, volumeHeight, volumeDepth, TextureFormat.Alpha8, false);
volumeTex.filterMode = (UnityEngine.FilterMode) filterMode;
volumeTex.wrapMode = TextureWrapMode.Clamp;
pixelBuffer = new Color[volumeWidth*volumeHeight*volumeDepth];
Random.seed = 0;
int i = 0;
for(int x = 0; x < volumeWidth; x++)
for(int y = 0; y < volumeHeight; y++)
for(int z = 0; z < volumeDepth; z++, i++) {
float r = (float)x / (float)volumeWidth;
float g = (float)y / (float)volumeHeight;
float b = (float)z / (float)volumeDepth;
pixelBuffer *= new Color(r, g, b, 0.0f);*
-
}*
-
volumeTex.SetPixels(pixelBuffer);*
-
volumeTex.Apply();*
After that I set the texture in a uniform variable:
-
renderer.material.SetTexture("_VolumeTex", volumeTex);*
However the 3d texture is not caught in the shader. Instead a different texture (text atlas to be precise) is used, probably because the texture is never actually set.
It worked fine in Unity Pro, but I would like for my shader to be compatible with Unity Free.