Need help with volume rendering parameters

when I first load the vtk volume it loads ok but not with the desired opacity.
image
but once I do any mouse operation, e.g., rotation, pan, or dolly, it renders with the desired effect
image

Could someone tell me what’s the difference between the two rendering. The actor properties are not changed. I would like to be able to control between the two rendering effects.

One thought: It looks as if you had made some actor property changes after your initial render, but never called render() again until the interaction occurred.

I didn’t, that’s what puzzles me. If I just click the mouse but do not move it, the interactor in vtk will start animationFrame update, and it still shows the original rendering effect. But once I move the mouse, it will changes and show the desired rendering effect.

I understand in animationFrameUpdate, vtk will invoke a callback in _animationRateSubscription and use a so called _smallViewportWidth (check Rendering\OpenGL\VolumeMapper\index.js) for rendering if update rate is not desired. which is fine. But still it doesn’t tell me how that would change the final rendering effect.

Also, if I move the camera by code after initial rendering without clicking and moving the mouse, I still don’t get the desired effect. But once I click and move the mouse, the desired effect will happen and it will stay. I really need to understand why.

It seems some ‘secret’ rendering switch is turned on or modifed by vtkInteractor/vtkObserver/vtkInteractorStyle, I tried but failed to find it.

It seems to me that you are referring to the volume downsampling behavior. AFAIK the only control I know of for that is interactor.setDesiredUpdateRate(fps). I will have to take a separate look to verify.

thanks Forrest. I just want to point out two more things in case it helps the investigation.

  1. the difference between the two pictures. In the first picture the bones are rendered with some kind of transparency, in the second picture it’s rendered basically without opacity, which looks more realistic. However, both rendering uses the same color transfer function and opacity transfer function and ‘shade on’ option as I never changed these after setting it up before the initial rendering. Is there any other rendering option to control the rendering behavior which is triggered by interactor?

  2. If I do mouse down-hold-up, it doesn’t change the rendering behavior, but a down-move-up operation changes. A down-hold-up operation still calls animationFrameUpdate, and it may still calls downSampling as I can see the blurred image, but the rendering behavior doesn’t change after mouse release. It changes once the mouse moves a bit.

Here are a few things to try:

  • Is it reproducible using different colormaps/opacity functions?
  • Is it reproducible if you load your dataset into Glance?
  • Does it happen with other datasets + same colormap/opacity functions?

Just as a follow-up: this could be a lighting issue. Issuing a renderer.updateLightsGeometryToFollowCamera() after calling resetCamera() might do the trick.

1 Like

Thanks Forrest! it works and indeed is the cause of the difference.