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 notifications@github.com
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.
Most helpful comment
@girng it would have to be "override_background_color" because background color is set based on environment, not Viewport.