Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Clear screen in gradient mode instead of sky-dome?

  1. #1
    Intern Newbie
    Join Date
    May 2004
    Posts
    46

    Clear screen in gradient mode instead of sky-dome?

    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

  2. #2
    Member Regular Contributor
    Join Date
    Apr 2007
    Posts
    268

    Re: Clear screen in gradient mode instead of sky-dome?

    Just draw a full screen quad with some color for the top vertices and another color for the bottom vertices.

  3. #3
    Intern Newbie
    Join Date
    May 2004
    Posts
    46

    Re: Clear screen in gradient mode instead of sky-dome?

    Then I don't see most of my scene...
    (if not to calculate the bounds at far distance ,which I'm trying to avoid )

  4. #4
    Advanced Member Frequent Contributor _NK47's Avatar
    Join Date
    Mar 2008
    Posts
    574

    Re: Clear screen in gradient mode instead of sky-dome?

    draw it before any other geometry and disable depth writing.

  5. #5
    Member Regular Contributor trinitrotoluene's Avatar
    Join Date
    Sep 2008
    Location
    Montérégie,Québec
    Posts
    362

    Re: Clear screen in gradient mode instead of sky-dome?

    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)

  6. #6
    Intern Newbie
    Join Date
    May 2004
    Posts
    46

    Re: Clear screen in gradient mode instead of sky-dome?

    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

  7. #7
    Junior Member Newbie
    Join Date
    Nov 2006
    Posts
    20

    Re: Clear screen in gradient mode instead of sky-dome?

    To save fillrate, it is recommended draw sky the last - at maximum depth with depth test.

  8. #8
    Advanced Member Frequent Contributor _NK47's Avatar
    Join Date
    Mar 2008
    Posts
    574

    Re: Clear screen in gradient mode instead of sky-dome?

    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.

  9. #9
    Senior Member OpenGL Pro dletozeun's Avatar
    Join Date
    Jan 2006
    Location
    FRANCE
    Posts
    1,367

    Re: Clear screen in gradient mode instead of sky-dome?

    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.

  10. #10
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,575

    Re: Clear screen in gradient mode instead of sky-dome?

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •