2010-02-02 2 views
2

투명도가있는 텍스처 (조명 정보가있는 흰색 삼각형)가 있고 은 알파벳 변수이 될 수 없습니다. 누락 된 조각 OpenGL-ES 가변 텍스처 알파 (2D)?

alt text http://gotoandplay.freeblog.hu/files/alpha_help.png

그리기 코드

:

//Place polygon vertices to the bottom left within the view. 
    glLoadIdentity(); 
    glTranslatef(centerX, centerY, 0); 

    //Draw "diffuse" layer. 
    glBindTexture(GL_TEXTURE_2D, spriteTexture[0]); //Bind. 
    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); 

    //Offset during development only. 
    glLoadIdentity(); 
    glTranslatef(centerX-10, centerY+10, 0); 

    //Draw "specular" layer. 
    glActiveTexture(GL_TEXTURE0); 
    glBindTexture(GL_TEXTURE_2D, spriteTexture[1]); //Bind. 

    //Some smart alpha scaling code needs here... 

    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); 

누군가는 코드의 적절한 라인 좀 도와 주 시겠어요? 일부 glBlendFunc 또는 glTextEnvi라고 생각할 수도 있습니다.

+0

두 텍스처의 값을 혼합하는 방법을 계산할 수 있습니까? (배경 + 삼각형 1 + 삼각형 2). 또는 두 삼각형을 같은 삼각형에 적용하고 싶습니까? – Frogblast

+0

삼각형은 텍스처에 연결된 별도의 프레임 버퍼로 렌더링됩니다. 따라서이 별도의 프레임 버퍼에서 배경은 (0,0,0,0)이며, 트라이앵글 1은 두 번째 삼각형과 마찬가지로 알파 블렌딩됩니다 (이러한 추가, 변조 등은 없습니다). 내 이전 질문에서 이러한 이미지 (그래서 생성 된 텍스처)를 볼 수 있습니다 : http://stackoverflow.com/questions/2173363/please-help-with-an-opengl-es-iphone-multi-texturing-2d-code – Geri

답변

0

좋아, 내가 정확히 한 일을 이해하지 못한다고해도 알았어. 내가 전에 다른 방법을 시도

//Place polygon vertices to the bottom left within the view. 
    glLoadIdentity(); 
    glTranslatef(centerX, centerY, 0); 

//--1 

     //Draw "diffuse" layer. 
     glActiveTexture(GL_TEXTURE0); 
     glBindTexture(GL_TEXTURE_2D, spriteTexture[0]); //Bind. 

      //Blending. 
      glBlendFunc(GL_ONE, GL_ONE); 

     glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); 

//--2 

     //Draw "specular" layer. 
     glBindTexture(GL_TEXTURE_2D, spriteTexture[1]); //Bind. 

      //Blending. 
      glColor4f(opacity, opacity, opacity, opacity); 
      glBlendFunc(GL_SRC_COLOR, GL_ONE_MINUS_SRC_ALPHA); 

     glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); 

...
glColor4f(1.0f, 1.0f, 1.0f, opacity); 
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 

...하지만 두 번째지도는 어떻게 든 "약한"이었다.