LibGdx Shader("着色器中没有名称'u_texture'的制服")

use*_*999 2 opengl shader opengl-es glsl libgdx

Shader成功编译,但是一旦渲染开始,程序就会崩溃......这就是我得到的错误:"在着色器中没有名称'u_texture'的统一".这就是我的着色器的样子:

#ifdef GL_ES
precision mediump float;
#endif

uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
varying vec2 surfacePosition;


#define MAX_ITER 10
void main( void ) {

    vec2 p = surfacePosition*4.0;
    vec2 i = p;
    float c = 0.0;
    float inten = 1.0;

    for (int n = 0; n < MAX_ITER; n++) {
        float t = time * (1.0 - (1.0 / float(n+1)));
        i = p + vec2(
            cos(t - i.x) + sin(t + i.y), 
            sin(t - i.y) + cos(t + i.x)
        );
        c += 1.0/length(vec2(
            p.x / (sin(i.x+t)/inten),
            p.y / (cos(i.y+t)/inten)
            )
        );
    }
    c /= float(MAX_ITER);

    gl_FragColor = vec4(vec3(pow(c,1.5))*vec3(0.99, 0.97, 1.8), 1.0);
}
Run Code Online (Sandbox Code Playgroud)

有人可以帮帮我吗.我不知道我做错了什么.顺便说一句,这是我在互联网上找到的着色器,所以我知道它正在工作,唯一的问题是使它与libgdx一起工作.

Ale*_*nov 7

libGDX的SpriteBatch假定你的着色器将具有'u_texture'制服.要在将着色器程序放入SpriteBatch之前添加 u_texture(Javadoc).

更新:raveesh关于着色器编译器消失未使用的制服和属性是正确的,但libGDX在自定义ShaderProgram中包装OpenGL着色器.