Results 1 to 6 of 6

Thread: Old problem.

  1. #1
    Senior Member Regular Contributor
    Join Date
    Nov 2000
    Location
    Sydney, NSW, Australia
    Posts
    426

    Old problem.

    This is my problem:
    I have a billboarded quad with a texture on it. The black pixels of the texture are given an alpha value of 0.0 and the rest are 1.0, then i turn on alpha blending with function GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA
    This will make the black parts of the quad transparent.

    Now, say i want to have this quad and another similar quad rotating around a certain point. I will begin to get artefacts as the quads rotate around this point because of the transparent parts of the quad blocking out the quad behind it even though they are meant to be transparent, but it still remains transparent to all pother geometry. I know this is a problem with depth sorting, but is there are simple way to fix this other that sorting MANUALLY the quads??
    :: Sleep is a poor substitute for caffeine ::

  2. #2
    Senior Member Regular Contributor
    Join Date
    Oct 2001
    Location
    Holland
    Posts
    179

    Re: Old problem.

    For on/off alpha features you can use the alphatest feature. The fragments failing the test will be rejected and thus not update the screen buffer (including depth buffer).

    Jean-Marc.

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Dec 2000
    Location
    Reutlingen, Germany
    Posts
    2,042

    Re: Old problem.

    I had the same problem some days ago. Itīs quite easy to solve.

    Either you sort your objects by depth, which would always work, but is quite much work especially in particle-systems,
    OR you disable depth-writing. This means that depth-values are calculated and compared to each other, but when you actually draw an object, its depth-values are not written to the depth-buffer. Therefore every other object will be drawn upon it but in particle-systems you usually donīt see this. So if it does not matter for your program, if the objects are not drawn in the correct order, you could use this.

    You can do this with glDepthMask (GL_FALSE).

    Hope that helps you.
    Jan.
    GLIM - Immediate Mode Emulation for GL3

  4. #4
    Senior Member Regular Contributor
    Join Date
    Nov 2000
    Location
    Sydney, NSW, Australia
    Posts
    426

    Re: Old problem.

    Yes, but if i set the depth mask to 0 then there will be depth sorting problems. eg: the billboard that is really behind another billboard will sometimes be rendered in front of the front billboard-a depth sorting problem.

    I think the first reply solution is the correct one. Is it simply glEnable(GL_ALPHA_TEST);
    And this will simply ignore the texels of the texture with 0 alpha value?
    :: Sleep is a poor substitute for caffeine ::

  5. #5
    Senior Member Regular Contributor
    Join Date
    Oct 2001
    Location
    Holland
    Posts
    179

    Re: Old problem.

    Originally posted by MrShoe:
    I think the first reply solution is the correct one. Is it simply glEnable(GL_ALPHA_TEST);
    And this will simply ignore the texels of the texture with 0 alpha value?
    Almost. First you have to set the test value to use and the type of comparison with glAlphaTest( func, ref). Func is one of GL_NEVER, GL_LESS, GL_LEQUAL, GL_EQUAL, GL_GEQUAL, GL_GREATER, GL_ALWAYS or GL_NOTEQUAL; ref can be anything from 0.0 to 1.0.
    Then you enable the test with glEnable( GL_APLHA_TEST).

    HTH

    Jean-Marc.

  6. #6
    Senior Member Regular Contributor
    Join Date
    Nov 2000
    Location
    Sydney, NSW, Australia
    Posts
    426

    Re: Old problem.

    Thanks alot...
    :: Sleep is a poor substitute for caffeine ::

Similar Threads

  1. Replies: 1
    Last Post: 09-23-2016, 02:24 PM
  2. Shading problem? (pyglet-problem?, my problem?)
    By H2OBrain in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 12-03-2009, 08:31 AM
  3. Replies: 4
    Last Post: 09-27-2004, 06:27 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean