Skip to content

Commit

Permalink
Added appearance chapter, on shadows, path tracing, and TF editing
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmelis committed Apr 16, 2024
1 parent 2fb93be commit 2d5685d
Show file tree
Hide file tree
Showing 19 changed files with 11,175 additions and 48 deletions.
87 changes: 87 additions & 0 deletions docs/appearance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
---
hide:
- navigation
---

# Appearance

The default rendering method used in ParaView does not produce shadows, nor any other realistic lighting effects. In certain cases you might want to have an image that looks a bit nicer (for example, as cover image). So we'll look into a few ways of accomplishing more appealing images below.

## Shadows

By default, ParaView renders a 3D view using fairly simple (GPU-accelerated) rendering. For example, this saved screenshot of an isosurface from the CT-scan dataset shows no shadows, and only uses a single light source:

![](./images/rendering-default.png)

Such a rendering lacks clues that you as a viewer normally uses to understand shapes and spatial relations. Here is the same image with added shadows:

![](./images/rendering-ospray-raycast-shadows.png)

As you can hopefully see, such a rendering provides much more information. For example, the parts seen through the right eye are now clearly seen to be located quite far backwards, something that was hard to judge in the non-shadowed image, and you can judge how much overhang there is from the cheekbone.

To enable such shadowed rendering we used the *Raytracing* modes in ParaView. These use more advanced rendering and lighting techniques to produce more realistic renderings. To enable this for a particular object, select the corresponding filter and check `Enable Ray Tracing` under the __Ray Traced Rendering__ property block, and then check `Shadows`.

![](./images/raytracing-settings.png)

This will change the rendering mode and show shadows on the object, just like the image above.

!!! warning "Slow interaction with ray tracing modes"

Note that rendering and interaction can become quite a bit slower when enabling ray tracing.
**This has an influence on the whole user interface**, and might make it almost unusable. So be somewhat careful in tweaking the ray tracing parameters, such as `Samples Per Pixel`, to high values.

In some cases it might be more effective to only use ray tracing mode when generating images from a Python script.

In this particular case we used the `OSPRay raycaster`, which is a CPU-based rendering mode with a fairly simple lighting model. Rendering and interaction speed will depend on the number of CPU cores in your system.

## Path tracing

A more advanced rendering method is Path tracing, which simulates more realistic lighting effects, such as light bouncing between surfaces reaching otherwise dark areas.

There's two path tracer modes in Paraview, the OSPray path tracer and the OptiX path tracer. The former (OSPray), is always available and is CPU-based, while the latter (OptiX) is GPU-based and only available if your system has an NVIDIA GPU. So the latter is to be preferred if you can enable it, as it will lead to less interaction slowdown. The resulting images will differ somewhat in lighting between these rendering modes, by the way.

With pathtracer rendering the main setting to tweak is `Samples Per Pixel`. The higher you set this the less noisy and better the rendered image becomes (but remember the warning from above about slow interaction). For example, here's the isosurface as shown above, but now rendering with the OptiX pathtracer and 4 samples per pixel (left), or even less noisy, when using 16 samples per pixel (right):

![](./images/rendering-optix-4spp.png) ![](./images/rendering-optix-16spp.png)

Compare the image using the shadowed raycasting we initially showed above, versus the path tracing image:

![](./images/rendering-ospray-raycast-shadows.png) ![](./images/rendering-optix-16spp.png)

Much more light can be seen reaching the depth of the eye socket, and the shadows is general are less harsh. The reason for the difference in surface color is not just due to different lighting effects, but also because of a different surface [material](https://docs.paraview.org/en/latest/ReferenceManual/objectShadingProperties.html) used by default between these modes.

Settings controlling material and appearance can be changed after enabling the advanced properties using ![](./images/wheel.png){ .iconimg }. ParaView comes with a list of pre-defined materials, for example, here's what we get when selecting `Metal_Copper_Flat` under __Material__ (in the __Ray Tracing__ section):

![](./images/rendering-metal-copper-flat.png)

## Volume rendering

We briefly showed volume rendering in Exercise 1, but actually did not go into the most important part, setting the *transfer function*. The transfer function is used to control the appearance, in terms of color and opacity, of a volume. Simply speaking it maps a voxel data value to a (color, opacity) pair. By doing this for all voxels and compositing the visual result back-to-front an image is generated. It is a really powerful technique for visualizing volumetric data, but it can be a bit challenging to get good results.

The default transfer function in ParaView is linear, mapping the data range minimum value to fully transparent blue, and the data range maximum value to fully opaque red. See the graph representation and color bar in the Color Map Editor (**`View > Color Map Editor`**):

![](./images/tf-default.png)

This default gives a fairly good overview of what's in the full dataset value range. But, for example, the values corresponding to the skull, which we know from the contour used earlier is around 2000, are mostly hidden by many layers of voxels containing the skin. We can just barely see a bit of the skull near the right eye show through.

We can try to show the bone more clearly by making the values 2000 opaque, and lowering the opacity of the existing points. By clicking in the graph we add a point, while dragging points allows control over both associated value (X) as well as opacity (Y):

![](./images/tf-2000.png)

Unforunately, this hasn't helped much, although the rendering is slightly different. We're still seeing too much of the low values (blue). Let's add another point to bring down the low value range to complete transparency:

![](./images/tf-white-skull.png)

Now we're getting somewhere, it nicely shows the skull (and other higher-valued parts, like the vertebrae and teeth). The skull is shown almost fully white, though, with no good way to grasp its shape (similar to lack of shadows showed earlier). This is due to the simple rendering used by default for volume rendering: it only composites mapped voxel colors onto each other, there's no advanced lighting being applied. Luckily, there's a setting to improve this. We can enable `Shade` in the **Volume Rendering** section:

![](./images/volren-shaded.png)

We can further tweak the colors of the different values in the transfer function, by clicking on a point in the color bar, pressing **`Enter`** and picking a more bone-like color:

![](./images/tf-color-edit.png)

By tweaking the transfer function a bit more we can get a nice view of the bone parts, in the context of the skin, and even highlighting the teeth a bit in white:

![](./images/tf-skull-and-skin.png)

As you can see there's a quite lot that can be achieved by editing the transfer function. In this case we used a one-dimensional function, mapping data value to color + opacity. Recent versions of ParaView have [added](https://www.kitware.com/advanced-multi-channel-volume-visualization-in-paraview/) the ability to use a two-dimensional transfer function, which has data value and associated gradient value as input. This allows finer control over appearance of specific parts of a volume.
Binary file added docs/images/raytracing-settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/rendering-default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/rendering-metal-copper-flat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/rendering-optix-16spp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/rendering-optix-4spp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/rendering-ospray-raycast-shadows.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/tf-2000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/tf-color-edit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/tf-default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/tf-skull-and-skin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/tf-white-skull.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/volren-shaded.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/wheel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/preparation.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ This directory will now have 4 datasets:
* __ALT_PRPB001A.vtk__: This file contains the results of a simulation of a coral growth. The scalars in this file represent the time of growth of a coral (this data is provided courtesy of Jaap Kaandorp , Section Computational Science, UvA).
* __SMRX.vtk__: This is a flow simulation of a viscous fluid through a stationary mixer (this data is provided courtesy of Drona Kandhai, Section Computational Science, UvA).

The remainder of this document contains four exercises based on these datasets.
Under the [Exercises](../exercise1) section there are four exercises based on these datasets.
3 changes: 2 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ nav:
- exercise2.md
- exercise3.md
- bonus.md
- scripting.md
- appearance.md
- scripting.md
- further-information.md
#- privacy.md

Expand Down
50 changes: 4 additions & 46 deletions notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,15 @@
12:40 – 13:00 * Q&A and closing (20 min)


-> add help ? tip
-> volume rendering TF editor in exercise?

can have multiple layouts in UI

line chart view, with Plot Data filter, can even do scatter plots


paraview state file
ALT...vtk file (coral growth)

Load file, isosurface
Save State to .pvsm file
clear scene, load pvsm

Second option: save state to .py file
Clear scene, load .py file

More flexible way: make trace
Start trace
Load file, contour, clip, save screenshot (don't embed state)
Show .py file
Note commented lines at the bottom of the script

Again, clear scene, load state from .py file
Notice head.png got written
can have multiple layouts in UI

Once more trace pipeline, this time save screenshot AND embed state
Load screenshot PNG file (identify -verbose head.png)
line chart view, with Plot Data filter, can even do scatter plots

Command-line: pvpython, pvbatch



Expand Down Expand Up @@ -72,16 +52,6 @@ node editor plugin, verbosity option
mention blender courses


https://www.paraview.org/Wiki/ParaView_Release_Notes

5.8 18-02-2020
5.9 28-01-2021
5.10 04-01-2022
5.11 17-11-2022
5.12 04-03-2024




https://www.kitware.com//matplotlib-view-coming-in-paraview-4-1/
https://www.kitware.com/paraview-python-view-is-now-more-versatile/
Expand Down Expand Up @@ -109,15 +79,3 @@ Can only have a single PythonView?
https://discourse.paraview.org/t/what-to-pass-as-view-for-python-view-call-render-function/9784/3





course chapters
- exercises
- explanatory
- reference material

slides
- explanatory

scripts for walkthroughs
Loading

0 comments on commit 2d5685d

Please sign in to comment.