Mesh typo into a shader

hi,
i drewa font in mesh thanks to getStringMesh

   myFont->getFontTexture().bind();
   myFont->getStringMesh(boids[i].myName,0,0).draw();
   myFont->getFontTexture().unbind();

I want to send it to a shader to make a fog
and of course that doesn’t work
apparently its because i have to send the font texture to the shader
so i tried with that

myShader.setUniformTexture(“tex1”,myFont.getFontTexture(),1);

and the frag shader

void main(){
uniform sampler2D tex1;
gl_FragColor = texture2D(tex1, vec2(gl_TexCoord));
}

Shader are so hard to debug,
it’s like walking in dark rooom

Wat that >>
vec4 color = texture2D(Texture0, vec2(gl_TexCoord[0]));
gl_FragColor = color;

myShader.setUniformTexture("tex1",myFont.getFontTexture(),1);

should be

myShader.setUniformTexture("tex1",myFont.getFontTexture(),0);

note the 0 instead of 1.

but doing just bind should work anyway. the texture has rgb as luminance so you should be multiplying that by the color you actually want to draw the font and then use the alpha form the font texture, something like:

vec4 tex_color = texture2D(Texture0, vec2(gl_TexCoord[0]));
vec4 color = vec4(1.0,0.0,0.0,1.0) * tex_color;
gl_FragColor = color;

which should draw the font as red.

also it’s usually useful to draw the tex coordinates as color to see if you are getting them correctly, like:

vec4 tex_color = vec4(gl_TexCoord[0].xy,0.0,1.0);
gl_FragColor = color;

which should draw a slight gradient in the boxes for each glyph

Thanks for the response,
OF change my life
i am still not really understanding how shader pipline works
i use also a vertex shader to create a fog
so which color is considered, the color of the frag shader ? of the vertex shader ? both ?
Other small trouble
the square typo mesh is visible behind the texture
the are a way to hidden it ?

the color in the fragment shader is usually an interpolation in between vertices of the color you set per vertex in the veretex shader, unless you pass it as a uniform in that case it’s the same in both.

in this case i would pass it as a uniform and apply it in the fragment shader.

what do you mean by the square typo?

if you zoom on the picture you can see a black square behind some letter.
i suppose it’s the 4 vertex mesh of each letter.

ah, i think it’s a problem with depth test while using alpha, it’s kind of tricky to solve and in your case where an object might be in different depths it could be even more, here are a couple of topics that talk about it: