Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VisualServer.set_default_clear_color doesn't do anything #4939

Closed
ghost opened this issue May 30, 2016 · 17 comments
Closed

VisualServer.set_default_clear_color doesn't do anything #4939

ghost opened this issue May 30, 2016 · 17 comments

Comments

@ghost
Copy link

ghost commented May 30, 2016

i put it anywhere doesn't seem to do anything

possibly an OSX only issue

@reduz reduz added this to the 3.0 milestone Jun 14, 2016
@reduz
Copy link
Member

reduz commented Aug 5, 2017

no longer an issue in 3.0

@reduz reduz closed this as completed Aug 5, 2017
@akien-mga akien-mga reopened this Jan 3, 2018
@brainsick
Copy link
Contributor

brainsick commented Jan 6, 2018

There's no sample and I'm not an expert. I might be off base. Does any of this help?

Ubuntu 17.10 x64
Godot 3.0 Beta 2 x64

### 4939-1 - Background Color
todd@todd-ab28d3:~/repos/remote/brainsick-godot-tests/tests/qa$ cat issues/4939-1.gd
extends SceneTree

func _initialize(): # MainLoop
	var viewport = get_root()
	
	var environment = Environment.new()
	environment.background_mode = Environment.BG_COLOR
	environment.background_color = Color(0, 0, 1, 1)
	
	viewport.world.environment = environment
	
	var camera = Camera.new()
	
	var mesh_instance = MeshInstance.new()
	mesh_instance.mesh = CubeMesh.new()
	mesh_instance.transform.origin.z = -5
	
	camera.add_child(mesh_instance)
	
	viewport.add_child(camera)

# main test body
func _iteration(delta): # MainLoop
	quit()
todd@todd-ab28d3:~/repos/remote/brainsick-godot-tests/tests/qa$ time ~/Downloads/Godot3.0Beta2/Godot_v3.0-beta2_x11.64 -s issues/4939-1.gd 
No touch devices found
OpenGL ES 3.0 Renderer: AMD Radeon (TM) R9 Fury Series (AMD FIJI / DRM 3.18.0 / 4.13.0-21-generic, LLVM 5.0.0)
GLES3: max ubo light: 409
GLES3: max ubo reflections: 455, ubo size: 144
ARVR: Registered interface: Native mobile

real	0m1.135s
user	0m0.155s
sys	0m0.045s

4939-1

### 4939-2 - Background Color Sky
todd@todd-ab28d3:~/repos/remote/brainsick-godot-tests/tests/qa$ cat issues/4939-2.gd 
extends SceneTree

func _initialize(): # MainLoop
	var viewport = get_root()
	
	var environment = Environment.new()
	environment.background_mode = Environment.BG_COLOR_SKY
	environment.background_sky = ProceduralSky.new()
	environment.background_color = Color(1, 0, 0, 1)
	
	viewport.world.environment = environment
	
	var camera = Camera.new()
	
	var mesh_instance = MeshInstance.new()
	mesh_instance.mesh = CubeMesh.new()
	mesh_instance.transform.origin.z = -5
	
	camera.add_child(mesh_instance)
	
	viewport.add_child(camera)

# main test body
func _iteration(delta): # MainLoop
	quit()
todd@todd-ab28d3:~/repos/remote/brainsick-godot-tests/tests/qa$ time ~/Downloads/Godot3.0Beta2/Godot_v3.0-beta2_x11.64 -s issues/4939-2.gd 
No touch devices found
OpenGL ES 3.0 Renderer: AMD Radeon (TM) R9 Fury Series (AMD FIJI / DRM 3.18.0 / 4.13.0-21-generic, LLVM 5.0.0)
GLES3: max ubo light: 409
GLES3: max ubo reflections: 455, ubo size: 144
ARVR: Registered interface: Native mobile

real	0m1.126s
user	0m0.305s
sys	0m0.039s

4939-2

### 4939-3 - Background Clear Color - THIS?

If you're trying to do something like this, then I agree that it isn't working how I assume it would. But I'm making a lot of assumptions here.

todd@todd-ab28d3:~/repos/remote/brainsick-godot-tests/tests/qa$ cat issues/4939-3.gd
extends SceneTree

func _init(): # Object
	VisualServer.set_default_clear_color(Color(0, 1, 0, 1)) # this

func _initialize(): # MainLoop
	var viewport = get_root()
	
	var environment = Environment.new()
	environment.background_mode = Environment.BG_CLEAR_COLOR
	
	viewport.world.environment = environment
	
	var camera = Camera.new()
	
	var mesh_instance = MeshInstance.new()
	mesh_instance.mesh = CubeMesh.new()
	mesh_instance.transform.origin.z = -5
	
	camera.add_child(mesh_instance)
	
	viewport.add_child(camera)

# main test body
func _iteration(delta): # MainLoop
	quit()
todd@todd-ab28d3:~/repos/remote/brainsick-godot-tests/tests/qa$ time ~/Downloads/Godot3.0Beta2/Godot_v3.0-beta2_x11.64 -s issues/4939-3.gd 
No touch devices found
OpenGL ES 3.0 Renderer: AMD Radeon (TM) R9 Fury Series (AMD FIJI / DRM 3.18.0 / 4.13.0-21-generic, LLVM 5.0.0)
GLES3: max ubo light: 409
GLES3: max ubo reflections: 455, ubo size: 144
ARVR: Registered interface: Native mobile

real	0m1.130s
user	0m0.159s
sys	0m0.033s

4939-3

@brainsick
Copy link
Contributor

brainsick commented Jan 6, 2018

No can do. GitHub doesn't allow .gd attachments.

Best I can do:

4939-1.gd.txt
4939-2.gd.txt
4939-3.gd.txt

If you're asking me to completely rework my examples, that's a resounding no. I'm only putting this together as an example of a QA test. The bug reporter should be providing the examples if these aren't to your taste. Do you have an example then?

@brainsick
Copy link
Contributor

brainsick commented Jan 6, 2018

Since you're offering to test, I'm assuming that one of these, probably 4939-3 is similar to your issue and you would expect that example to work (the background be green) as well. If so, here is an updated test that builds in a little buffer to ensure everything's initialized. Just for good measure, I threw the set_default_clear_color() in there at various points in the initialization cycle.

Test
todd@todd-ab28d3:~/repos/remote/brainsick-godot-tests/tests/qa$ cat issues/4939-3.gd
extends SceneTree

func _init(): # Object
	VisualServer.set_default_clear_color(Color(0, 1, 0, 1)) # this

func _initialize(): # MainLoop
	var viewport = get_root()
	
	VisualServer.set_default_clear_color(Color(0, 1, 0, 1)) # this
	
	var environment = Environment.new()
	environment.background_mode = Environment.BG_CLEAR_COLOR
	
	viewport.world.environment = environment
	
	var camera = Camera.new()
	
	var mesh_instance = MeshInstance.new()
	mesh_instance.mesh = CubeMesh.new()
	mesh_instance.transform.origin.z = -5
	
	camera.add_child(mesh_instance)
	
	viewport.add_child(camera)

# it takes 6 _iterations to have usable viewport texture data, add buffer
const DELAY_CYCLES = 6 * 2

var delay = DELAY_CYCLES

# main test body
func _iteration(delta): # MainLoop
	VisualServer.set_default_clear_color(Color(0, 1, 0, 1)) # this
	
	if delay > 0:
		delay -= 1
		
		return false # return true in MainLoop exits, keep going?
	
	quit()
todd@todd-ab28d3:~/repos/remote/brainsick-godot-tests/tests/qa$ time ~/Downloads/Godot3.0Beta2/Godot_v3.0-beta2_x11.64 -s issues/4939-3.gd 
No touch devices found
OpenGL ES 3.0 Renderer: AMD Radeon (TM) R9 Fury Series (AMD FIJI / DRM 3.18.0 / 4.13.0-21-generic, LLVM 5.0.0)
GLES3: max ubo light: 409
GLES3: max ubo reflections: 455, ubo size: 144
ARVR: Registered interface: Native mobile

real	0m1.129s
user	0m0.174s
sys	0m0.030s

In the past, I've had the best success working with VisualServer in _init() or _initialize() as it was in my original example.

@brainsick
Copy link
Contributor

brainsick commented Jan 6, 2018

This script is designed to work from the command line, yes. It is designed to test the use of 'clear color' in isolation from other factors.

I don't know the syntax for running a script with an AppBundle on OSX, sorry.

@brainsick
Copy link
Contributor

The script is not a fix. It merely attempts to demonstrate the issue in the absence of any other examples. If the script is accurate, it serves as a test for a developer who might try and address this reported bug.

@akien-mga
Copy link
Member

We have now entered release freeze for Godot 3.0 and want to focus only on release critical issues for that milestone. Therefore, we're moving this issue to the 3.1 milestone, though a fix may be made available for a 3.0.x maintenance release after it has been tested in the master branch during 3.1 development. If you consider that this issue is critical enough to warrant blocking the 3.0 release until fixed, please comment so that we can assess it more in-depth.

@akien-mga akien-mga modified the milestones: 3.0, 3.1 Jan 9, 2018
@aaschmitz
Copy link

aaschmitz commented Feb 2, 2018

I tested with latest version compiled (Godot 3.1.dev from 01/30/2018) and this issue is present (using Ubuntu 16.04 64bits).

For a simple test, use the "2d platformer" from godot demos, delete the node "parallax_bg" from main scene and run it: the background is grey (the default Godot editor color).

Add the code below in the player.gd:

func _ready():
    VisualServer.set_default_clear_color("000000")

Now the background should be black (in Godot 2.1.x this is true) but in latest Godot 3.1.x (or Godot 3.0.0) the background remains gray.

@ghost
Copy link
Author

ghost commented Feb 2, 2018

i tried this on windows and it appears it doesn't work

VisualServer.set_default_clear_color("000000");

Seems like environment clear setting overrides it? I cannot tell.

@aaschmitz
Copy link

As a workaround, add the code below in the player.gd (using the example "2d platformer" quoted above):

func _ready():
    # This not work in Godot 3, background remains gray
    #VisualServer.set_default_clear_color("000000")
    
    # Workaround solution for Godot 3, background changed to black
    ProjectSettings.set_setting("rendering/environment/default_clear_color", "000000")

@akien-mga
Copy link
Member

Thanks, the fact that setting the project setting manually is a good hint to fix VisualServer.set_default_clear_color.

I'd suggest comparing what happens in both cases to find out why the latter doesn't work when the former does.

@eon-s
Copy link
Contributor

eon-s commented Mar 15, 2018

Why do changes on project settings affect a running game? (This is not how it used to work)
PS clear color is resetting the visual server?

@ghost
Copy link

ghost commented Mar 15, 2018

is this still an issue?

@ghost
Copy link
Author

ghost commented Mar 27, 2018

@CarlGustavAlbertDwarfsteinYung unfortunatly yea :P, tested on 3.0.2

@Alexander-Alekseev
Copy link
Contributor

set_default_clear_color does nothing since 22d83bc (2016-10-03):

void VisualServerRaster::set_default_clear_color(const Color& p_color){
}

Current master:

void VisualServerRaster::set_default_clear_color(const Color &p_color) {
}

@ghost
Copy link
Author

ghost commented Apr 2, 2018

really? Since 2016 omg lol

@Web-eWorks
Copy link
Contributor

The way I see it, the solution is to make VisualServerViewport::clear_color public (or add a method to set it) and implement set_default_clear_color like so:

void VisualServerRaster::set_default_clear_color(const Color &p_color) {
    VSG::viewport->set_clear_color(p_color);
}

@reduz would this stomp all over the render system?

@reduz reduz closed this as completed in 7b63c63 Jul 29, 2018
malcolmhoward pushed a commit to malcolmhoward/godot that referenced this issue Jul 31, 2018
malcolmhoward pushed a commit to malcolmhoward/godot that referenced this issue Jul 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants