bevy
bevy copied to clipboard
Add RenderTarget::TextureView
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.
Welcome, new contributor!
Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨
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.
Bumping
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?
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 TextureView
s, you can't provide your own. AFAIU bevy's render to image feature creates new TextureView
s so it's incompatible with OpenXR
Alright, makes sense. In that case this PR seems fine.
Straightforward enough, and on the critical path. Let's see what the community can do with this <3