[vtk-developers] Ambient Lighting in the GPU Volume Mapper
marko at rosenmueller.de
Wed Mar 21 09:53:34 EDT 2012
I have a problem with probably incorrect ambient lighting in the GPU
volume raycast mapper (VTK 5.10 and also 5.8). The result is a
difference in the rendererd image compared to the fixed point raycast
mapper. The problem comes from the following lines in
vtkGPUVolumeRayCastMapper_ShadeFS.glsl in function "vec4 shade(vec4
// ambient term for this light
// scene ambient term
In line 184, I would assume that the transferfunction should be
considered as well. This results in a grayish rendering since some
gray value is added that depends on the ambient term of the light
source and the material but not on the color computed via the transfer
I fixed this by adding the color computed from the transferfunction in line 184:
In line 200, the ambient term for the scene is added, which is
independent of the light's ambient term. To get the same result as the
fixed point mapper provides, I had to set the ambient property of the
OpenGL light model to zero. This disables the global ambient lighting
of the scene. I did this by setting the scene ambient color of the
vtkRenderer, which is used by the vtkOpenGLRenderer to set the
GL_LIGHT_MODEL_AMBIENT value (see vtkOpenGLRenderer::ClearLights()).
This works fine for me and results in the same rendering compared to
the fixed point CPU raycaster. My questions are:
1. Is the problem in line 184 a bug in VTK?
2. Is it correct that the scene color depends on the ambient property
of the vtkRenderer? If yes, should the fixed point renderer also
account for the scene ambient color?
Another question regarding the code of the fragment shader: Why are
frontLightProduct_Diffuse and frontLightProduct_Specular computed in
lines 120-121? Shouldnt this be the same as
gl_FrontLightProduct.diffuse / gl_FrontLightProduct.specular?
Actually this was changed from version 5.8 to 5.10. Is there any
reason for that?
More information about the vtk-developers