Question How to change backgound color from default black?

n00rp

Active member
Featured Contributor
Joined
Jun 11, 2020
Messages
35
Reactions
193
Hi. Been away for a while so starting with a simple one :) How do I get flat colour backgrounds instead of the default scene black? I don't want to add any objects/walls to do this or any skydome. Just a simple colour change from black. Thanks
 
I don't think that's a "background color" per se.Isn't it black because it's actual void?
With no lights and no objects to illuminate (with said lights or ambient light). :unsure:

So you have to add something, either CUA (and recolor it) or atoms (maybe emissive panel if you don't wanna add lights?).


Strange question, but I would also like to hear if there's a way to change it, without adding anything.
 
Last edited:
Upvote 0
That background color is tied to the camera. Documentation is here.

I can create a simple Plugin for that. Already got it working ... let me just add a color picker + test + pack it to a var and uploaded it.
The only requirement is that the skybox is disabled in the [Scene Lighting]-tab.

Guess this could be very useful for video editing too (chromakey stuff).
 
Upvote 0
@n00rp
Before I upload to the Hub for everyone, could you test it in VR please?
(assuming you have VR hardware?)

I doubt it, but it's possible that VAM could use a different camera-object for VR.

Unfortunately I do not own any VR hardware to test.

The color should be saved per scene and I do reset it back to default black if the Plugin is "destroyed" - hopefully that should always reset it back in case a new scene is loaded.

Some parts of the UI, like the preview-screenshot thingy, will still show the default black.
That's because they use another camera object for that part of the user interface.


Edit #2: It's on the Hub now here. Discord confirmed it works in VR too.

Here is the (old V1) code and the VAR-file is attached:
(edit: update to restore saved color more reliable)
C#:
using UnityEngine;

public class CameraBackgroundColor : MVRScript
{
    private Camera mainCamera;
    private JSONStorableColor jColor;

    public override void Init()
    {
        mainCamera = CameraTarget.centerTarget.targetCamera;
        mainCamera.clearFlags = CameraClearFlags.SolidColor;
        jColor = new JSONStorableColor("Color", HSVColorPicker.RGBToHSV(0f, 0f, 1f), SetColor);
        RegisterColor(jColor);
        CreateColorPicker(jColor);
    }

    void Start() { SetColor(jColor.val.H, jColor.val.S, jColor.val.V); }

    private void SetColor(float h, float s, float v) {mainCamera.backgroundColor = Color.HSVToRGB(h, s, v); }

    void OnDestroy() { mainCamera.backgroundColor = Color.black; }
}
 

Attachments

  • Sally.CameraBackgroundColor.1.var
    1.1 KB · Views: 0
Last edited:
Upvote 0
Back
Top Bottom