Skip to content

Commit

Permalink
[render] Remove RenderEngineOspray entirely (RobotLocomotion#14339)
Browse files Browse the repository at this point in the history
* Remove RenderEngineOspray entirely

Other than killing the class, its factory, bindings, and their tests, this
also touches a fair amount of other sites in the code:

1. Documentation of various sorts have references to the render engine
   removed.
2. Build infrastructure removes explicit dependencies on OSPRay (and
   Embree).
3. Removed OSPRay-specific functionality from docker configuration.
  • Loading branch information
SeanCurtis-TRI authored Nov 17, 2020
1 parent 5cf50ff commit 2411116
Show file tree
Hide file tree
Showing 22 changed files with 19 additions and 2,545 deletions.
28 changes: 0 additions & 28 deletions bindings/pydrake/geometry_py.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include "drake/geometry/query_results/penetration_as_point_pair.h"
#include "drake/geometry/render/gl_renderer/render_engine_gl_factory.h"
#include "drake/geometry/render/render_engine.h"
#include "drake/geometry/render/render_engine_ospray_factory.h"
#include "drake/geometry/render/render_engine_vtk_factory.h"
#include "drake/geometry/render/render_label.h"
#include "drake/geometry/scene_graph.h"
Expand Down Expand Up @@ -382,33 +381,6 @@ void def_geometry_render(py::module m) {
m.def("MakeRenderEngineVtk", &MakeRenderEngineVtk, py::arg("params"),
doc.MakeRenderEngineVtk.doc);

{
using Class = OsprayMode;
constexpr auto& cls_doc = doc.OsprayMode;
py::enum_<Class>(m, "OsprayMode", cls_doc.doc)
.value("kRayTracer", Class::kRayTracer, cls_doc.kRayTracer.doc)
.value("kPathTracer", Class::kPathTracer, cls_doc.kPathTracer.doc);
}

{
using Class = RenderEngineOsprayParams;
constexpr auto& cls_doc = doc.RenderEngineOsprayParams;
py::class_<Class>(m, "RenderEngineOsprayParams", cls_doc.doc)
.def(ParamInit<Class>())
.def_readwrite("mode", &Class::mode, cls_doc.mode.doc)
.def_readwrite("default_diffuse", &Class::default_diffuse,
cls_doc.default_diffuse.doc)
.def_readwrite("background_color", &Class::background_color,
cls_doc.background_color.doc)
.def_readwrite("samples_per_pixel", &Class::samples_per_pixel,
cls_doc.samples_per_pixel.doc)
.def_readwrite(
"use_shadows", &Class::use_shadows, cls_doc.use_shadows.doc);
}

m.def("MakeRenderEngineOspray", &MakeRenderEngineOspray, py::arg("params"),
doc.MakeRenderEngineOspray.doc);

{
py::class_<RenderLabel> render_label(m, "RenderLabel", doc.RenderLabel.doc);
render_label
Expand Down
26 changes: 0 additions & 26 deletions bindings/pydrake/test/geometry_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,32 +599,6 @@ def test_render_engine_vtk_params(self):
self.assertEqual(params.default_label, label)
self.assertTrue((params.default_diffuse == diffuse).all())

def test_render_engine_opsray(self):
params = mut.render.RenderEngineOsprayParams()
self.assertEqual(params.mode, mut.render.OsprayMode.kPathTracer)
self.assertIs(params.default_diffuse, None)
self.assertIs(params.background_color, None)
self.assertEqual(params.samples_per_pixel, 1)
self.assertEqual(params.use_shadows, True)

params = mut.render.RenderEngineOsprayParams(
mode=mut.render.OsprayMode.kRayTracer,
default_diffuse=[0.1, 0.2, 0.3, 0.4],
background_color=[1., 1., 1.],
samples_per_pixel=2,
use_shadows=False,
)
self.assertEqual(params.mode, mut.render.OsprayMode.kRayTracer)
np.testing.assert_array_equal(
params.default_diffuse, [0.1, 0.2, 0.3, 0.4])
np.testing.assert_array_equal(params.background_color, [1., 1., 1])
self.assertEqual(params.samples_per_pixel, 2)
self.assertEqual(params.use_shadows, False)

# Acceptance-test construction of renderer.
renderer = mut.render.MakeRenderEngineOspray(params=params)
self.assertIsInstance(renderer, mut.render.RenderEngine)

def test_render_depth_camera_properties(self):
obj = mut.render.DepthCameraProperties(width=320, height=240,
fov_y=pi/6,
Expand Down
5 changes: 5 additions & 0 deletions doc/gallery.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ arbitrary fixed position in the simulation's world frame) of the controlled
The material properties are simple to highlight the impact of the lighting model.
(October 2018)

(Update 2020) The OSPRay-based renderer had an impoverished API and was little
used. For maintenance reasons, it has been removed. If, in the future, users
feel they'd like to have it back, please post an issue and we can investigate
its restoration and completion.

.. raw :: html
<iframe width="800" height="224" src="https://www.youtube.com/embed/UKxytyIJmq8" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
Expand Down
131 changes: 0 additions & 131 deletions geometry/benchmarking/render_benchmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <gflags/gflags.h>

#include "drake/common/filesystem.h"
#include "drake/geometry/render/render_engine_ospray_factory.h"
#include "drake/geometry/render/render_engine_vtk_factory.h"
#include "drake/systems/sensors/image_writer.h"

Expand Down Expand Up @@ -65,28 +64,12 @@ RenderEngineBenchmark/VtkDepth/1/1/640/480 1.35 ms
RenderEngineBenchmark/VtkDepth/1/10/640/480 13.0 ms 13.0 ms 50 // NOLINT(*)
RenderEngineBenchmark/VtkLabel/1/1/640/480 1.45 ms 1.45 ms 464 // NOLINT(*)
RenderEngineBenchmark/VtkLabel/1/10/640/480 26.1 ms 25.3 ms 37 // NOLINT(*)
RenderEngineBenchmark/OsprayRayColor/1/1/640/480 23.4 ms 22.7 ms 33 // NOLINT(*)
RenderEngineBenchmark/OsprayRayColor/4/1/640/480 28.8 ms 27.4 ms 23 // NOLINT(*)
RenderEngineBenchmark/OsprayRayColor/8/1/640/480 34.4 ms 32.9 ms 17 // NOLINT(*)
RenderEngineBenchmark/OsprayRayColor/1/10/640/480 193 ms 174 ms 3 // NOLINT(*)
RenderEngineBenchmark/OsprayRayColor/1/1/320/240 5.16 ms 5.09 ms 120 // NOLINT(*)
RenderEngineBenchmark/OsprayRayColor/1/1/1280/960 67.9 ms 65.2 ms 11 // NOLINT(*)
RenderEngineBenchmark/OsprayRayColor/1/1/2560/1920 283 ms 267 ms 2 // NOLINT(*)
RenderEngineBenchmark/OsprayRayColorShadowsOff/1/1/640/480 15.7 ms 15.7 ms 43 // NOLINT(*)
RenderEngineBenchmark/OsprayRayColorShadowsOff/4/1/640/480 20.0 ms 19.6 ms 30 // NOLINT(*)
RenderEngineBenchmark/OsprayRayColorShadowsOff/8/1/640/480 25.2 ms 25.2 ms 28 // NOLINT(*)
RenderEngineBenchmark/OsprayRayColorShadowsOff/1/10/640/480 162 ms 159 ms 4 // NOLINT(*)
RenderEngineBenchmark/OsprayPathColor/1/1/640/480 36.2 ms 35.3 ms 20 // NOLINT(*)
RenderEngineBenchmark/OsprayPathColor/1/10/640/480 351 ms 345 ms 2 // NOLINT(*)
```
Additional configuration is possible via the following flags:
- __save_image_path__: Enables saving the rendered images in the given
location. Defaults to no saving.
- __show_window__: Whether to display the rendered images. Defaults to false.
- __samples_per_pixel__: The number of illumination samples per pixel when path
tracing with RenderEngineOspray. Higher numbers introduce higher quality at
increased cost. Defaults to 1.
For example:
```
Expand All @@ -107,14 +90,6 @@ RenderEngineBenchmark/OsprayPathColor/1/10/640/480 351 ms
- __VtkColor__: Renders the color image from RenderEngineVtk.
- __VtkDepth__: Renders the depth image from RenderEngineVtk.
- __VtkLabel__: Renders the label image from RenderEngineVtk.
- __OsprayRayColor__: Renders the color image from RenderEngineOspray with
ray-traced shadows.
- __OsprayRayColorShadowsOff__: Renders the color image from
RenderEngineOspray without any shadows -- most closely approximates the
RenderEngineVtk color image.
- __OsprayPathColor__: Renders the color image from RenderEngineOspray with
path-traced global illumination (with only a single sample per pixel by
default, unless configured using --samples_per_pixel).
- __camera_count__: Simply the number of independent cameras being rendered.
The cameras are all co-located (same position, same view direction) so
they each render the same image.
Expand All @@ -137,8 +112,6 @@ RenderEngineBenchmark/OsprayPathColor/1/10/640/480 351 ms
for label.
- RenderEngineVtk also increased a factor of 10X when path-tracing the
scene when we increased the number of cameras by a factor of 10X.
- The number of objects in the scene has an apparently negligible impact on
RenderEngineVtk, but a noticeable impact on RenderEngineOspray.
*/

// Friend class for accessing RenderEngine's protected/private functionality.
Expand Down Expand Up @@ -169,8 +142,6 @@ using systems::sensors::SaveToTiff;
DEFINE_string(save_image_path, "",
"Enables saving rendered images in the given location");
DEFINE_bool(show_window, false, "Whether to display the rendered images");
DEFINE_int32(samples_per_pixel, 1,
"Number of illumination samples per pixel when path tracing");

// Default sphere array sizes.
const int kCols = 4;
Expand Down Expand Up @@ -205,24 +176,6 @@ class RenderEngineBenchmark : public benchmark::Fixture {
SetupScene(sphere_count, camera_count, width, height);
}

/* Set up the scene using the Ospray render engine.
@param sphere_count Number of spheres to include in the render.
@param camera_count Number of cameras to include in the render.
@param width Width of the render image.
@param height Height of the render image.
@param mode The OsprayMode, i.e. ray tracing or path tracing.
@param use_shadows Whether to render shadows when in ray tracing mode
(`OsprayMode::kRayTracer`). Ignored in path tracing mode.
*/
void SetupOsprayRender(const int sphere_count, const int camera_count,
const int width, const int height, OsprayMode mode,
bool use_shadows) {
RenderEngineOsprayParams params{
mode, {}, bg_rgb_, FLAGS_samples_per_pixel, use_shadows};
renderer_ = MakeRenderEngineOspray(params);
SetupScene(sphere_count, camera_count, width, height);
}

/* Parse arguments from the benchmark state.
@return A tuple representing the sphere count, camera count, width, and
height. */
Expand Down Expand Up @@ -395,90 +348,6 @@ BENCHMARK_REGISTER_F(RenderEngineBenchmark, VtkLabel)
->Args({1, 1, 640, 480}) // 1 sphere, 1 camera, 640 width, 480 height.
->Args({1, 10, 640, 480}); // 1 sphere, 10 cameras, 640 width, 480 height.

BENCHMARK_DEFINE_F(RenderEngineBenchmark, OsprayRayColor)
// NOLINTNEXTLINE(runtime/references)
(benchmark::State& state) {
auto [sphere_count, camera_count, width, height] = ReadState(state);
SetupOsprayRender(sphere_count, camera_count, width, height,
OsprayMode::kRayTracer, true);
for (auto _ : state) {
for (int i = 0; i < camera_count; ++i) {
renderer_->RenderColorImage(cameras_[i], FLAGS_show_window,
&color_image_);
}
}
if (!FLAGS_save_image_path.empty()) {
const std::string path_name =
image_path_name("OsprayRayColor", state, "png");
SaveToPng(color_image_, path_name);
saved_image_paths.insert(path_name);
}
}
BENCHMARK_REGISTER_F(RenderEngineBenchmark, OsprayRayColor)
->Unit(benchmark::kMillisecond)
->Args({1, 1, 640, 480}) // 1 sphere, 1 camera, 640 width, 480 height.
->Args({4, 1, 640, 480}) // 4 spheres, 1 camera, 640 width, 480 height.
->Args({8, 1, 640, 480}) // 8 spheres, 1 camera, 640 width, 480 height.
->Args({1, 10, 640, 480}) // 1 sphere, 10 cameras, 640 width, 480 height.
->Args({1, 1, 320, 240}) // 1 sphere, 1 camera, 320 width, 240 height.
->Args({1, 1, 1280, 960}) // 1 sphere, 1 camera, 1280 width, 960 height.
->Args({1, 1, 2560, 1920}); // 1 sphere, 1 camera, 2560 width, 1920 height.

BENCHMARK_DEFINE_F(RenderEngineBenchmark, OsprayRayColorShadowsOff)
// NOLINTNEXTLINE(runtime/references)
(benchmark::State& state) {
auto [sphere_count, camera_count, width, height] = ReadState(state);
SetupOsprayRender(sphere_count, camera_count, width, height,
OsprayMode::kRayTracer, false);
for (auto _ : state) {
for (int i = 0; i < camera_count; ++i) {
renderer_->RenderColorImage(cameras_[i], FLAGS_show_window,
&color_image_);
}
}
if (!FLAGS_save_image_path.empty()) {
const std::string path_name =
image_path_name("OsprayRayColorShadowsOff", state, "png");
SaveToPng(color_image_, path_name);
saved_image_paths.insert(path_name);
}
}
BENCHMARK_REGISTER_F(RenderEngineBenchmark, OsprayRayColorShadowsOff)
->Unit(benchmark::kMillisecond)
->Args({1, 1, 640, 480}) // 1 sphere, 1 camera, 640 width, 480 height.
->Args({4, 1, 640, 480}) // 4 spheres, 1 camera, 640 width, 480 height.
->Args({8, 1, 640, 480}) // 8 spheres, 1 camera, 640 width, 480 height.
->Args({1, 10, 640, 480}); // 1 sphere, 10 cameras, 640 width, 480 height.

BENCHMARK_DEFINE_F(RenderEngineBenchmark, OsprayPathColor)
// NOLINTNEXTLINE(runtime/references)
(benchmark::State& state) {
auto [sphere_count, camera_count, width, height] = ReadState(state);
SetupOsprayRender(sphere_count, camera_count, width, height,
OsprayMode::kPathTracer, true);
for (auto _ : state) {
// NOTE: The ospray renderer has a quirk; if no poses update, subsequent
// render passes seem to accumulate into the same frame buffer, artificially
// improving the image quality, like increasing the number of per-pixel
// samples.
renderer_->UpdatePoses(poses_);
for (int i = 0; i < camera_count; ++i) {
renderer_->RenderColorImage(cameras_[i], FLAGS_show_window,
&color_image_);
}
}
if (!FLAGS_save_image_path.empty()) {
const std::string path_name =
image_path_name("OsprayPathColor", state, "png");
SaveToPng(color_image_, path_name);
saved_image_paths.insert(path_name);
}
}
BENCHMARK_REGISTER_F(RenderEngineBenchmark, OsprayPathColor)
->Unit(benchmark::kMillisecond)
->Args({1, 1, 640, 480}) // 1 sphere, 1 camera, 640 width, 480 height.
->Args({1, 10, 640, 480}); // 1 sphere, 10 cameras, 640 width, 480 height.

void Cleanup() {
if (!RenderEngineBenchmark::saved_image_paths.empty()) {
std::cout << "Saved rendered images to:" << std::endl;
Expand Down
1 change: 0 additions & 1 deletion geometry/geometry_roles.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ class ProximityProperties final : public GeometryProperties {
Examples of functionality that depends on the perception role:
- render::RenderEngineVtk
- render::RenderEngineOspray
*/
class PerceptionProperties final : public GeometryProperties{
public:
Expand Down
57 changes: 0 additions & 57 deletions geometry/render/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ drake_cc_package_library(
":camera_properties",
":render_camera",
":render_engine",
":render_engine_ospray",
":render_engine_vtk",
":render_engine_vtk_base",
":render_label",
Expand Down Expand Up @@ -65,41 +64,6 @@ drake_cc_library(
],
)

# The VTK-OSPRay-based render engine implementation.
drake_cc_library(
name = "render_engine_ospray",
srcs = [
"render_engine_ospray.cc",
"render_engine_ospray_factory.cc",
],
hdrs = [
"render_engine_ospray.h",
"render_engine_ospray_factory.h",
],
# render_engine_ospray.h directly pulls in VTK headers; leave it out of the
# install.
install_hdrs_exclude = ["render_engine_ospray.h"],
deps = [
":render_engine",
":render_engine_vtk_base",
"//common",
"//systems/sensors:color_palette",
"//systems/sensors:vtk_util",
"@eigen",
"@vtk//:vtkCommonCore",
"@vtk//:vtkCommonDataModel",
"@vtk//:vtkCommonTransforms",
"@vtk//:vtkFiltersGeneral",
"@vtk//:vtkFiltersSources",
"@vtk//:vtkIOGeometry",
"@vtk//:vtkIOImage",
"@vtk//:vtkRenderingCore",
"@vtk//:vtkRenderingOSPRay",
"@vtk//:vtkRenderingOpenGL2",
"@vtk//:vtkRenderingSceneGraph",
],
)

# The VTK-OpenGL-based render engine implementation.
drake_cc_library(
name = "render_engine_vtk",
Expand Down Expand Up @@ -207,27 +171,6 @@ drake_cc_googletest(
],
)

drake_cc_googletest(
name = "render_engine_ospray_test",
data = [
":test_models",
"//systems/sensors:test_models",
],
# This generally flakes on CI for unknown reasons.
flaky = 1,
tags = vtk_test_tags() + [
# OSPRay uses TBB which is not tsan-friendly.
"no_tsan",
],
deps = [
":render_engine_ospray",
"//common:find_resource",
"//common/test_utilities:eigen_matrix_compare",
"//common/test_utilities:expect_throws_message",
"//math:geometric_transform",
],
)

drake_cc_googletest(
name = "render_engine_vtk_test",
data = [
Expand Down
Loading

0 comments on commit 2411116

Please sign in to comment.