Results 1 to 2 of 2

Thread: Multitexturing && Texture With Alpha Channel problem....

  1. #1
    Junior Member
    Join Date
    Apr 2009
    Posts
    1

    Multitexturing && Texture With Alpha Channel problem....

    Hi all,
    I have two textures, while texture0 has no alpha channel(RGB 565), and texture1 has alpha channel (RGBA888, i export&load them via pvr format.
    so the final rgb = texture0.rgb + (texture1.rgb * texture1.alpha). //and there is no need to blend with background color
    I am new to opengl es, and i found glTexEnv(xxx) is so hard to understand and use.....
    I've tried code in "OGLES-1.1_WINDOWS_PCEMULATION_2.03.23.1162\TrainingCours e\10_Multitexture", but the result looks strange, here is my code:
    Code :
            glDisable(GL_BLEND); 
             glActiveTexture(GL_TEXTURE0);
    		glBindTexture(GL_TEXTURE_2D, m_ui32Ground);
                  // Set up the Second Texture
    		glActiveTexture(GL_TEXTURE1);
    		glBindTexture(GL_TEXTURE_2D,  m_ui32WallForeground);//m_ui32WallForeground
     
    	   /**/
    		// Set the texture environment mode for this texture to combine
    		myglTexEnv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
     
    		// Set the method we're going to combine the two textures by.
    		myglTexEnv(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);//GL_MODULATE
     
    		// Use the previous combine texture as source 0
    		myglTexEnv(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE);
     
    		// Use the current texture as source 1
    		myglTexEnv(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PREVIOUS);
     
     
    			//Set what we will operate on, in this case we are going to use
    			//just the texture colours.
     
    		myglTexEnv(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
    		myglTexEnv(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_DST_ALPHA);
     
     
    		// Indexed Triangle list
    		glDrawElements(GL_TRIANGLES, Mesh.nNumFaces * 3, GL_UNSIGNED_SHORT, (unsigned short*)Mesh.sFaces.pData);

    Please help me...

  2. #2
    Senior Member
    Join Date
    May 2006
    Posts
    353

    Re: Multitexturing && Texture With Alpha Channel problem....

    GL_DST_ALPHA is not a valid value for GL_OPERAND1_RGB, I suppose you meant GL_SRC_ALPHA.

    However, to do what you want, i.e.
    final rgb = texture0.rgb + (texture1.rgb * texture1.alpha)
    you need to do the multiplication first, i.e. on texture environment TEXTURE0, and the addition on TEXTURE1. To keep it simple you can set the vertex color to black and use GL_DECAL and GL_ADD.

    Code :
    glColor4ub(0, 0, 0, 255);
    glActiveTexture(GL_TEXTURE0);
    glEnable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, m_ui32WallForeground);
    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
    glActiveTexture(GL_TEXTURE1);
    glEnable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, m_ui32Ground);
    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD);
    Georg Kolling, Imagination Technologies
    Please ask questions specific to PowerVR hardware or SDKs on the PowerVR Insider Forum
    DevTech@imgtec.com | http://www.powervrinsider.com

Similar Threads

  1. Replies: 2
    Last Post: 07-30-2009, 06:44 PM
  2. render to texture & shadows w/o stencil
    By crafter in forum OpenGL ES general technical discussions
    Replies: 0
    Last Post: 11-09-2005, 05:37 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
  •