Is there any way to change the InternalFormat?

Greetings, I can’t get vtkOpenGLGPUVolumeRayCastMapper nor vtkFixedPointVolumeRayCastMapper to work. I consistently get vtkTextureObject (0x250840): Failed to determine texture parameters., because the InternalFormat is 0.

I tried to print the default internal format like this:

vtkSmartPointer<vtkTextureObject> obj = vtkSmartPointer<vtkTextureObject>::New();
obj->SetContext(vtkOpenGLRenderWindow::SafeDownCast(renWin));
std::cout << obj->GetInternalFormat(VTK_UNSIGNED_SHORT, 1, false) << std::endl;

But, even when changing the type and the amount of components, this always prints 0.

At first the internal format was R32F, but this isn’t feasible for me as any format with this internal format isn’t texture filterable and in vtkOpenGLRayCastImageDisplayHelper line 125 and 126 it gets hardcoded to linear interpolation.
I presume the R32F comes from vtkTextureObject::GetDefaultInternalFormat?
There’s a this->UseSRGBColorSpace protected property there that gets initialized to false/ I don’t suppose there’s a way to maybe change this to true?

Furthermore, is it normal that I had to increase the stack size to 1048576 to not have a stack overflow when running vtkFixedPointVolumeRayCastMapper ?

My code:

ta> makeUniformCube(const std::array<int, 3> &dimensions, unsigned short value)
{
    vtkSmartPointer<vtkImageData> imageData = vtkSmartPointer<vtkImageData>::New();
    imageData->SetDimensions(dimensions.data());
    imageData->SetSpacing(1.0, 1.0, 1.0);
    imageData->SetOrigin(0.0, 0.0, 0.0);
    imageData->AllocateScalars(VTK_UNSIGNED_SHORT, 1);

    int nofVoxels = dimensions[0] * dimensions[1] * dimensions[2];
    unsigned short *voxel = static_cast<unsigned short *>(imageData->GetScalarPointer(0, 0, 0));
    for (std::size_t i = 0; i < nofVoxels; ++i)
    {
        *voxel = value;
        voxel++;
    }

    return imageData;
}

int main(int argc, char *argv[])
{
    vtkNew<vtkRenderer> ren1;

    vtkNew<vtkRenderWindow> renWin;
    renWin->AddRenderer(ren1);

    vtkNew<vtkRenderWindowInteractor> iren;
    vtkNew<vtkInteractorStyleTrackballCamera> style;
    iren->SetRenderWindow(renWin);
    iren->SetInteractorStyle(style);
    style->SetDefaultRenderer(ren1);

    // Create the reader for the data
    vtkSmartPointer<vtkImageData> reader = makeUniformCube({8, 8, 8}, static_cast<unsigned short>(128));

    vtkNew<vtkPiecewiseFunction> opacityTransferFunction;
    vtkNew<vtkColorTransferFunction> colorTransferFunction;

    double rescaledMin = 0.0;
    double rescaledMax = 128.0;
    LookupTable::createVTKColorOpacityFunctions(
        rescaledMin, rescaledMax, *colorTransferFunction, *opacityTransferFunction);

    vtkNew<vtkVolumeProperty> volumeProperty;
    volumeProperty->SetColor(colorTransferFunction);
    volumeProperty->SetScalarOpacity(opacityTransferFunction);
    volumeProperty->ShadeOn();
    // Ideally this is linear instead of nearest
    // volumeProperty->SetInterpolationTypeToLinear();
    volumeProperty->SetInterpolationTypeToNearest();

    // Both volume mappers give an error
    // vtkNew<vtkGPUVolumeRayCastMapper> volumeMapper;
    // vtkNew<vtkOpenGLGPUVolumeRayCastMapper> volumeMapper;
    vtkNew<vtkFixedPointVolumeRayCastMapper> volumeMapper;

    volumeMapper->SetInputData(reader);
    volumeMapper->SetSampleDistance(1.0 / 4.0);
    volumeMapper->SetBlendModeToComposite();

    vtkNew<vtkVolume> volume;
    volume->SetProperty(volumeProperty);
    volume->SetMapper(volumeMapper);

    ren1->AddVolume(volume);
    ren1->ResetCamera();
    renWin->Render();
    iren->Start();

    return 0;
}