Results 1 to 5 of 5

Thread: blending incorrect triangles

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2015
    Posts
    20

    blending incorrect triangles

    Hello everyone,
    I'm trying to render an object in transparency. What I should do is render the same object in two different positions, in the first rendering the object should be opaque and the second rendering must be transparent.
    I have tried simply to render the transparent object but I see an incorrect rendering of triangles scattered and do not understand why

    My code have the depth test enabled and the pseudocode is similar to this:
    glEnable (GL_BLEND);
    glBlendFunc (GL_SRC_ALPHA, GL_ONE);
    glColor (x, x, x, 100);
    renderObject (no triangles ordered)

    blending.jpg

  2. #2
    Senior Member Regular Contributor uwi2k2's Avatar
    Join Date
    Mar 2011
    Posts
    138
    hi,

    it looks like both objets are in exacly same place ..
    that would lead to so calld "z-fighting".
    Just keep in mind that a transpernt pixel still writes some depth information ...
    Blending can only work properbly id objects are drawn from back to front.
    Can you upload a picture of a single object ? as it is hard to see were object 1 starts and 2 ends.

    regards
    uwi2k2
    uwi2k2 - OpenGL Trainer: www.opengl-trainer.com
    ---------------------------------------------------------
    The OpenGL and VULKAN Podcast ( OpenGL2GO ) : OpenGL & Vulkan Podcast
    ---------------------------------------------------------
    timbling.com - Indie TeamUp

  3. #3
    Junior Member Newbie
    Join Date
    Jan 2015
    Posts
    20
    Quote Originally Posted by uwi2k2 View Post
    hi,

    it looks like both objets are in exacly same place ..
    that would lead to so calld "z-fighting".
    Just keep in mind that a transpernt pixel still writes some depth information ...
    Blending can only work properbly id objects are drawn from back to front.
    Can you upload a picture of a single object ? as it is hard to see were object 1 starts and 2 ends.

    regards
    uwi2k2
    Hello uwi2k2,

    in the picture you can see a single object: it's a tooth in blending mode. Are blending wrong if I draw a single object with depth buffer enabled without
    order the triangles object from back to front? All triangles object are draw with the same color and the same alpha value.
    I attach another picture where I remove the code lines
    /*glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA,GL_ONE);*/
    noblend.jpg

  4. #4
    Senior Member Regular Contributor uwi2k2's Avatar
    Join Date
    Mar 2011
    Posts
    138
    hi,

    ok - got it..
    than you should try: glCullFace() and hide backfaces ... it this works fine .. than the order of the triangles it really the problem ...
    than you need some complex logic to order tem.

    cu
    uwi2k2
    uwi2k2 - OpenGL Trainer: www.opengl-trainer.com
    ---------------------------------------------------------
    The OpenGL and VULKAN Podcast ( OpenGL2GO ) : OpenGL & Vulkan Podcast
    ---------------------------------------------------------
    timbling.com - Indie TeamUp

  5. #5
    Junior Member Newbie
    Join Date
    Jan 2015
    Posts
    20
    Quote Originally Posted by uwi2k2 View Post
    hi,

    ok - got it..
    than you should try: glCullFace() and hide backfaces ... it this works fine .. than the order of the triangles it really the problem ...
    than you need some complex logic to order tem.

    cu
    uwi2k2
    now added

    glEnable(GL_CULL_FACE);
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA,GL_ONE);

    does not work even if the problem is minimized.

    The problem is depend from the viewer position and I can rotate the trackball in positions where I have this problem, and in positions where everything seems ok. This picture is rendered in a position where I can see this problem (GL_CULL_FACE enabled)blendWithCull.jpg

Similar Threads

  1. Reflection Ray incorrect
    By JasonRay in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 09-26-2015, 10:28 AM
  2. glDrawArrays() bug or incorrect use?
    By posixoptions in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 05-27-2010, 06:29 AM
  3. Incorrect lighting
    By blender in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 07-14-2004, 10:56 AM
  4. Incorrect timing
    By dew in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 05-13-2001, 10:58 AM
  5. How to do real time smooth blending of Triangles using OpenGL
    By Navneet Dalal in forum OpenGL: Advanced Coding
    Replies: 7
    Last Post: 01-08-2001, 02:04 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