*FIXED* Problem with black transparency.
  • Caterpillar
    Caterpillar
    AmiDARK
    Posts: 38 from 2011/10/29
    From: South France
    Hi All,

    I have fixed the crashes I had in the MorphOS version of the AmiDARK engine and nearly everything run fine.
    But, I have a problem.
    When I set transparency to 1 on a 3D Object, the 3D object disappear.

    On AmigaOS4.1 the transparency work perfectly (MiniGL/OpenGL) but not on MorphOS.

    Here is the details for cases 0 & 1. 0 = no transparency, 1 = black is not visible
    Code:
        switch( MyObjectMesh->Transparency ){
    case 0: // 0 - First Phase rendering NO ALPHA
    glEnable( GL_BLEND );
    glBlendFunc( GL_ONE, GL_ZERO );
    glDisable( GL_ALPHA_TEST );
    glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
    glTexEnvf( GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE );
    break;
    case 1: // 1 - First Phase WITH ALPHA MASKING
    glEnable( GL_BLEND );
    glEnable( GL_DEPTH_TEST );
    glEnable( GL_ALPHA_TEST );
    glAlphaFunc( GL_EQUAL, 0 );
    glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
    glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
    glTexEnvf( GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE );
    break;


    Does anyone have any clue ?


    [ Edité par AmiDARK 19.01.2012 - 14:28 ]
  • »16.01.12 - 21:06
    Profile Visit Website
  • MorphOS Developer
    kiero
    Posts: 129 from 2003/2/28
    if i'm not mistaken here is why:

    case 1: // 1 - First Phase WITH ALPHA MASKING
    glEnable( GL_BLEND );
    glEnable( GL_DEPTH_TEST );
    glEnable( GL_ALPHA_TEST );
    glAlphaFunc( GL_EQUAL, 0 ); <---- only pass fragments with alpha value of 0
    glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); <--- blend using source fragment alpha
    glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
    glTexEnvf( GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE );
    break;

    now combine these two rules and you get that only fragments with alpha == 0 are drawn and they are invisible because of the second rule. if this is not the case then prepare some >simple< test code and i will try to verify. and please, don't use amigaos minigl as a reference. if you want to check something run it through software implementation (mesa) or on pc.
  • »17.01.12 - 21:39
    Profile Visit Website
  • Caterpillar
    Caterpillar
    AmiDARK
    Posts: 38 from 2011/10/29
    From: South France
    Excuse, GL_EQUAL was the last test done.
    Defaut value was "GL_NOTEQUAL, 0"
    What is strange is that under AmigaOS4.x it work perfectly with GL_NOTEQUAL, 0 and not under MorphOS ... Objects are not displayed.

    I don't use PC for development and, firstly, the AmiDARK Engine was developed on AmigaOS 4.x ... Now, I can adapt it to MorphOS cos I have an Efika ... but before it was only for AmigaOS4.x ... This is why AmigaOS 4.x is my reference.

    [ Edité par AmiDARK 17.01.2012 - 23:18 ]
  • »17.01.12 - 23:16
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    Posts: 186 from 2003/10/23
    sorry for the off topic, but i see kiero online :D

    Kiero can u put an eye and watch this problem ?

    https://morph.zone/modules/newbb_plus/viewtopic.php?forum=49&topic_id=7895&post_id=84425&viewmode=flat&sortorder=1&showonepost=1
    I'm nerdy in the extreme
    And whiter than sour cream

    White&Nerdy 2006 Al Yankovic
  • »18.01.12 - 11:23
    Profile
  • Caterpillar
    Caterpillar
    AmiDARK
    Posts: 38 from 2011/10/29
    From: South France
    Hi,

    I've fixed my issue using this :

    Code:
            glEnable( GL_DEPTH_TEST );
    glBlendFunc( GL_ONE, GL_ZERO );
    glEnable( GL_BLEND );
    glAlphaFunc( GL_NOTEQUAL, 0.0f );
    glEnable( GL_ALPHA_TEST );
    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);


    Kindest Regards,
    AmiDARK
  • »19.01.12 - 14:28
    Profile Visit Website