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

WideAngleCamera cube map texture pixel format should be customizable #2928

Closed
scpeters opened this issue Jan 27, 2021 · 7 comments · Fixed by #2960
Closed

WideAngleCamera cube map texture pixel format should be customizable #2928

scpeters opened this issue Jan 27, 2021 · 7 comments · Fixed by #2960

Comments

@scpeters
Copy link
Member

The rendering::WideAngleCamera::CreateEnvRenderTexture function creates an envCubeMapTexture using the same pixel format as the output image. For advanced users who write their own shaders, it can be necessary to use a floating point pixel format for the cube map texture even if the output image uses integers, for example to avoid integer overflow. I think it would be convenient to specify this in SDFormat as a env_texture_format parameter that is a sibling to the //camera/lens/env_texture_size element.

@scpeters
Copy link
Member Author

Intending to target this at gazebo9 and gazebo11

@iche033
Copy link
Contributor

iche033 commented Jan 28, 2021

the proposed approach should work. One thing to note is that with //camera/lens/env_texture_size we're getting into implementation details on internal / intermediate texture formats. I'm not sure if the param would be useful other consumers of sdformat since they may decide to implement wide angle cameras differently.

Other options include:

  • setting the format to Ogre::PF_FLOAT32_RGB here in gazebo classic and wide angle cameras should still work - it just uses more memory.
  • Provide a WideAngleCameraClass::SetEnvTexFormat function for users to set through plugins. The downside of this approach is that we'll need to recreate the env textures when users sets a different format.

@scpeters
Copy link
Member Author

  • setting the format to Ogre::PF_FLOAT32_RGB here in gazebo classic and wide angle cameras should still work - it just uses more memory.

I'll try this and see if I can quantify the memory impacts

@scpeters
Copy link
Member Author

  • setting the format to Ogre::PF_FLOAT32_RGB here in gazebo classic and wide angle cameras should still work - it just uses more memory.

I'll try this and see if I can quantify the memory impacts

I tried this earlier today with a pair of wide-angle cameras with 2048x2048 resolution with a target update rate of 30 Hz. When using the same intermediate pixel format, I was able to reach 30 frames per second easily, but when using FLOAT32 for the cube map texture, it dropped the frame rate by a factor of 10 to less than 3 frames per second. According to nvidia-smi, it also increased the GPU memory usage of gzserver by a little over 1 GB, but I think the performance hit is the most significant factor.

This will need to be configurable.

@scpeters
Copy link
Member Author

scpeters commented Feb 1, 2021

I'll try adding an API for plugins as well as a custom namespaced element like //camera/lens/gazebo:env_texture_format

@scpeters
Copy link
Member Author

scpeters commented Feb 4, 2021

I've created a branch that sets the texture format based on the custom element //camera/lens/gazebo:env_texture_format in scpeters@d3793e3

In terms of adding an API for setting the texture format programmatically, is it possible to change the texture after the camera has been initialized? This seems a bit more complicated to me

@iche033
Copy link
Contributor

iche033 commented Feb 4, 2021

I think you'll need to remove the existing texture and then create a new one with the new format

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants