I’m stuck. I feel like I am missing something simple but with the information I can find, I can’t figure out what it is. I did discover that if I use the same code to replace different tags, I get different errors. Is there any documentation about the different shaders in the Paraview shader program, like what they do, how to figure out which tag to replace, etc? Is there a way to see the final result after the shader replacements? I saw a response to a VTK user on Andriod suggesting to uncomment vtkOpenGL2PolyDataMapper.cxx somewhere, but couldn’t figure out how to do the equivelant in Paraview
Below are the replacement shader strings I am trying to use in Paraview. These are in a file with a .json extension that I load with the file selector in Properties > Display > Miscellaneous > Use Shader Replacements:
{
"type":"fragment",
"original":"//VTK::Normal::Dec",
"replacement":"
//VTK::System::Dec
float df;
float sf;
vec3 diffuse;
vec3 specular;
"
}
{
"type":"fragment",
"original":"//VTK::Normal::Impl",
"replacement":"
//VTK::System::Dec
df = max(0.0, normalVCVSOutput.z);
sf = pow(df, 2.0);
diffuse = df * vec3(0.2, 0.5, 0.3) //diffuseNormalUniform;
specular = sf * vec3(0.4,0.4,0.4);
gl_FragData[0] = vec4(0.3*abs(normalVCVSOutput) + 0.7*diffuse + specular, 1.0);
"
}
{
"type":"vertex",
"original":"//VTK::Normal::Dec",
"replacement":"
//VTK::Output::Dec
vec4 tmpPosDC;
"
}
{
"type":"vertex",
"original":"//VTK::Normal::Impl",
"replacement":"
//VTK::System::Dec
//VTK::Normal::Dec
tmpPosDC = MCDCMatrix * vertexMC;
normalVCVSOutput = normalMatrix * normalMC;
gl_Position = tmpPosDC*vec4(0.2+0.8*abs(tmpPosDC.x),0.2+0.8*abs(tmpPosDC.y),1.0,1.0);
"
}
When I load it, the geometry I have in the viewer, a sphere geometrical shape source, turns black. Then, after a 94 line listing of vtkShaderProgram, I get the following errors. The vtkShaderProgram is mostly tags and comments with my code sprinkled in. I think the 3rd and 5th are important, but I can’t figure out what to do:
ERROR: In vtkShaderProgram.cxx, line 1145
vtkShaderProgram (0xfae02b0):
ERROR: In vtkOpenGLPolyDataMapper.cxx, line 2645
vtkOpenGLBatchedPolyDataMapper (0x10e36050): Could not set shader program
ERROR: In vtkOpenGLVertexArrayObject.cxx, line 262
vtkOpenGLVertexArrayObject (0x10e36c90): attempt to add attribute without a bound program for attribute normalMC
ERROR: In vtkOpenGLVertexBufferObjectGroup.cxx, line 269
vtkOpenGLVertexBufferObjectGroup (0xff78cf0): Error setting ‘normalMC’ in shader VAO.
ERROR: In vtkOpenGLVertexArrayObject.cxx, line 262
vtkOpenGLVertexArrayObject (0x10e36c90): attempt to add attribute without a bound program for attribute vertexMC
ERROR: In vtkOpenGLVertexBufferObjectGroup.cxx, line 269
vtkOpenGLVertexBufferObjectGroup (0xff78cf0): Error setting ‘vertexMC’ in shader VAO.