Kyle Shay
Kyle Shay

Reputation: 688

blending two fragment shaders with opengl/glsl

I have two shaders that do different things. The first loads an image generated realtime from a html5 canvas, the other is generated by a string that represents the code for the shader.

Basically, I would like to overlay the texture over the first shader, but not have the shader generated by the code have any effect on the texture. The texture itself has its own shader.

How can I display both shaders (the one with the texture would have a white transparency so the generated shader below would be visible.

Upvotes: 1

Views: 415

Answers (1)

Quonux
Quonux

Reputation: 2991

Use the blending operations see here (yes its an old link but its still valid).

Draw the underlying triangles with the shader, then enable blending and draw the other trangles with the other shader, not also that the second shader must write the Alhpa value (eg. 0.7).

About your terminology:

Saying that a texture has a shader is plainly wrong, shaders fetch textures so you basically see only a shader that does operations on textures.

Upvotes: 1

Related Questions