PDA

View Full Version : Clear screen in gradient mode instead of sky-dome?



anuchka
10-15-2008, 07:43 AM
Hi

Is it possible to clear screen with color in gradient mode?

It would be fast and good solution for sky effect.
Plain color doesn't look too realistic.

I found some articles about sky-dome generation ,but they are too complicated to implement on dynamic 3d scenes (we need to calculate position for the sky sphere in horizon and also for camera movements )

If the answer is no ,please advice me something that looks good
and are not too time/resource costing.

Thanks

overlay
10-15-2008, 08:40 AM
Just draw a full screen quad with some color for the top vertices and another color for the bottom vertices.

anuchka
10-15-2008, 08:46 AM
Then I don't see most of my scene...
(if not to calculate the bounds at far distance ,which I'm trying to avoid )

_NK47
10-15-2008, 08:49 AM
draw it before any other geometry and disable depth writing.

trinitrotoluene
10-15-2008, 09:00 AM
Then I probably won't see most of my scene...
(if not to calculate the bounds at far distance ,which I'm trying to avoid )

Maybe you can use glDepthRange(1.0,1.0) (http://www.opengl.org/sdk/docs/man/xhtml/glDepthRange.xml)

anuchka
10-15-2008, 09:08 AM
Ohhh thanks, I tried it before I posted ,but
I forgot about depth buffer and gluLookAt(...) since I switched to glOrtho(...),and I got weird result, no it works ok :o

unsigned void
10-15-2008, 11:16 PM
To save fillrate, it is recommended draw sky the last - at maximum depth with depth test.

_NK47
10-16-2008, 03:48 AM
unsigned void: To save fillrate, it is recommended draw sky the last - at maximum depth with depth test.

isn't pixel first shaded and then depth-rejected? and you have a depth test here instead of disabling it.

dletozeun
10-16-2008, 05:41 AM
isn't pixel first shaded and then depth-rejected?


fragment are first shaded if alpha test is enabled or if you write the fragment depth in a fragment shader. Otherwise it is useless to shade a fragment if we know that it is behind another one and it is discarded right after depth comprarison.

Then drawing the skybox last, you save many depth buffer writes and instead you just do depth comparisons.

ZbuffeR
10-16-2008, 05:43 AM
Z test optimization techniques exists in many video cards, in certain cases it can kill fragments early enough to make it worth. You can not directly control it.

Anyway you probably don't have to worry about this now.

_NK47
10-16-2008, 06:01 AM
dletozeun:
Otherwise it is useless to shade a fragment if we know that it is behind another one and it is discarded right after depth comprarison.

i remember depth sorting where geomtery is sorted according to the camera, to draw closer object first and more likely cause a depth test fail on next objects. good if geomtry is heavy on rasterization like normalmapping. makes sense. thanks.

dletozeun
10-16-2008, 06:13 AM
I have just found another thread about depth test optimatizations which is what Zbuffer was talking about IMO. Look at the link in modus's post, I think it would interest you.

http://www.opengl.org/discussion_boards/...6418#Post246418 (http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Main=48075&Number=246418#Post246418)

_NK47
10-16-2008, 07:07 AM
i will give it a read. thanks alot dletozeun.