-
-
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
[Merged by Bors] - Add capability to render to a texture #3412
Conversation
f46aeec
to
e814a8a
Compare
This looks quite nice to me, and should be very useful. It looks like there's just MSAA support left to add and then this should be ready to merge? |
I may leave MSAA for a later PR, because it didn't work on the old renderer and may be significantly more work. I will need MSAA support, so it'll get added eventually. The missing piece for this PR is a working example in |
edab9e8
to
4de71ea
Compare
862668f
to
fbd7c86
Compare
Co-authored-by: Johan Klokkhammer Helsing <johanhelsing@gmail.com>
332589f
to
aa7c0d0
Compare
This is great and I think I'd like to merge it as-is because it is small, straightforward, and extremely useful as written. But I do think we need to revisit what a "render target" is conceptually. I think users should be able to utilize render targets to draw to textures (or other windows) without touching the render app / graph (or understanding its underlying structure) at all. A RenderTarget should be "an entity created by a user that correlates to a Window or Texture, which by default runs the 'default render graph logic', but specialized for each target". This means everything runs by default (ui, 2d, 3d, user defined passes, post processing, etc). It follows that Cameras cannot own a RenderTarget because more than one camera is required to render the "default behavior". RenderTargets should drive execution of Render Graphs and clear passes, not Cameras / Views. Cameras / Views should correlate to RenderTargets. This also solves the "ClearColor mapping" problem, because we can add a ClearColor component to RenderTargets. This would also solve the weirdness in the This does create a number of questions:
I think I'm down to merge this right now so we can start ironing out the various kinks unrelated to user-facing apis (such as per-target lights) and unblock people that need the feature asap. The only change I'd request is a switch to a second |
I'd like to add another question, which I work on a bit in later PRs:
|
bors r+ |
@cart one more thought on clear colours - if there are multiple cameras contributing to a render target, is it possible / does it make sense to support a different clear colour per camera which would then clear different parts of the screen? |
My current take: I don't think cameras should have clear colors. I think render targets should be decoupled from cameras (and allow multiple cameras mapping to the same render target). RenderTargets should have clear colors. RenderTargets should have a single clear color for the "default render graph". Non-default render target / render graph combos can define their own clear passes (with their own clear color configuation) as it makes sense. |
# Objective Will fix bevyengine#3377 and bevyengine#3254 ## Solution Use an enum to represent either a `WindowId` or `Handle<Image>` in place of `Camera::window`. Co-authored-by: Carter Anderson <mcanders1@gmail.com>
# Objective Fixes #3499 ## Solution Uses a `HashMap` from `RenderTarget` to sampled textures when preparing `ViewTarget`s to ensure that two passes with the same render target get sampled to the same texture. This builds on and depends on #3412, so this will be a draft PR until #3412 is merged. All changes for this PR are in the last commit.
# Objective - After #3412, `Camera::world_to_screen` got a little bit uglier to use by needing to provide both `Windows` and `Assets<Image>`, even though only one would be needed https://github.com/bevyengine/bevy/blob/b697e73c3d861c209152ccfb140ae00fbc6e9925/crates/bevy_render/src/camera/camera.rs#L117-L123 - Some time, exact coordinates are not needed but normalized device coordinates is enough ## Solution - Add a function to just get NDC
…4041) # Objective - After bevyengine#3412, `Camera::world_to_screen` got a little bit uglier to use by needing to provide both `Windows` and `Assets<Image>`, even though only one would be needed https://github.com/bevyengine/bevy/blob/b697e73c3d861c209152ccfb140ae00fbc6e9925/crates/bevy_render/src/camera/camera.rs#L117-L123 - Some time, exact coordinates are not needed but normalized device coordinates is enough ## Solution - Add a function to just get NDC
# Objective Fixes bevyengine#3499 ## Solution Uses a `HashMap` from `RenderTarget` to sampled textures when preparing `ViewTarget`s to ensure that two passes with the same render target get sampled to the same texture. This builds on and depends on bevyengine#3412, so this will be a draft PR until bevyengine#3412 is merged. All changes for this PR are in the last commit.
# Objective Fixes bevyengine#3499 ## Solution Uses a `HashMap` from `RenderTarget` to sampled textures when preparing `ViewTarget`s to ensure that two passes with the same render target get sampled to the same texture. This builds on and depends on bevyengine#3412, so this will be a draft PR until bevyengine#3412 is merged. All changes for this PR are in the last commit.
…4041) # Objective - After bevyengine#3412, `Camera::world_to_screen` got a little bit uglier to use by needing to provide both `Windows` and `Assets<Image>`, even though only one would be needed https://github.com/bevyengine/bevy/blob/b697e73c3d861c209152ccfb140ae00fbc6e9925/crates/bevy_render/src/camera/camera.rs#L117-L123 - Some time, exact coordinates are not needed but normalized device coordinates is enough ## Solution - Add a function to just get NDC
Objective
Will fix #3377 and #3254
Solution
Use an enum to represent either a
WindowId
orHandle<Image>
in place ofCamera::window
.