Welcome! Log In Create A New Profile

Advanced

GX_SetCopyClear & GX Blender problems

Posted by ekeeke 
GX_SetCopyClear & GX Blender problems
April 10, 2009 06:06PM
Here's a little problem I got with the GX blender, which is driving me nut.
In my case,I turn the Blender ON with the following function call:

    GX_SetBlendMode(GX_BM_BLEND,GX_BL_SRCALPHA,GX_BL_INVSRCALPHA,GX_LO_CLEAR);

As we already know, this allows to render images as textured quads with transparencies (texture alpha) above the background color in EFB. The result pixel color being calculated this way:

Quote

new_efb.color = (texture.alpha x texture.color) + (1 - texture.alpha) x old_efb.color

Everything worked fine until I tried to setup the EFB background color to something else than pure black, for example:

  GXColor BACKGROUND = {0xd4,0xd0,0xc8,0xff}; /* light grey */
  GX_SetCopyClear(BACKGROUND,0x00ffffff);

Now, if I clear the EFB with this light color and try to render a texture into EFB, it seems like the texture color intensity is influenced by the background color:textures supposed to be grey (0x33,0x33,0x33,0xff) are displayed in pure black (0x00,0x00,0x00,0xff) when it should not be the case ... or more likely, it's as if the color luminance was lowered a lot (only happen to grey colors though)

Some facts:
- this does not happen if I turn the Blender OFF (and lose transparencies), that's why I thought it has somehing to do with that .
- this does not happen when running the dol in Gcube
- the strangest thing is that the efffect is less visible when I render other texture with transparencies, even if the two textures does not overlap... but not always, depends on the textures being rendered.
- colored textures (other than grey or dark grey ones) seems not to be affected

Does anyone with strong GX experience have any idea what the problem could be ? Is it a bug in libogc or somewhere else ? Does anyone ever used another EFB background color than BLACK ?


On a side note, here's the code I'm using to render textures:

if (texture->data)
  {
    /* load texture object */
    GXTexObj texObj;
    GX_InitTexObj(&texObj, texture->data, texture->width, texture->height, GX_TF_RGBA8, GX_CLAMP, GX_CLAMP, GX_FALSE);
    GX_LoadTexObj(&texObj, GX_TEXMAP0);
    GX_InvalidateTexAll();

    /* adjust coordinate system */
    x -= (vmode->fbWidth/2);
    y -= (vmode->efbHeight/2);

    /* Draw textured quad */
    GX_Begin(GX_QUADS, GX_VTXFMT0, 4);
    GX_Position2s16(x,y+h);
    GX_Color4u8(0xff,0xff,0xff,0xff);
    GX_TexCoord2f32(0.0, 1.0);
    GX_Position2s16(x+w,y+h);
    GX_Color4u8(0xff,0xff,0xff,0xff);
    GX_TexCoord2f32(1.0, 1.0);
    GX_Position2s16(x+w,y);
    GX_Color4u8(0xff,0xff,0xff,0xff);
    GX_TexCoord2f32(1.0, 0.0);
    GX_Position2s16(x,y);
    GX_Color4u8(0xff,0xff,0xff,0xff);
    GX_TexCoord2f32(0.0, 0.0);
    GX_End ();
    GX_DrawDone();
  }

could it be a problem with texture coordinates (back/front texture face problem) ?



Edited 5 time(s). Last edit at 04/10/2009 11:01PM by ekeeke.
Sorry, only registered users may post in this forum.

Click here to login