OpenGL ES 2.0着色器,如何调用时间变量?

时间:2011-06-03 17:27:36

标签: opengl-es time shader opengl-es-2.0

我尝试执行这样的像素着色器:

"#ifdef GL_ES\n"
"    precision highp float;\n"
"    #endif\n"
"    \n"
"   uniform float time;\n"
"       uniform vec2 resolution;\n"
"\n"
"       void main( void ) {\n"
"\n"
"        vec3 rgb = vec3( abs( sin( time / 5.0 ) ), 0.0, 0.0 );\n"
"        gl_FragColor = vec4( rgb, 1.0 );\n"
"\n"
"       }\n"

我想让它工作alike this webGL mrdoob sample(从黑色到红色)。但似乎时间变量只是0 ...(

BTW sample shown here按预期符文。

OpenGL ES 2.0的像素着色器中是否有“时间变量”?

1 个答案:

答案 0 :(得分:4)

检查第一个链接上的页面来源。您必须计算并传入主机程序中的time值。

OpenGL ES 2.0没有时间,挂钟或其他概念。