Falcor icon indicating copy to clipboard operation
Falcor copied to clipboard

Aspect ratio is not applied to scene in Testbed

Open julcst opened this issue 1 month ago • 0 comments

Testbed does not apply the current aspect ratio of the framebuffer to the scene camera.

Proposed fix:

// ...existing code...
void Testbed::loadScene(const std::filesystem::path& path, SceneBuilder::Flags buildFlags)
{
    mpScene = SceneBuilder(mpDevice, path, Settings(), buildFlags).getScene();

+   // Ensure scene camera matches current target FBO aspect
+   if (mpScene && mpTargetFBO)
+       mpScene->setCameraAspectRatio(mpTargetFBO->getWidth() / float(mpTargetFBO->getHeight()));

    if (mpRenderGraph)
        mpRenderGraph->setScene(mpScene);
}
// ...existing code...

void Testbed::loadSceneFromString(const std::string& scene, const std::string extension, SceneBuilder::Flags buildFlags)
{
    mpScene = SceneBuilder(mpDevice, scene.data(), scene.length(), extension, Settings(), buildFlags).getScene();

+   // Ensure scene camera matches current target FBO aspect
+   if (mpScene && mpTargetFBO)
+       mpScene->setCameraAspectRatio(mpTargetFBO->getWidth() / float(mpTargetFBO->getHeight()));

    if (mpRenderGraph)
        mpRenderGraph->setScene(mpScene);
}
// ...existing code...

julcst avatar Nov 19 '25 17:11 julcst