Problems with NOSKY

Posted By: MasterQ32

Problems with NOSKY - 11/17/12 11:39

Hey!

I'm just working on a render pipeline and need to clear some render target to another color than sky color

my first thought was using the NOSKY-Flag. I've made a small test to check if it's the right flag to use here:

Code:
#include <acknex.h>
#include <default.c>

function on_space_event()
{
	camera->flags |= NOSKY;
	camera->bg = pixel_for_vec(COLOR_RED, 100, 8888);
}

function main()
{
	wait(1);
	level_load(NULL);
	ent_create(CUBE_MDL, vector(64, 0, 0), NULL);
	ent_create(CUBE_MDL, vector(-64, 0, 0), NULL);
	ent_create(CUBE_MDL, vector(0, 64, 0), NULL);
	ent_create(CUBE_MDL, vector(0, -64, 0), NULL);
	
	camera->bmap = bmap_createblack(screen_size.x, screen_size.y, 888);
	while(1)
	{
		camera->pan += 2 * time_step;
		draw_quad(camera->bmap, nullvector, NULL, screen_size, NULL, NULL, 100, 0);
		wait(1);
	}
}



This worked like expected, red background, not sky color

But then i tried to use the same approach in a render chain, so using the same code just with a stage view:

Code:
#include <acknex.h>
#include <default.c>

VIEW *pass = 
{
	flags = CHILD;
}

function on_space_event()
{
	pass->flags |= NOSKY;
	pass->bg = pixel_for_vec(COLOR_RED, 100, 8888);
}

function main()
{
	wait(1);
	level_load(NULL);
	ent_create(CUBE_MDL, vector(64, 0, 0), NULL);
	ent_create(CUBE_MDL, vector(-64, 0, 0), NULL);
	ent_create(CUBE_MDL, vector(0, 64, 0), NULL);
	ent_create(CUBE_MDL, vector(0, -64, 0), NULL);
	
	camera->bmap = bmap_createblack(screen_size.x, screen_size.y, 888);
	pass->bmap = bmap_createblack(screen_size.x, screen_size.y, 888);
	
	camera->stage = pass;
	
	while(1)
	{
		camera->pan += 2 * time_step;
		draw_quad(pass->bmap, nullvector, NULL, screen_size, NULL, NULL, 100, 0);
		wait(1);
	}
}



And it doesn't work. The models smear over the screen and the background gets not cleared correctly (it doesn't get cleared in any way)

Is this a wanted behaviour or is this a bug?
Would be cool to get an answer soon!

Greetings
Felix Queißner

PS.: I can use a dirty workaround, but it would be better to use the correct flags for this wink
Posted By: jcl

Re: Problems with NOSKY - 11/20/12 16:10

For clearing the sky, use a sky color. NOSKY must then not be set of course.

Alternatively, use view->bg for defining a background color that is different to the sky color.
Posted By: MasterQ32

Re: Problems with NOSKY - 11/20/12 22:53

i know that i can clear the background to skycolor, but i also need to clear some other rendertargets to other colors than skycolor

i have 4 different render targets:
the first should be cleared to zero, the second one to black, third one to ambient_color and the last one to zero
the last pass renders to the screen and has to be cleared to sky_color

so just using sky_color won't work
Posted By: jcl

Re: Problems with NOSKY - 11/21/12 09:50

Originally Posted By: jcl
Alternatively, use view->bg for defining a background color that is different to the sky color.
Posted By: MasterQ32

Re: Problems with NOSKY - 11/21/12 09:53

i know this.
but it doesn't work in view stages, only with camera!
Posted By: jcl

Re: Problems with NOSKY - 11/21/12 10:08

I've just checked, but can not confirm that problem.

Maybe something in your code sets bg to zero? It only clears the background when it's nonzero.
Posted By: MasterQ32

Re: Problems with NOSKY - 11/21/12 10:10

have you used the script above?
i tried this and it doesn't work
can check it this evening again, but i'm certainly sure that it was like described
(pressing space in the test code to setup NOSKY and bg)
Posted By: jcl

Re: Problems with NOSKY - 11/21/12 10:46

In your script you're setting the CHILD flag. This lets the view inherit the parameters from the preceding stage, so your bg setting has no effect. Only the NOSKY flag did work because flags are not inherited.
Posted By: MasterQ32

Re: Problems with NOSKY - 11/21/12 13:23

okay, that means that i have to copy all those parameters by myself but changing bg...
thanks for the help
Posted By: EvilSOB

Re: Problems with NOSKY - 11/21/12 13:28

Please forgive the noob suggestion...

Couldnt you keep the CHILD flag, change the BG of the 'parent'
at the start of 'this' stage, then set the parent BG back to its original?

Or is that even more 'messing about' than a simple memcpy?
© 2024 lite-C Forums