Sign in to follow this  


Recommended Posts

AlricDoRei    147
Here is my code:

glBindTexture(GL_TEXTURE_2D, myTexture);
glColor3f(1.0f, 1.0f, 1.0f);
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);
glBindTexture(GL_TEXTURE_2D, 0);

How to emulate these lines using glsl?

Here is my shader program:

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

fragment shader:[CODE]
uniform sampler2D Texture;
void main()
vec3 Color = texture2D(Texture, gl_TexCoord[0].st).rgb;
gl_FragColor = vec4(Color, 1.0);
[/CODE] Edited by AlricDoRei

Share this post

Link to post
Share on other sites
Saruman    4339
[quote name='Brother Bob' timestamp='1351591225' post='4995345']
Unless it has changed in a very recent version, you cannot do blending in the shaders. The blending has to be done using the blending functions.
The only platform I know of right now that supports programmable blending with extensions is iOS using APPLE_shader_framebuffer_fetch and it was just recently added with the latest version of the OS 6.0. The shader receives the built-in variable gl_LastFragData which is read-only but allows you to use it when rendering to the framebuffer.

Share this post

Link to post
Share on other sites
powly k    657
You can render all the things you want into textures with an FBO and blend them in the pixel shader, if you want exact control over what's going on. This won't work for more than a few things, though, so if you want to do lots of blending, just use the glblendfunc(separate) and glblendequation functions. You can't do everything with them, but even GPUs can't do everything :)

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this