Change default graphics compositor settings so UI isn't affected by post processing or shown in editor
PR Details
This PR updates the default graphics compositor setup so that UI is in its own render stage that isn't affected by post processing and also isn't shown in the editor view.
Description
By default there is now a render stage called UserInterface which the UIRenderFeature is assigned to. The UIRenderFeature is also no longer assigned to the Transparent render stage.
The Editor Renderer entry point is now a SceneRenderCollection with one child, a shared forward renderer which doesn't use the UserInterface stage. This stops the UI from being shown in the editor. SceneRenderCollection was chosen in case a user wants the UI to be visible in the editor. They just need to add a SingleStageRenderer set to the UserInterface stage to the collection.
The Game Renderer remains mostly the same, using a Camera Renderer with a SceneRenderCollection as the child. The collection has an added SingleStageRenderer set to the UserInterface stage.
I consider this setup much simpler than the one described here while achieving the same results.
A small additional change this PR makes is giving proper names to the render features, they were all just test or null before.
There's a risk that this is a breaking change, so I'd like some feedback on that before marking this as ready to merge.
Related Issue
Addresses https://github.com/stride3d/stride/issues/1154 This setup also avoids the problem from https://github.com/stride3d/stride/issues/1508
Motivation and Context
See related issues.
Types of changes
- [ ] Docs change / refactoring / dependency upgrade
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [x] Breaking change (fix or feature that would cause existing functionality to change)
Checklist
- [ ] My change requires a change to the documentation.
- [ ] I have added tests to cover my changes.
- [ ] All new and existing tests passed.
To do
- [x] Update the level 10 archetype file
- [x] Update the level 9 archetype file
- [ ] Update the create default function in the GraphicsCompositorHelper class
Hey @JackPilley do you happen to remember what the status of this was? Does some other work need to be done on it before it could be merged? I'd be happy to take a go at it if something is still needed.
Hey @JackPilley do you happen to remember what the status of this was? Does some other work need to be done on it before it could be merged? I'd be happy to take a go at it if something is still needed.
There's a couple things. I only updated the empty new game project, so I think the samples and templates would also need to be updated. I'm also not sure if the changes would only apply to new projects, or if existing projects will be affected by the changes. And there's always the possibility I did something wrong and it'll break in some situation I didn't think to test.
Not sure if related. I am adding Clean UI through the code.
In the community toolkit, I am adding default GraphicsCompositor like so
var graphicsCompositor = GraphicsCompositorHelper.CreateDefault(true);
https://github.com/stride3d/stride-community-toolkit/blob/f774f0bb5a36810e622ceefc5d7ff1dacfd34efb/src/Stride.CommunityToolkit/Engine/GameExtensions.cs#L171-L180
And then, I am applying CleanUI with the extension AddCleanUIStage().
game.AddGraphicsCompositor().AddCleanUIStage();
https://github.com/stride3d/stride-community-toolkit/blob/f774f0bb5a36810e622ceefc5d7ff1dacfd34efb/src/Stride.CommunityToolkit/Rendering/Compositing/GraphicsCompositorExtensions.cs#L37-L43
And making adjustments
https://github.com/stride3d/stride-community-toolkit/blob/f774f0bb5a36810e622ceefc5d7ff1dacfd34efb/src/Stride.CommunityToolkit/Rendering/Compositing/GraphicsCompositorExtensions.cs#L37-L43
AddPostEffects(graphicsCompositor);
AddRenderStagesAndFeatures(graphicsCompositor);
That means, on the top what is suggested in this issue, not sure if the Stride's GraphicsCompositorHelper.CreateDefault(true); should be also updated so we get the same result, without me having extensions.
Note, that my code implementation adds CleanUI only to Group31 if I am correct. Not sure if it should be across all groups.
Note, that my code implementation adds CleanUI only to Group31 if I am correct. Not sure if it should be across all groups.
Since the UI is in its own stage, it shouldn't need to be assigned to any particular group.
So I messed around with it and the setup seems to work fine, couldn't find any issues, so all good there. I was looking at applying these changes to the samples. And it looks like they use the Level10 graphics compositor setup. But not quite sure the best way to go and actually edit them. Can't copy-paste due to the ref ids all being different, and not sure how to open the samples directly if possible even). Any suggestions?
I spent some time today doing some testing. It seems like the changes apply to all of the templates and samples already. So they don't actually need to be updated.
I also tested creating a project on a previous version of Stride, editing the graphics compositor, and then opening the project again after recompiling Stride with these changes. It definitely does pose a risk of breaking existing projects if they've edited their compositor.
So this is a breaking change.
It seems like the changes apply to all of the templates and samples already
Oh, just tested and you're right! YAY!
I also tested creating a project on a previous version of Stride, editing the graphics compositor, and then opening the project again after recompiling Stride with these changes. It definitely does pose a risk of breaking existing projects if they've edited their compositor.
Hmm deffinitly shouldn't, it creates the assets in the project and then keeps no reference to the template used. I tested it my self to be sure and it didn't apply to an existing compositor. Steps:
- Create new template project in current version of stride.
- Open project, open GraphicsCompositor editing window.
- Close stride, and click the "Save" button when prompted.
- Open the same project with stride compiled with these changes.
- See GraphicsCompositor unchanged.
Is it possible something else was going on with your setup?
Here's what happened for me, the modifications I made to the compositor are basically the setup for removing post processing from the UI that Hero Crab documented.
I added a new render stage called EXAMPLE
I modified the UIRenderFeature so there's groups going to two different stages
I added the new render stage to the entry points
Now after applying the changes and recompiling the engine I get this:
The UserInterface render stage got added automatically
The render feature still sends groups to different stages, but where the first one is going is now different, also the selected groups got reset for the first one
And there's now an entry point for the UserInterface stage
Make sure you clean the solution and fully rebuild the project when you're testing, Visual Studio doesn't always detect the changes in the files I'm modifying.
I first opened and created the project via the stride launcher. And then reopened it from source. Are you able to test in another project or something? And maybe somone esle can as well?
Ok, creating the project from an engine version downloaded through the launcher and then reopening from an engine compiled from source seems to work fine.
It seems weird to me that there would be a difference in behaviour though. Maybe it's because the version from the launcher is a different release number?
It just occurred to me that this might also mean the changes won't apply to the samples and templates.
Well @JackPilley I figured out what is going on... the graphics compositors that are created in new projects have one of the two default graphics compositors as their archetype. That is why they update!
So if I'm understanding correctly, the samples and templates don't need to be updated, but this is a breaking change since existing projects will use the new archetype?
Well @JackPilley I figured out what is going on... the graphics compositors that are created in new projects have one of the two default graphics compositors as their archetype. That is why they update!
Is it the one I mentioned in my comment var graphicsCompositor = GraphicsCompositorHelper.CreateDefault(true);
If that one is sorted as well, I can remove my extension 🙂.
@VaclavElias No, it looks like the create default function doesn't use the archetype file, so it'll need to be updated manually as well. Good thing you mentioned it otherwise I wouldn't have known to look for it.