guys, I got a question on how to use multiple shaders in my app. The app is simple: I have a 3D scene, say, simple game and I want to show some 2D GUI in the scene. I was following this tutorial on how to add font rendering to my scene. One difference is that I am using Java and lwjgl, but everything is implemented as in the tutorial.

So I have 2 sets of shaders (2 programs). 1st that handles the 3D models and scene at all. I added the second set of shaders, I just copied them from the tutorial. Here are they:


#version 330
in vec2 position;
in vec2 texcoord;
out vec2 TexCoords;
uniform mat4 projection;

void main() {
    gl_Position = projection * vec4(position, 0.0, 1.0);
    TexCoords = texcoord;

and fragment:

#version 330
in vec2 TexCoords;
out vec4 color;

uniform sampler2D text;
uniform vec3 textColor;

void main() {
    vec4 sampled = vec4(1.0, 1.0, 1.0, texture(text, TexCoords).r);
    color = vec4(textColor, 1.0) * sampled;

I compile shaders, link them into a separate programs. (so I have modelProgram and fontProgram). However, when I run my application, I see errors in the console (however, the application runs fine):

WARNING: Output of vertex shader 'TexCoords' not read by fragment shader
ERROR: Input of fragment shader 'vNormal' not written by vertex shader
ERROR: Input of fragment shader 'vTexCoord' not written by vertex shader
ERROR: Input of fragment shader 'vPosition' not written by vertex shader

As you can see TexCoords is an out variable in font.vs.glsl and the other 3 are in variables in model.fs.glsl. So they belong to the other set of shaders, other program.

My question is why this happen? It looks like the pipeline tries to combine one program with another, although the application runs smoothly.

The other problem I have is that I do not see any text rendered. I don't know whether this is caused by this or it happens because something else. Any help will be appreciated!

Thank you


1 Answer 1


Make sure that you're doing glUseProgram(0); and then glUseProgram(SHADER_PROGRAM_ID); (The first of those is likely unnecessary, but it's always a good idea to be over-explicit when in doubt) If you're doing that, be sure that you're loading the correct files into the shader. You might be initializing a shader with the source code from one of the wrong shaders, while the other is the correct one.

  • \$\begingroup\$ OMG. You are right. When compiling my second program, I used the correct vertex shader, but the fragment shader from the first program! Thank you. Anyways, I still don't see my text rendered, but I guess it would be for another question. \$\endgroup\$ Commented May 26, 2018 at 19:02
  • \$\begingroup\$ @MarošŠeleng Glad to help! \$\endgroup\$
    – CJ Burkey
    Commented May 26, 2018 at 19:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .