gz-rendering
gz-rendering copied to clipboard
Update ogre2 implementation of Projector to project texture based on a frustum
Environment
- OS Version: Ubuntu 22.04
- Source or binary build? Source build 91f5fe954197a61a3c520c7b92a4f64f7bb2403e
The projected texture in the ogre2 implementation of Projector differs from ogre1.x's and we need to update the ogre2 implementation to match ogre1.x's.
Related PR: https://github.com/gazebosim/gz-rendering/pull/845
From the PR description:
- The ogre 1.x implementation is ported from gazebo-classic's Projector class. It uses ogre material projective texturing feature.
- in addition, I extended the implementation to support visibility flags so that we can toggle the visibility of the projected texture based on the camera's visibility mask.
- The ogre 2.x implementation uses screen space decals (instead of projective texturing) and has a different behavior.
Also added support for setting visibility flags.
- Note: There is one major caveat with this implementation. The projection is not in the form of a "frustum" (i.e. projection becomes larger at longer distance). It uses ogre 2.x screen space decals. Think of a as a rectangular volume and any surface that intersects with the volume will have the texture mapped onto it.
- We will need to investigate whether it's possible to change the implementation to match the ogre 1.x behavior in the future. Here is a related ogre forum post asking the same question. I will create an issue to track this limitation once the PR is merged.
Description
- Expected behavior: The projected texture should be based on a frustum
- Actual behavior: Projection is done based on a rectangular volume (bounding box)
Steps to reproduce
- Build and the projector example.
- Run with
ogre2
:./projector ogre2
and see that the projection is a rectangular volume - Run with
ogre
:./projector ogre
and see that the projector has a proper frustum, i.e. the further surface the larger the projection.
Output
See screenshots in https://github.com/gazebosim/gz-rendering/pull/845