Changing background color or texture?

Official Python bindings with a focus on reinforcement learning and robotics.
Post Reply
Zackory
Posts: 4
Joined: Thu Jan 24, 2019 4:32 pm

Changing background color or texture?

Post by Zackory »

In pybullet, is it possible to change the current background color (light blue/purple) to another color, or even to a texture?
For example, is it possible to have a starry night background, similar to the one found in DeepMind's control suite?
https://github.com/deepmind/dm_control
Zackory
Posts: 4
Joined: Thu Jan 24, 2019 4:32 pm

Re: Changing background color or texture?

Post by Zackory »

I have found out we can change the background color of the GUI window using the following code:

Code: Select all

import pybullet as p
p.connect(p.GUI, options='--background_color_red=1.0 --background_color_green=0.0 --background_color_blue=0.0')
andytgl
Posts: 6
Joined: Thu Jul 08, 2021 5:54 pm

Re: Changing background color or texture?

Post by andytgl »

Regarding this, I find myself unable to change the background color (which will remain light purple) either in the GUI window or in DIRECT mode when using the code above. I have experienced this issue with pybullet 3.2.5 on the following OS/python versions
- python 3.9.12 on MAC OS 11.6.5
- python 3.8.10 on Ubuntu 18

An example of the output I get is the following:
Python 3.9.12 (main, Mar 26 2022, 15:52:10)
[Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pybullet as p
pybullet build time: Jun 16 2022 23:11:14
>>> p.connect(p.GUI, options='--background_color_red=1.0 --background_color_green=1.0 --background_color_blue=1.0')
argv[0]=--background_color_red=1.0
argv[1]=--background_color_green=1.0
argv[2]=--background_color_blue=1.0
Version = 4.1 ATI-4.6.21
Vendor = ATI Technologies Inc.
Renderer = AMD Radeon Pro 5300M OpenGL Engine
b3Printf: Selected demo: Physics Server
startThreads creating 1 threads.
starting thread 0
started thread 0
MotionThreadFunc thread started
0
with background color:
Image

Has anyone experienced the same issue?
nobuyuki
Posts: 3
Joined: Wed Feb 01, 2023 5:45 pm

Re: Changing background color or texture?

Post by nobuyuki »

You can change the background color of the GUI in PyBullet using the p.configureDebugVisualizer() function.

You can specify the background color using the rgbBackground parameter. This function accepts multiple parameters other than rbgBackground parameter.

Here’s an example:

Code: Select all

p.configureDebugVisualizer(rgbBackground=[0, 0, 0])
In this example, the rgbBackground parameter is used to set the background color to black. You can pass an RGB vector [red, green, blue] to set a color of your choice. Each color value should be between 0 and 1.
Post Reply