I’ve written and used shaders for libgdx in the past, but never run into this stupid f**king problem.
“no uniform with name ‘u_texture’ in shader”
Exception in thread "LWJGL Application" java.lang.IllegalArgumentException: no uniform with name 'u_texture' in shader
at com.badlogic.gdx.graphics.glutils.ShaderProgram.fetchUniformLocation(ShaderProgram.java:293)
at com.badlogic.gdx.graphics.glutils.ShaderProgram.fetchUniformLocation(ShaderProgram.java:283)
at com.badlogic.gdx.graphics.glutils.ShaderProgram.setUniformi(ShaderProgram.java:307)
Here’s my shader fragment program
#ifdef GL_ES
precision mediump float;
#endif
uniform sampler2D u_sampler2D;
uniform vec2 u_resolution;
varying vec4 v_color;
varying vec2 v_texCoord0;
void main()
{
vec4 color = texture2D(u_sampler2D, v_texCoord0) * v_color;
vec2 fragPos = gl_FragCoord.xy / u_resolution.xy; //will give range in [0-1, 0-1]
float dist = distance(fragPos, vec2(0.5, 0.5)); //distance to the center of the screen
gl_FragColor = vec4(0, 0, dist, 1);
}
I’ve tried for so long to get this shit to work. None of my other shaders have this f**king problem.
And here’s the real kicker. I put my exact same shader code in a different libgdx project and it worked, but in this new project it keeps giving me this stupid f**king error.
I even tried setting the sampler2D’s name to u_texture and that didn’t work.