Jump to content

  • Log In with Google      Sign In   
  • Create Account


AlricDoRei

Member Since 30 Oct 2012
Offline Last Active Sep 29 2013 09:37 PM
-----

Topics I've Started

GL_ONE_MINUS_SRC_COLOR using GLSL

30 October 2012 - 03:45 AM

Here is my code:

glEnable(GL_TEXTURE_2D);
  glBindTexture(GL_TEXTURE_2D, myTexture);
  glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);
  glEnable(GL_BLEND);
  glColor3f(1.0f, 1.0f, 1.0f);
  glBegin(GL_QUADS);
   glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, 0.0f);
   glTexCoord2f(1.0f, 0.0f); glVertex2f(1.0f, 0.0f);
   glTexCoord2f(1.0f, 1.0f); glVertex2f(1.0f, 1.0f);
   glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0f, 1.0f);
  glEnd();
  glDisable(GL_BLEND);
  glBindTexture(GL_TEXTURE_2D, 0);
  glDisable(GL_TEXTURE_2D);

How to emulate these lines using glsl?
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);
  glEnable(GL_BLEND);

Here is my shader program:

vertex shader
void main(void)
{
		gl_TexCoord[0] = gl_Vertex;
		gl_Position = gl_Vertex * 2.0 - 1.0;
}

fragment shader:
uniform sampler2D Texture;
void main()
{
		vec3 Color  = texture2D(Texture, gl_TexCoord[0].st).rgb;
		gl_FragColor = vec4(Color, 1.0);
}

PARTNERS