|
| 1 | +# 3D Textures |
| 2 | + |
| 3 | +The image viewer support 3D textures from the dds and ktx file format. If you dont have 3D textures in the required format see [Creating 3D Textures](#Creating-3D-Textures). |
| 4 | + |
| 5 | +## View Modes |
| 6 | + |
| 7 | +After opening a 3D texture, they will be displayed in the "Volume" view (see status bar next to the eye icon). If you want to inspect only a single slice you can select the "Single" view and navigate through each slice with the "Silce Index" that can be set inside the "Images" tab on the right side. |
| 8 | + |
| 9 | +The volume view provides the following display options: |
| 10 | +* Shading: Enables simple flat shading |
| 11 | +* Hide Internals (for Transparency): Hides the insides of transparent areas so that only the hull is visible |
| 12 | +* Alpha Is Coverage (for Transparency): When disabled, assumes that light loses colored instead of monochrome intensity when shinging through colored surfaces. |
| 13 | +* Slice: Configures the range of displayed slices (cuts through the volume) |
| 14 | + |
| 15 | +### Issues with Linear Interpolation |
| 16 | +When enabling linear interpolation, a ray marching algorithm is used to determine the color. Possible Issues: |
| 17 | +* Dark/Invalid Outlines: Those outlines can appear if the color channel of the texture is not correctly configured for fully transparent voxels (alpha = 0). In this case, the color of those invalid voxels bleeds over to non transparent voxels because linear interpolation is used. To fix this issue, apply the "fix_alpha" filter in the "Filter" tab. |
| 18 | + |
| 19 | +## Creating 3D Textures |
| 20 | + |
| 21 | +If you dont have the tools to create 3D dds or ktx textures you can use the image viewer to create a 3D textures from multiple 2D textures: |
| 22 | +* Go to File->Import as Array/3D |
| 23 | +* Drag your 2D textures into the list box |
| 24 | +* Click "To Texture3D" to convert the seperate 2D textures into a merged 3D texture |
| 25 | + |
| 26 | +Alternatively, you can convert a 2D texture array to a 3D texture via "Tools->Texture Array to Texture3D" after loading the texture array. |
| 27 | + |
| 28 | +If you want to create a 3D texture programatically you can use [GLI](https://github.com/g-truc/gli) to create dds/ktx files. This is a minimal example on how to create and save 3d textures: |
| 29 | + |
| 30 | +```c++ |
| 31 | +#include <gli/gli.hpp> |
| 32 | + |
| 33 | +int main() { |
| 34 | + // 3d texture with rgba 8 bit srgb format, 32x32x32 resolution and 1 mipmap |
| 35 | + gli::texture3d tex(gli::format::FORMAT_RGBA8_SRGB_PACK8, gli::extent3d(32, 32, 32), 1); |
| 36 | + |
| 37 | + // raw access to pixels |
| 38 | + uint8_t* pixels = reinterpret_cast<uint8_t*>(tex.data()); |
| 39 | + // set pixel at (0, 0, 0) to white (0xFFFFFFFF) |
| 40 | + tex.store({ 0, 0, 0 }, 0, 0xFFFFFFFF;); |
| 41 | + |
| 42 | + gli::save_dds(tex, "volume.dds"); |
| 43 | + return 0; |
| 44 | +} |
| 45 | +``` |
0 commit comments