ANN: Examples for Physically Based Rendering

After reading this impressive article: Introducing Physically Based Rendering with VTK. I created a couple of examples (both in C++ and Python) that (I hope) capture most of what has been written in the articles.

In the examples you can select different surfaces to visualise: Boy’s Surface (default), Mobius Strip, Torus, Sphere and Cube. The non-orientable surfaces are interesting e.g. in the case of Boy’s Surface on the left side you see reflections of the sky even though the surface is angled to the ground at that point.

You can also select different skyboxes, the images are found in VTKExamples/Testing/Data/skyboxes/. Try different skyboxes! For texturing the images are found in VTKExamples/Testing/Data/

Here are the C++ examples, links to the corresponding Python examples can be found on these pages:

  1. Skybox_PBR
    TestSkybox_PBR
    These sliders set metallicity and roughness of the object:

  2. PhysicallyBasedRenderingTestPhysicallyBasedRendering

    Here texturing is used to generate lighting effects. The sliders allow you to adjust: metallicity, roughness, occlusion strength and normal scaling

6 Likes

Impressive work, impressive examples. Thanks for doing this @amaclean !

Awesome, thank you @amaclean !
I would be very happy to have your feedback regarding PBR. Did you have difficulty using it? Is the documentation sufficient? Is everything clear in the blog article?

@Michael, in relation to the first example, the documentation was pretty clear and straightforward. I must admit, I was pretty pleased when it all worked and the results looked so beautiful.

In relation to the texturing example I had to feel my way a bit, I searched the VTK repository to find the textures used in the picture in the article. I was also unfamiliar with the terminology. My biggest problem was finding an emissive texture so I used Photoshop to modify the VTK logo and convert it to a black background. You will see I kept the bars around the letters as they gave me an indication of the lighting colour when setting the emissive factor.

With respect to the sources used, it was interesting to do uv-texturing on the parametric surfaces. Once I figured this out, the texturing of these surfaces was easy! For debugging texturing I found your files: tex_debug.jpg and vtk_Base_Color.png useful.

I learned a lot from your well written article.

One other big bonus from the work you guys have done is that it was really simple to convert the C++ code to Python as you can see in the examples.

@Michael it goes without saying that if the examples can be enhanced/improved please submit merge requests.

Thank you for the feedback and I will definitely have a look at your examples code when I find the time.

Thank you for this example!
Is it possible to use data arrays to steer the PBR parameters similar to the ActiveScalars for pointsets?
This could then be another helpful example for data that does not come with texture coordinates but has per vertex attributes.

Absolutely, you can add scalar coloring with PBR. Here is a simple wavelet isosurface having an elevation field (top dielectric, bottom metallic).

@Michael Thanks for the quick response. What I meant was to assign per vertex values for the metallic and roughness parameters as well. I want to avoid the textures but still have spatially varying PBR parameters.

This is something we have considered and I think this would be something very useful but we have no funding yet for this feature.

Thanks for your answer. Do you think it is worth trying to find a workaround? (something like trying to map the data array manually to the shader inputs in the PolyDataMapper)

Yes, you can hack something easily if you have enough shader development skill.
Send your arrays to the shader inputs and modify the fragment shader code to get interpolated value from your custom vertex attributes to set roughness/metallic. You will need to modify the vertex shader as well to transfer your attribute to the fragment shader.

Thanks for these hints! (Still hoping to see this feature sometime in vtk 9.x :wink: )

Update:

I have renamed the examples:

It makes more sense logically and also for testing. Also you can now read in HDR skyboxes to produce nice hi-res images. There are some nice ones here Poly Haven.

I hope to have an anisotropic texturing example done real soon, it wil be called … wait for it … PBR_Skybox_Anisotropy, thanks to @Lfx_Paul for the anisotropic textures.

2 Likes

Sweet !!

Looks cool, how do you zoom-out the cubemap? In the rendering it appears zoomed-in and low resolution compared to the original. Colors also look a bit different.

Screenshot from 2021-08-10 13-51-47

  1. You can only zoom in/out of objects that you place in the scene. The skybox is essentially at infinity.
  2. That 4k image is quite blurry, this is not a VTK issue, try other ones. I also verified this using ParaView.
  3. I will be updating these examples later today, introducing tone mapping into them, among other things. With tone mapping you will be able to control exposure and contrast.

I have reworked the PBR examples, thanks to @Lfx_Paul for the anisttropic textures and to @Timothee_Chabat for some insightful comments.

Please look at:

There are also corresponding Python examples.

The major changes are:

  • A hi-res skybox is now used.
  • The default VTK lighting is now switched off and the objects are just illuminated by the skybox.
  • You can now vary the exposure, thanks to vtkToneMappingPass.
  • A gamma correction is now applied to the skybox.
  • The vtkCameraOrientationWidget has also been added.

Enjoy a day at the beach with some “interesting” objects:

6 Likes

:heart_eyes:

Great work @amaclean !