Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to toggle frustum culling in replay renderer. #2199

Merged
merged 2 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/esp/bindings/SimBindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,9 @@ void initSimBindings(py::module& m) {
R"(List of sensor specifications for one simulator. For batch rendering, all simulators must have the same specification.)")
.def_readwrite("gpu_device_id", &ReplayRendererConfiguration::gpuDeviceId,
R"(The system GPU device to use for rendering)")
.def_readwrite("enable_frustum_culling",
0mdc marked this conversation as resolved.
Show resolved Hide resolved
&ReplayRendererConfiguration::enableFrustumCulling,
R"(Controls whether frustum culling is enabled.)")
.def_readwrite(
"force_separate_semantic_scene_graph",
&ReplayRendererConfiguration::forceSeparateSemanticSceneGraph,
Expand Down
2 changes: 2 additions & 0 deletions src/esp/sim/AbstractReplayRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class ReplayRendererConfiguration {
*/
bool leaveContextWithBackgroundRenderer = false;

bool enableFrustumCulling = true;
0mdc marked this conversation as resolved.
Show resolved Hide resolved

std::vector<std::shared_ptr<sensor::SensorSpec>> sensorSpecifications;

ESP_SMART_POINTERS(ReplayRendererConfiguration)
Expand Down
20 changes: 13 additions & 7 deletions src/esp/sim/ClassicReplayRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,14 @@ void ClassicReplayRenderer::doRender(
}

#ifdef ESP_BUILD_WITH_BACKGROUND_RENDERER
esp::gfx::RenderCamera::Flags flags{};
if (config_.enableFrustumCulling) {
flags |= gfx::RenderCamera::Flag::FrustumCulling;
}
0mdc marked this conversation as resolved.
Show resolved Hide resolved

if (imageViews.size() > 0) {
renderer_->enqueueAsyncDrawJob(
visualSensor, sceneGraph, imageViews[envIndex],
esp::gfx::RenderCamera::Flags{
gfx::RenderCamera::Flag::FrustumCulling});
renderer_->enqueueAsyncDrawJob(visualSensor, sceneGraph,
imageViews[envIndex], flags);
}
#else
// TODO what am I supposed to do here?
Expand All @@ -258,6 +261,10 @@ void ClassicReplayRenderer::doRender(
void ClassicReplayRenderer::doRender(
Magnum::GL::AbstractFramebuffer& framebuffer) {
const Mn::Vector2i gridSize = environmentGridSize(config_.numEnvironments);
esp::gfx::RenderCamera::Flags flags{};
if (config_.enableFrustumCulling) {
flags |= gfx::RenderCamera::Flag::FrustumCulling;
}
0mdc marked this conversation as resolved.
Show resolved Hide resolved

for (int envIndex = 0; envIndex < config_.numEnvironments; envIndex++) {
auto& sensorMap = getEnvironmentSensors(envIndex);
Expand All @@ -269,9 +276,8 @@ void ClassicReplayRenderer::doRender(
visualSensor.renderTarget().renderEnter();

auto& sceneGraph = getSceneGraph(envIndex);
renderer_->draw(
*visualSensor.getRenderCamera(), sceneGraph,
esp::gfx::RenderCamera::Flags{gfx::RenderCamera::Flag::FrustumCulling});

renderer_->draw(*visualSensor.getRenderCamera(), sceneGraph, flags);

if (envIndex == 0 && debugLineRender_) {
auto* camera = visualSensor.getRenderCamera();
Expand Down