0
\$\begingroup\$

I'm trying to get a "ripple"-shader working for OpenGL ES 2.0+ (using LibGDX).

However, I can't get it to compile, and for some reason ShaderProgram.getLog() returns an empty string even though the Shader didn't compile.

I am 100% confident that the vertex shader is correct.. here's the fragment shader (not written by me, but I modified it a bit long time ago.. when I had a desktop project - and it worked back then):

                #version 120
                precision mediump float;
                varying vec2 v_texCoords;
                uniform float time;
                uniform float alpha;
                uniform float waveLengthMultiplier;
                uniform sampler2D u_texture;
                void main()
                {
                    vec2 center = vec2(0.5, 0.5);
                    vec2 tc = v_texCoords.xy;
                    vec2 p = -1.0 + 2.0 * (tc - offset);
                    float len = length(p) * waveLengthMultiplier;
                    vec2 uv = tc + (p / len) * cos(len * 12.0 - time * 4.0) * 0.03;
                    vec3 col = texture2D(u_texture, uv).xyz;
                    gl_FragColor = vec4(col, alpha);
                }

I'm still not very well-versed with shaders, as I've used them only a little.. Like I said, getLog() returns an empty string, so I'm hoping someone spots an error in the code.

\$\endgroup\$
  • \$\begingroup\$ Did you forget to declare float precision at the top of the fragment shader? precision mediump float; \$\endgroup\$ – TenFour04 Mar 25 '16 at 19:26
1
\$\begingroup\$

"offset" is not declared. Not sure why it would compile anywhere else, I doubt it.

\$\endgroup\$
  • \$\begingroup\$ The thing is, I actually cleaned up the shader (as I converted it from Java String to Kotlin multiline String) and by the looks of it I removed the offset in the process.. thank you. Do you (or anyone else) have ideas why the log might return an empty string? \$\endgroup\$ – fluxi Mar 8 '16 at 11:08
  • \$\begingroup\$ OK, after removing the offset completely the Shader works flawlessly on desktop. Any ideas why it doesn't work on Android (5.0)? This is kind of difficult to debug without the log :( \$\endgroup\$ – fluxi Mar 8 '16 at 13:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.