Manipulating ModelTransformMatrix on RenderView breaks GPU Based volume mode
Description
When using CAVEInteraction
plugin, if I configure vtkVRInteractorStyles that manipulate the ModelTransformMatrix
property on the RenderView
proxy, this can result in volume rendering errors. The problem only seems to happen when using the "GPU Based" volume rendering mode.
Reproducing
This problem can be reproduced simply using the GUI with the "Python Shell" view.
- Add a
Wavelet
source and set the representation toVolume
. - In the Python editor view, paste or type the following:
import math
theta = math.pi / 4
v = GetActiveView()
# For a 45 deg rotation about the y axis
rot_y_matrix = [math.cos(theta), 0, math.sin(theta), 0, 0, 1, 0, 0, -math.sin(theta), 0, math.cos(theta), 0, 0, 0, 0, 1]
v.SetPropertyWithName("ModelTransformMatrix", rot_y_matrix)
Render()
That produces the following image:
Notice that if I change the "Volume Rendering Mode" from "Smart" to "Ray Cast Only", the problem goes away, like below:
Changing the mode back to "Smart" or to "GPU Based" again produces the issue.
Observations
This makes sense given that the gpu shader based volume mapper depends on the camera position (see here) which we circumvent by using the ModelTransformMatrix
.
I would expect other things that depend on the camera position (e.g. clipping) to be affected when transformations include a translation are applied via the ModelTransformMatrix
property on the RenderView
proxy as well.
System Information
$ uname -a
Linux 4.15.0-189-generic #200-Ubuntu SMP Wed Jun 22 19:53:37 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.6 LTS"
$ nvidia-smi
Thu Jul 14 19:40:32 2022
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 510.73.05 Driver Version: 510.73.05 CUDA Version: 11.6 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 NVIDIA GeForce ... Off | 00000000:04:00.0 On | N/A |
| 29% 48C P8 23W / 250W | 1247MiB / 11264MiB | 1% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| 0 N/A N/A 3230 G /usr/lib/xorg/Xorg 40MiB |
| 0 N/A N/A 3413 G /usr/bin/gnome-shell 119MiB |
| 0 N/A N/A 4316 G /usr/lib/xorg/Xorg 525MiB |
| 0 N/A N/A 4485 G /usr/bin/gnome-shell 73MiB |
| 0 N/A N/A 4927 G /usr/lib/firefox/firefox 157MiB |
| 0 N/A N/A 4937 G ...veSuggestionsOnlyOnDemand 145MiB |
| 0 N/A N/A 19112 G ...w/build_cave/bin/paraview 58MiB |
| 0 N/A N/A 31099 G ...RendererForSitePerProcess 120MiB |
+-----------------------------------------------------------------------------+