Skip to content

Commit 7acea96

Browse files
Fix rendering energy loss via correcting VTK usage
Drake was misusing VTK in two ways (one was very much self inflicted). This PR corrects that. 1. Eliminate an erroneous patch. 2. Set the skybox to use gamma correction, even for hdr images. This will have an immediate change on rendered outputs -- images will be brighter. The lighting configuration tutorial has been updated accordingly. Current camera configurations will need to be updated, especially with respect to their exposure values and lighting levels. Renderings for which high exposure values seemed necessary will now seem oversaturated. Furthermore, with more energy coming from the environment map, lights may need to be brighter to have a comparable effect as before. (Note: there are still a couple of issues remaining that are intrinsic to VTK's implementation. See issue #23772 for details.)
1 parent 5bcea4e commit 7acea96

File tree

4 files changed

+17
-46
lines changed

4 files changed

+17
-46
lines changed

geometry/render_vtk/internal_render_engine_vtk.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -952,8 +952,7 @@ void RenderEngineVtk::InitializePipelines() {
952952
// environment map.
953953
skybox->SetFloorRight(0, -1, 0);
954954
skybox->SetProjection(vtkSkybox::Sphere);
955-
// Linear color space (aka *not HDR*) requires gamma correction.
956-
skybox->SetGammaCorrect(!env_map.is_hdr);
955+
skybox->GammaCorrectOn();
957956
renderer->AddActor(skybox);
958957
}
959958
// Setting an environment map should require all materials to be PBR.

tools/workspace/vtk_internal/patches/upstream/rendering_opengl2_scaled_albedo_for_ibl.patch

Lines changed: 0 additions & 37 deletions
This file was deleted.

tools/workspace/vtk_internal/repository.bzl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ def vtk_internal_repository(
194194
# - Use alphabetical order within a directory when listing patches.
195195
":patches/upstream/common_core_rm_iostream.patch",
196196
":patches/upstream/rendering_core_vtkcomposite_exception.patch",
197-
":patches/upstream/rendering_opengl2_scaled_albedo_for_ibl.patch",
198197
":patches/upstream/utilities_x11_more_functions.patch",
199198
":patches/common_core_fmt12.patch",
200199
":patches/common_core_fmt9.patch",

tutorials/configuring_rendering_lighting.ipynb

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1692,7 +1692,10 @@
16921692
"\n",
16931693
"# Center on the balls, filling the frame.\n",
16941694
"comparator.pose_camera_once(camera_in_world=[0, -3.5, 2],\n",
1695-
" target_in_world=[0, 0, 2])"
1695+
" target_in_world=[0, 0, 2])\n",
1696+
"\n",
1697+
"# Restore Meshcat exposure levels.\n",
1698+
"meshcat.SetProperty(\"/Render Settings/<object>\", \"exposure\", 1)"
16961699
]
16971700
},
16981701
{
@@ -2457,6 +2460,7 @@
24572460
"env = RenderEngineSpec(\n",
24582461
" \"Iteration 1\",\n",
24592462
" {\n",
2463+
" \"exposure\": 2,\n",
24602464
" \"lights\": [\n",
24612465
" LightParameter(type=\"directional\", frame=\"world\", direction=[0, 1, 0], intensity=10),\n",
24622466
" ],\n",
@@ -2491,6 +2495,7 @@
24912495
"env = RenderEngineSpec(\n",
24922496
" \"Iteration 2\",\n",
24932497
" {\n",
2498+
" \"exposure\": 2,\n",
24942499
" \"lights\": [\n",
24952500
" LightParameter(type=\"directional\", frame=\"world\", direction=[0, 1, -.5], intensity=10),\n",
24962501
" ],\n",
@@ -2522,6 +2527,7 @@
25222527
"env = RenderEngineSpec(\n",
25232528
" \"Iteration 3\",\n",
25242529
" {\n",
2530+
" \"exposure\": 2,\n",
25252531
" \"cast_shadows\": True,\n",
25262532
" \"lights\": [\n",
25272533
" LightParameter(type=\"directional\", frame=\"world\", direction=[0, 1, -.5], intensity=10),\n",
@@ -2555,6 +2561,7 @@
25552561
" \"Iteration 4\",\n",
25562562
" {\n",
25572563
" \"environment_map\": EnvironmentMap(texture=EquirectangularMap(path=hdr_path)),\n",
2564+
" \"exposure\": 2,\n",
25582565
" \"cast_shadows\": True,\n",
25592566
" \"lights\": [\n",
25602567
" LightParameter(type=\"directional\", frame=\"world\", direction=[0, 1, -.5], intensity=10),\n",
@@ -2582,15 +2589,18 @@
25822589
"metadata": {},
25832590
"outputs": [],
25842591
"source": [
2585-
"# Final configuration: Tone down the window light; we only want faint shadows from the window.\n",
2592+
"# Final configuration: Correct two things:\n",
2593+
"# 1. The shadows are more pronounced than we want. Dim the light to reduce the strength of the shadow.\n",
2594+
"# 2. The exposure value was set based *only* on the environment map. Adding the window light has made the scene\n",
2595+
"# over exposed. Reduce the exposure to return back to the desired levels.\n",
25862596
"env = RenderEngineSpec(\n",
25872597
" \"Iteration 5\",\n",
25882598
" {\n",
25892599
" \"environment_map\": EnvironmentMap(texture=EquirectangularMap(path=hdr_path)),\n",
25902600
" \"cast_shadows\": True,\n",
2591-
" \"exposure\": 3,\n",
2601+
" \"exposure\": 1.5,\n",
25922602
" \"lights\": [\n",
2593-
" LightParameter(type=\"directional\", frame=\"world\", direction=[0, 1, -.5], intensity=1),\n",
2603+
" LightParameter(type=\"directional\", frame=\"world\", direction=[0, 1, -.5], intensity=3.5),\n",
25942604
" ],\n",
25952605
" }\n",
25962606
")\n",
@@ -2632,13 +2642,13 @@
26322642
" \"cast_shadows\": True,\n",
26332643
" \"shadow_map_size\": 1024,\n",
26342644
" # With additional lights, we reduce exposure.\n",
2635-
" \"exposure\": 2,\n",
2645+
" \"exposure\": 1, # more lights --> reduced exposure.\n",
26362646
" \"lights\": [\n",
26372647
" LightParameter(**(ceiling_light | {\"position\": [-1, 1, 3.0]})),\n",
26382648
" LightParameter(**(ceiling_light | {\"position\": [-1, -1, 3.0]})),\n",
26392649
" LightParameter(**(ceiling_light | {\"position\": [1, 1, 3.0]})),\n",
26402650
" LightParameter(**(ceiling_light | {\"position\": [1, -1, 3.0]})),\n",
2641-
" LightParameter(type=\"directional\", frame=\"world\", direction=[0, 1, -.5], intensity=1),\n",
2651+
" LightParameter(type=\"directional\", frame=\"world\", direction=[0, 1, -.5], intensity=5),\n",
26422652
" ],\n",
26432653
"}\n",
26442654
"env = RenderEngineSpec(\"Full Lighting\", render_config)\n",

0 commit comments

Comments
 (0)