Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: Weird overlap effect

  1. #1
    Intern Newbie
    Join Date
    Mar 2012
    Location
    Devon, England
    Posts
    40

    Weird overlap effect

    When I enable depth testing in my program I get this weird overlap effect. I gather it's something to do with blending but I don't know much about texture blending.
    http://i.imgur.com/vBAtP.png
    In the picture examples of my problem are circled.

    Any help is much appreciated!
    Thanks,
    Rowan.

    PS: As you can tell from the picture my top down tree sprites are awful. Do you know where I can get some the look decent.
    Help Me [img]<<GRAEMLIN_URL>>/smile.gif[/img]

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Apr 2010
    Posts
    754
    Looks to me as if your transparent objects are writing to the depth buffer and/or are not rendered from back to front.

  3. #3
    Intern Newbie
    Join Date
    Mar 2012
    Location
    Devon, England
    Posts
    40
    Why shouldn't a transparent object write to depth buffer? How else am I meant to change the drawing order without major changes to my code?
    Help Me [img]<<GRAEMLIN_URL>>/smile.gif[/img]

  4. #4
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,948
    Why shouldn't a transparent object write to depth buffer?
    Because then the algorithm doesn't work.

    If you draw something transparent into the depth buffer, and then draw something (transparent or opaque) behind it, OpenGL will dutifully not draw it at all.

    OpenGL only knows about the triangle it's currently rendering and the framebuffer. It doesn't know what has been rendered "transparently" before.

    This is a common, well-understand thing about transparency via blending. You must render all transparent objects last. You must turn off depth buffering, and you must sort transparent objects back-to-front. There is no other way to handle this.

  5. #5
    Intern Contributor uwi2k2's Avatar
    Join Date
    Mar 2011
    Posts
    98

    Blend Func

    Hi,

    just an other idea.
    maybe your blendfunc is not set correctly.

    cu
    uwi
    uwi2k2 - OpenGL Trainer: www.opengl-trainer.com
    ---------------------------------------------------------
    Free Programming Helpline: www.programming-hotline.com
    ---------------------------------------------------------
    A Friday Night Programmer: www.uwiworld.net

Posting Permissions

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