I am doing some scientific rendering of relatively large, dense, volumetric data. In other words, given a cube of space, I have an assignment of one color per voxel.
I can't think of a better way to render this in Blender than the following:
- Convert the 3D data into a long filmstrip, where each "slice" of 3D data is concatenated into a very long 2D image texture
- Map the texture to the material based upon the object coordinates, so that boolean slices into the mesh reveal more data underneath
Conveniently, this means that the same material can be used for surface renders and volumetric renders :)
There's a more comprehensive render of what I'm doing here, on Twitter:
And here's a schematic of my strategy:
And here's a Google Drive with a .Blend file with the red example above: https://drive.google.com/drive/folders/1H_djtWjYUEwuIMtkUX5DX5tCrXv7Yipy?usp=sharing
So basically, I wind up with a very long texture like this one (https://i.sstatic.net/wxFMe.png).
On relatively small volumes like the red one I rendered above, everything appears to work perfectly. But when I scale up to much larger texture sizes, I start getting texture "stretching." From a TIFF image of (2253×64896) pixels, where the 2D slices are roughly 2Kpx in each direction and there are around 30 z-slices concatenated in the Y direction of the texture map, I see the following:
In other words, there is blurring, in the direction of the long axis of the image. This screenshot was taken from the UV image editor in Blender, i.e., this is Blender's interpretation of the image from disk, NOT something weird in the viewport.
The data are supposed to look like this (screenshot from opening the same image in Photoshop), i.e., with square pixels:
I vaguely recall from Three.js programming that there is a reason to have power-of-two dimensions to make things load into VRAM nicely, and that textures may be automatically stretched to fit a power-of-two in each dimension by the underlying GPU API. But my X and Y axes are both not-crazy-far from powers of 2, and so the stretching should be minimal.
Is the WHOLE image being resized to a square? Is there somewhere where I can learn more about what Blender is doing to textures under the hood?