Added option to render a texture (e.g. Sensor output) as main image in the viewer - #3811
Added option to render a texture (e.g. Sensor output) as main image in the viewer#3811daniela-hase wants to merge 5 commits into
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough
ChangesMain image viewer rendering
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@newton/_src/viewer/gl/opengl.py`:
- Around line 1392-1458: Update the main-image rendering path around the
framebuffer setup and texture-drawing loop to bind and render into
renderer._frame_fbo instead of the default framebuffer, so ViewerGL.get_frame()
reads the selected image. Preserve the existing screen presentation behavior as
needed after rendering, and add a headless get_frame() regression test covering
a main-image frame.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro Plus
Run ID: 396b22bc-0b88-470f-9721-9e2c74894daf
📒 Files selected for processing (10)
changelog/+viewer-main-image-18cc9933.added.mddocs/guide/visualization.rstnewton/_src/viewer/gl/image_logger.pynewton/_src/viewer/gl/opengl.pynewton/_src/viewer/gl/shaders.pynewton/_src/viewer/viewer_gl.pynewton/examples/sensors/example_sensor_tiled_camera.pynewton/tests/test_example_sensor_tiled_camera.pynewton/tests/test_viewer_image_logger.pynewton/tests/test_viewer_main_image.py
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@newton/tests/test_viewer_get_frame.py`:
- Around line 117-121: Update the ViewerGL construction handling in the test
around newton.viewer.ViewerGL to catch only the specific exception(s) indicating
an unavailable graphics backend, preserving the existing skip behavior for those
cases. Remove the broad Exception catch so unexpected headless initialization
failures propagate and fail the test.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro Plus
Run ID: 1fec9a5d-94cb-4546-9c14-be6aca5d6dcb
📒 Files selected for processing (2)
newton/_src/viewer/gl/opengl.pynewton/tests/test_viewer_get_frame.py
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
Instead of a new function could we make this an option on the In general we should name things with common prefixes so they're grouped together, e.g.: |
|
Also a little surprised at the size of this change, if it's just adding a docked image log function then do we really need all the internal refactoring as well? Given the late stage of the PR it would be good to keep it as minimal as possible. |
Description
Adds the ability to render an arbitrary logged image — e.g. a
SensorTiledCameracolor output — as the main viewer surface for a frame, instead of the 3D scene.
A new
ViewerGL.log_main_image(name, image)method logs an image (via the existingImageLogger) and marks it as the frame's main surface. Duringend_frame,ViewerGLthen draws that image texture directly to the window and skips the 3Dscene render, while keeping the UI available on top. The selection is per-frame: if
a later frame does not call
log_main_image(), the viewer returns to normal 3Dscene rendering automatically.
Supporting changes:
RendererGL.render_texture()draws a texture (single image or a packed tileatlas) directly to the window, laying tiles out with
compute_grid_layoutandcentering them, or clearing the window when no texture is available.
uv_rectuniform so a sub-rectangle of an atlas texturecan be sampled per tile (default identity rect preserves the existing full-frame
blit).
ImageLogger.get_texture()exposes live GL texture metadata(
LoggedImageTexture), andImageLogger.draw()accepts ahidden_nameso theimage currently shown as the main surface isn't also drawn as a floating overlay
window.
example_sensor_tiled_cameraexample gains a "Sensor Color as Main View"toggle demonstrating the feature, defaulting on when the viewer supports it and
falling back gracefully to overlay logging otherwise.
Checklist
changelog fragment instructions
Test plan
test_viewer_main_imagecovers the UV atlas flip, all three_updaterenderbranches (main-image texture, missing-image clear, normal scene), and the public
log_main_imagelogging/selection and empty-name rejection.test_viewer_image_loggercoversget_texturereturning live metadata andreturning
Nonefor missing/uninitialized images.test_example_sensor_tiled_cameracovers the example's main-view toggle, overlayfallback, viewers without main-image support, and the GUI checkbox.
Manually verified in the GL viewer by running the sensor example and toggling
"Sensor Color as Main View".
New feature / API change
Summary by CodeRabbit
New Features
Documentation