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

Adds GlobalRenderResourcesNode to easily bind Resources #2043

Closed
wants to merge 3 commits into from

Conversation

mtsr
Copy link
Contributor

@mtsr mtsr commented Apr 29, 2021

To expose a ECS Resource as a custom uniform requires reimplementing most of the stuff that camera_node.rs or lights_node.rs do. My idea here was to see if this can be significantly reduced for Resources that implement RenderResources.

One of the use cases is being able to easily expose values to FullscreenPassNode shaders, which do not use any entities.

It currently works, although it's quite possible I missed some edge cases. Also I'm aware it doesn't currently support Textures.

Before I put in the work polishing this, I'd like to hear what people think.

@alice-i-cecile alice-i-cecile added C-Enhancement A new feature help wanted A-Rendering Drawing game state to the screen labels Apr 29, 2021
@CptPotato
Copy link
Contributor

CptPotato commented Apr 29, 2021

Before I put in the work polishing this, I'd like to hear what people think.

I might be a bit biased since I was somewhat involved in this. But in terms of general ergonomics, using a Resource felt like the most natural way to go and was the first thing I've tried when attempting to use "global" uniforms.

@mtsr mtsr force-pushed the global-render-resources-node branch from 2114b57 to d4a9975 Compare May 7, 2021 06:46
@msklywenn
Copy link
Contributor

msklywenn commented May 12, 2021

This seems like a really neat feature. For clarity and ease of comprehension, may I suggest renaming GlobalRenderResourcesNode into ResourcesNode and RenderResourcesNode into ComponentsNode? It would match their source object and I think the "Render" is superfluous since this is all already in the render_graph crate.

Edit: I just saw there was an AssetRenderResourcesNode too and the naming I just proposed might be confusing in the global context. I also find that RenderResource might be confused with ECS Resources while they are in fact completely unrelated. So may I actually suggest:

  • RenderResourcesNode => ComponentDataNode
  • GlobalRenderResourcesNode => ResourceDataNode
  • AssetRenderResourcesNode => AssetDataNode

mut render_resource_bindings: ResMut<RenderResourceBindings>,
) {
// TODO add support for textures
// No need to do anything if no changes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about added?

Copy link
Contributor Author

@mtsr mtsr May 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_changed() is also true for added. Although I guess it doesn't hurt to add it for clarity.

@cart cart added the S-Pre-Relicense This PR was made before Bevy added the Apache license. Cannot be merged or used for other work label Jul 23, 2021
@mockersf mockersf removed the S-Pre-Relicense This PR was made before Bevy added the Apache license. Cannot be merged or used for other work label Jul 24, 2021
@alice-i-cecile
Copy link
Member

alice-i-cecile commented Nov 20, 2022

How does this relate to the modern ExtractResource approach? Is this still needed?

@IceSentry
Copy link
Contributor

I believe this is too outdated to be relevant. ExtractResource covers most of this.

@IceSentry IceSentry closed this Oct 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Enhancement A new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants