【发布时间】:2015-01-15 16:08:44
【问题描述】:
着色器编译成功,但程序在渲染开始时立即崩溃......这是我得到的错误:“着色器中没有名称为'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);
}
谁能帮帮我。我不知道我做错了什么。顺便说一句,这是我在互联网上找到的着色器,所以我知道它正在工作,唯一的问题是让它与 libgdx 一起工作。
【问题讨论】:
-
这个错误不是很清楚吗? Libgdx 使用统一变量
u_texture来做某事,你的着色器必须有它。 -
我想的差不多,但即使添加了它,错误仍然是一样的
-
你确定错误是一样的吗?你究竟是如何添加这个变量的?
-
我刚刚添加了 uniform sampler2D u_texture;在着色器程序中
标签: opengl opengl-es libgdx glsl shader