bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Add RenderTarget::TextureView

Open mrchantey opened this issue 1 year ago • 2 comments

Objective

We can currently set camera.target to either an Image or Window. For OpenXR & WebXR we need to be able to render to a TextureView.

This partially addresses #115 as with the addition we can create internal and external xr crates.

Solution

A TextureView item is added to the RenderTarget enum. It holds an id which is looked up by a ManualTextureViews resource, much like how Assets<Image> works. I believe this approach was first used by @kcking in their xr fork. The only change is that a u32 is used to index the textures as FromReflect does not support uuid and I don't know how to implement that.


Changelog

Added

Render: Added RenderTarget::TextureView as a camera.target option, enabling rendering directly to a TextureView.

Migration Guide

References to the RenderTarget enum will need to handle the additional field, ie in match statements.


Comments

  • The wgpu work done by @expenses allows us to create framebuffer texture views from wgpu v0.15, bevy 0.10.
  • I got the WebXR techniques from the xr fork by @dekuraan.
  • I have tested this with a wip external webxr crate on an Oculus Quest 2.

Screenshot 2023-03-11 230651

mrchantey avatar Mar 11 '23 12:03 mrchantey

Welcome, new contributor!

Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨

github-actions[bot] avatar Mar 11 '23 12:03 github-actions[bot]

It looks like your PR is a breaking change, but you didn't provide a migration guide.

Could you add some context on what users should update when this change get released in a new version of Bevy? It will be used to help writing the migration guide for the version. Putting it after a ## Migration Guide will help it get automatically picked up by our tooling.

github-actions[bot] avatar Mar 11 '23 18:03 github-actions[bot]

Bumping

MalekiRe avatar May 03 '23 22:05 MalekiRe

So, the implementation seems good to me, but I'm not sure I understand why this is necessary. Isn't the Image render target just a wrapper around targetting a TextureView? As in, couldn't you just use the render to image feature and use the texture view of the image?

IceSentry avatar Jun 11 '23 19:06 IceSentry

So, the implementation seems good to me, but I'm not sure I understand why this is necessary. Isn't the Image render target just a wrapper around targetting a TextureView? As in, couldn't you just use the render to image feature and use the texture view of the image?

There's a quick discord conversation about this, essentially OpenXR requires you to use its TextureViews, you can't provide your own. AFAIU bevy's render to image feature creates new TextureViews so it's incompatible with OpenXR

kcking avatar Jun 11 '23 19:06 kcking

Alright, makes sense. In that case this PR seems fine.

IceSentry avatar Jun 11 '23 19:06 IceSentry

Straightforward enough, and on the critical path. Let's see what the community can do with this <3

alice-i-cecile avatar Jun 19 '23 13:06 alice-i-cecile