godot-proposals
godot-proposals copied to clipboard
Add background color to Viewports
Describe the project you are working on:
Trying to put a virtual computer screen with old school computer text on it inside a 3D game.
Describe the problem or limitation you are having in your project:
It isn't readily apparent where the Viewport gets its background color from but evidently there isn't a way to set a different background color on different Viewports.
Right now, the workaround for not having a way to set a background color for an individual Viewport is adding a ColorRect to its tree. I can use that for now but it is still annoying.
Describe how this feature / enhancement will help you overcome this problem or limitation:
There should be a property on the Viewport to let you set a background color. That would make Viewports easier to work with instead of requiring another object to clear the viewport with.
If this enhancement will not be used often, can it be worked around with a few lines of script?:
A whole additional seemingly unnecessary object is required to do something Viewports should do on their own.
Is there a reason why this should be core and not an add-on in the asset library?:
Lacking this feature seems like an oversight.
Background color is set within the environment of a Viewport. Near the top of the inspector there is a property for a Viewport to use its own world. Select that, assign an environment, and then set the background color there.
Sounds to me like OP is talking also (or exclusively) about the 2D viewport @clayjohn . Maybe you can clarify @BenMcLean ?
I first thought that's probably a color you could set in Editor Settings>Editor>2D, but I could not find it. Right clicking in an empty area in the background also does nothing (no context menu) I then checked in the World environment node, but "Canvas" mode does not seem to have a setting for the viewport background color and setting the mode to "CustomColor" changes nothing in 2D.
So far I also did the same as BenMcLean and just added a ColorRect. Which is annoying if you go fullscreen. and the rect won't scale. Changing the background color is a absolute beginner-desire, yet in order to do it correctly so you don't get problems when window proportions changes or you go fullscreen, you first have to understand the incredibly counter intuitive Control node stretch settings: If a beginner finds that layout button (first obstacle) just clicks on "Full Rect", the ColorRect will visually disappear, not become a full rect. The same would happen if they would set the anchors to 1, as so many reddit posts and tutorials suggest.
Edit: Found it! It's in the Project Settings > Rendering > Environment > Default Clear Color
This will change the default background color for all your scenes be it 2D or 3D. The naming "Clear Color" is not really helpful I suppose. I would really welcome a very accessible (maybe using the RMB context menu) "per scene" setting which would overwrite the "Default Clear Color", if it is set.
Yes that is what I was trying to say.
On Sun, Nov 24, 2019, 9:55 AM golddotasksquestions [email protected] wrote:
Sounds to me like OP is talking also (or exclusively) about the 2D viewport @clayjohn https://github.com/clayjohn . I first thought that's probably a color you could set in Editor Settings>Editor>2D, but I could not find it. Right clicking also does nothing. I then checked in the World environment node, but "Canvas" mode does not seem to have a setting for the viewport background color and setting the mode to "CustomColor" changes nothing in 2D.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/godotengine/godot-proposals/issues/252?email_source=notifications&email_token=AANKSMWIZM75TK2MLN3XKWLQVKPWVA5CNFSM4JQ2J7Z2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFAON4A#issuecomment-557901552, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANKSMXTB2NBMZZ5SJIWLEDQVKPWVANCNFSM4JQ2J7ZQ .
Yea, as said by clayjohn the clear color is defined by an environment. While there's always a default environment which is defined in the project's settings, each viewport will either use the default environment or the one defined in the node inspector.
So what I basically want to point out here: The clear color is always defined by an environment at the moment.
Adding another property in the inspector might even confuse beginners since it wouldn't be obvious if the clear color was defined by the property or the environment for the viewport
set_default_clear_color
?
I don't see an issue adding it to the VP's inspector.. that would be a good idea. It is kind of hidden
@girng it would have to be "override_background_color" because background color is set based on environment, not Viewport.
TIL. I always thought it was just the VP's bg color, ty for the clarification. Okay that's probably why it's not in the VP's inspector then
Environment doesn't work for 2D games. 2D games often require their own background color, and having to stretch a color rect is hacky. You can set the background color for ALL viewports in the project preferences, (or by calling VisualServer.set_default_clear_color()) but it's a very common use case that you would want to set the background color for EACH viewport you are using.
We discussed this at today's proposal review meeting. We agreed on an implementation as follows:
- Add a per-viewport setting for clear color (could be renamed background color)
- Replace the current implementation of clear color to use Viewport clear color instead (Project setting would remain, but would set the default clear color for each viewport instead, each viewport could then change their clear color in editor or at run time)
- Internally this would work the same from the renderer's perspective, if no Environment is present, or if background mode is set to clear_color, the Viewport's clear color will be used.
The implementation of the above should not be too complex. The difficult part of this proposal will be ensuring that nothing breaks in the editor as it makes heavy use of Viewports
Yes please rename this to default_background_color
(for the project settings) and custom_background_color
instead of clear_color
. A clear_color to me is a color with 100% transparency. This makes no sense to me here since I can clearly see the color.
Yes please rename this to
default_background_color
(for the project settings) andcustom_background_color
instead ofclear_color
. A clear_color to me is a color with 100% transparency. This makes no sense to me here since I can clearly see the color.
That makes sense!
The rename makes sense for, uhm, clarity, but just for the sake of, eh, transparency — it is called a "clear" color on the graphic library level, as it is the color used to clear the rendering surface. I.e. it is the color that you wipe the screen with.
If we add a per-viewport clear color option, there are two questions I have:
- Changing the Clear Color (background color) on a per-viewport basis should affect radiance map generation if possible. Is it possible to do this on a per-viewport basis, though?
- Should Environment keep its Custom Color property? Remember that it also affects the radiance map generation.
@YuriSizov
The rename makes sense for, uhm, clarity, but just for the sake of, eh, transparency — it is called a "clear" color on the graphic library level, as it is the color used to clear the rendering surface. I.e. it is the color that you wipe the screen with.
That's super interesting fact, thank you for sharing! Unfortunately naming like this is usually completely lost to the end user who works and experiences the tool on a much higher level.
- Changing the Clear Color (background color) on a per-viewport basis should affect radiance map generation if possible. Is it possible to do this on a per-viewport basis, though?
Well, the background color doesn't impact radiance map generation. We already store a clear_color per rendertarget internally. The only change is that we would remove the default clear color and instead always rely on clear color set per Viewport/RenderTarget. Everything else with respect to 3D rendering/the environment can stay the same.
- Should Environment keep its Custom Color property? Remember that it also affects the radiance map generation.
Environment doesn't need to change. This proposal will only affect the environment when background mode clear color is used. In that case, the per-viewport clear color will be used.
Background color is set within the environment of a Viewport. Near the top of the inspector there is a property for a Viewport to use its own world. Select that, assign an environment, and then set the background color there.
Yeah this does nothing in 4.2...
I've been struggling to work out which setting controls the background color of a window node for the last hour (adding pretty much every node type to the theme and changing its colours). It's not intuitive that everything else about a window is available in the theme, but its background is covered in Godot's viewport settings. A theme setting would be intuitive.
If there's a property somewhere (as mentioned above) under the "window" node type that's related to "viewport" or "world" to set its colour under 4.3 beta 2, I can't find it.