-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Add Image constructor specialised for rendering to a texture #17209
base: main
Are you sure you want to change the base?
Conversation
@BenjaminBrienen I've "rebased" this |
Co-authored-by: Antony <[email protected]>
Shouldn't hard code to default the texture format. HDR cameras need a different format. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also update headless_renderer, gpu_readback, and compute_shader_game_of_life
I think those are all the examples that use this pattern.
(Sorry, that wasn't an approve, just a comment)
Yeah, this should either take a |
So to clarify, the suggestion is to either:
|
In the discord there were a few comments:
if (hdr) {
ViewTarget::TEXTURE_FORMAT_HDR
} else {
TextureFormat::bevy_default()
} For now I have left the constructor in |
I've done this but the discrepancies make me think maybe these should have their own helper constructors, possibly with guidance in the doc comment.
|
Objective
Fixes #7358
Redo of #7360
Ergonomics. There's a bunch of enigmatic boilerplate for constructing a texture for rendering to, which could be greatly simplified for the external user-facing API.
Solution
Image
, with minimal changes beyond theDefault
implementation.Strictly speaking, there are two small differences between the constructor and the example:
1. The example sets thesize
when initially constructing theImage
, thenresize
s, butresize
sets thesize
anyway so we don't need to do this extra step.2. The example setsImage.texture_descriptor.format
toTextureFormat::Bgra8UnormSrgb
, but the default impl sets this toTextureFormat::Rgba8UnormSrgb
viawgpu::TextureFormat::bevy_default()
. I don't know what sort of impact this has, but it works on my machine.I've deliberately chosen to only include
width
andheight
as parameters, but maybe it makes sense for some of the other properties to be exposed as parameters.Changelog
Added
Added
Image::new_target_texture
constructor for simpler creation of render target textures.Notes:
Image
constructor specialised for rendering to a texture #7360 - there's some relevant discussion on code style there.bevy_render::camera::Camera
andbevy_render::camera::RenderTarget::Image
.bevy_image
used to be part ofbevy_render
and was split out in the past, andbevy_image
doesn't depend onbevy_render
. What's the recommendation here?