VTK render error:vtkShaderProgram (00000289700E3F20): ERROR: 0:216: '' : expect an array name

20 views Asked by At

my code

#include "vtkPiecewiseFunction.h"
#include "vtkColorTransferFunction.h"
#include "vtkGPUVolumeRayCastMapper.h"
#include "vtkSmartVolumeMapper.h"
#include "vtkImageData.h"
#include "vtkVolumeProperty.h"
#include "vtkVolume.h"
#include "vtkRenderWindow.h"
#include "vtkRenderer.h"
#include "vtkRenderWindowInteractor.h"
#include <vtkNIFTIImageReader.h>

#include "vtkAutoInit.h" 
VTK_MODULE_INIT(vtkRenderingOpenGL2);
VTK_MODULE_INIT(vtkInteractionStyle);
VTK_MODULE_INIT(vtkRenderingVolumeOpenGL2);

#define vtkRenderingCore_AUTOINIT 4(vtkInteractionStyle,vtkRenderingFreeType,vtkRenderingFreeTypeOpenGL2,vtkRenderingOpenGL2)
#define vtkRenderingVolume_AUTOINIT 1(vtkRenderingVolumeOpenGL2)

int main(int, char *[])
{
    vtkNIFTIImageReader *reader = vtkNIFTIImageReader::New();
    reader->SetFileName("./data_image/resource/295.nii");
    reader->Update();

    vtkGPUVolumeRayCastMapper *mapper = vtkGPUVolumeRayCastMapper::New();
    mapper->SetInputData(reader->GetOutput());

    vtkVolume *volume = vtkVolume::New();
    volume->SetMapper(mapper);

    vtkVolumeProperty *property = vtkVolumeProperty::New();


    vtkPiecewiseFunction *popacity = vtkPiecewiseFunction::New();
    popacity->AddPoint(1000, 0.0);
    popacity->AddPoint(4000, 0.68);
    popacity->AddPoint(7000, 0.83);

    vtkColorTransferFunction *color = vtkColorTransferFunction::New();
    color->AddHSVPoint(1000, 0.042, 0.73, 0.55);
    color->AddHSVPoint(2500, 0.042, 0.73, 0.55, 0.5, 0.92);
    color->AddHSVPoint(4000, 0.088, 0.67, 0.88);
    color->AddHSVPoint(5500, 0.088, 0.67, 0.88, 0.33, 0.45);
    color->AddHSVPoint(7000, 0.95, 0.063, 1.0);

    property->SetColor(color);
    property->SetScalarOpacity(popacity);
    property->ShadeOn();
    property->SetInterpolationTypeToLinear();
    property->SetShade(0, 1);
    property->SetDiffuse(0.9);
    property->SetAmbient(0.1);
    property->SetSpecular(0.2);
    property->SetSpecularPower(10.0);
    property->SetComponentWeight(0, 1);
    property->SetDisableGradientOpacity(1);
    property->DisableGradientOpacityOn();
    property->SetScalarOpacityUnitDistance(0.891927);

    volume->SetProperty(property);

    vtkRenderer *ren = vtkRenderer::New();
    ren->AddActor(volume);
    ren->SetBackground(0.1, 0.2, 0.4);

    vtkRenderWindow *renWin = vtkRenderWindow::New();
    renWin->AddRenderer(ren);

    vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
    iren->SetRenderWindow(renWin);
    renWin->SetSize(600, 600);
    renWin->Render();
    iren->Start();

    return 0;
};
 

No error is reported when compiling the code, but an error is reported when running.

when i run to 'renWin->Render();',a error occurred!! error_image)

ERROR: In D:\TempRepository\VTK\Rendering\OpenGL2\vtkShaderProgram.cxx, line 462
vtkShaderProgram (00000289700E3F20): ERROR: 0:216: '' : expect an array name 
ERROR: 1 compilation errors.  No code generated.
ERROR: In D:\TempRepository\VTK\Rendering\VolumeOpenGL2\vtkOpenGLGPUVolumeRayCastMapper.cxx, line 3029
vtkOpenGLGPUVolumeRayCastMapper (000002896AF2E510): Shader failed to compile

but D:\TempRepository\VTK\Rendering\VolumeOpenGL2 this is the path where the source code is located. The real library path is D:\ThirtyLibrary\VTK\VTK-8-2-0\vc141_x64_debug .

  1. I tried reinstalling qt5.12.6 and recompiling the vtk8.2.0 library, but the same error still occurred.
  2. use vs2017 is also occurred.
  3. I reinstalled the AMD graphics card driver and even reinstalled the Win10 system, and the result was the same.
  4. I used vtkFixedPointVolumeRayCastMapper instead of vtkGPUVolumeRayCastMapper so it works correctly.

But I still want to use GPU acceleration, what should I do?

so please...

0

There are 0 answers