libgdx / gdx-video

A libGDX cross platform video rendering extension
Apache License 2.0
147 stars 50 forks source link

no uniform with name 'camTransform' in shader #5

Closed marekhalmo closed 8 years ago

marekhalmo commented 9 years ago

Hello, everything works on my SG4 Mini as expected. If i try to play the video on nVIDIA Shield this error happens:

04-02 15:30:40.469: E/AndroidRuntime(25994): java.lang.IllegalArgumentException: no uniform with name 'camTransform' in shader 04-02 15:30:40.469: E/AndroidRuntime(25994): at com.badlogic.gdx.graphics.glutils.ShaderProgram.fetchUniformLocation(ShaderProgram.java:292) 04-02 15:30:40.469: E/AndroidRuntime(25994): at com.badlogic.gdx.graphics.glutils.ShaderProgram.fetchUniformLocation(ShaderProgram.java:282) 04-02 15:30:40.469: E/AndroidRuntime(25994): at com.badlogic.gdx.graphics.glutils.ShaderProgram.setUniformMatrix(ShaderProgram.java:548) 04-02 15:30:40.469: E/AndroidRuntime(25994): at com.badlogic.gdx.graphics.glutils.ShaderProgram.setUniformMatrix(ShaderProgram.java:536) 04-02 15:30:40.469: E/AndroidRuntime(25994): at sk.maniacs.beatmania.common.VideoPlayerAndroid.render(VideoPlayerAndroid.java:277) 04-02 15:30:40.469: E/AndroidRuntime(25994): at sk.maniacs.beatmania.screens.GameScreenSM.render(GameScreenSM.java:300) 04-02 15:30:40.469: E/AndroidRuntime(25994): at sk.maniacs.beatmania.BeatManiaGame.render(BeatManiaGame.java:648) 04-02 15:30:40.469: E/AndroidRuntime(25994): at com.badlogic.gdx.backends.android.AndroidGraphics.onDrawFrame(AndroidGraphics.java:416) 04-02 15:30:40.469: E/AndroidRuntime(25994): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1523) 04-02 15:30:40.469: E/AndroidRuntime(25994): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)

Any clues why?

Mur4ik commented 9 years ago

It's can be issue with precision in fragment shader.

"varying vec2 " + VARYING_TEXCOORDINATE + ";" + should be "varying mediump vec2 " + VARYING_TEXCOORDINATE + ";" +

in AndroidVideoPlayer.java

marekhalmo commented 9 years ago

Ok i will try to patch this in my local build. I will let you know if it works...

Any other suggestions?

RBogie commented 9 years ago

Hmm, I don't have any suggestions. I would've needed quite a bit of debugging (especially since my only android device is a galaxy s4, which doesn't have any problems with the code...).

Please let me know if this solves it!

marekhalmo commented 9 years ago

Same problem on ADT-1

Mur4ik commented 9 years ago

If prev patch does not work for You, try this one

//@formatter:off String vertexShaderCode = "attribute highp vec4 a_position; \n" + "attribute highp vec2 " + ATTRIBUTE_TEXCOORDINATE + ";" + "uniform highp mat4 " + UNIFORM_CAMERATRANSFORM + ";" + "varying highp vec2 " + VARYING_TEXCOORDINATE + ";" + "void main() \n" + "{ \n" + " gl_Position = " + UNIFORM_CAMERATRANSFORM + " * a_position; \n" + " varTexCoordinate = " + ATTRIBUTE_TEXCOORDINATE + ";\n" + "} \n";

String fragmentShaderCode = "#extension GL_OES_EGL_image_external : require\n" +
        "uniform samplerExternalOES " + UNIFORM_TEXTURE + ";" +
        "varying highp vec2 " + VARYING_TEXCOORDINATE + ";" +
        "void main()                 \n" +
        "{                           \n" +
        "  gl_FragColor = texture2D(" + UNIFORM_TEXTURE + ", " + VARYING_TEXCOORDINATE + ");    \n" +
        "}";
//@formatter:on

should solve all isues on most of devices

Mur4ik commented 9 years ago

Also you can log problems with compiling shaders, place next code right after shader initalization in constructor of AndroidVideoPlayer

if (!shader.isCompiled()) { Gdx.app.log("Problem compiling shader: ", shader.getLog()); }

marekhalmo commented 9 years ago

Thanx... i newer worked with shaders before.. i will update you with the log if necesaary.

marekhalmo commented 9 years ago

Hello, i tested the mod today on nVIDIA Shield. . Worked like a charm! I will test on xperia mini pro and ADT-1 later.

Could you explain what the change was about? Are there any performance implications?

Thanx anyway, you are the best!

Mur4ik commented 9 years ago

Hi. Its all abut shaders language specification, some devices more strict on it. Should not decrease performance. Can be optimized a little if replace all "highp" to "mediump" in cese of second patch solved your preblems.

RBogie commented 9 years ago

Great to hear it is working with these changes!

Could one of you be so kind to put in a pull request, so that this can be merged back into develop? Thanks

jltrem commented 8 years ago

I ran into this on a Galaxy Tab 2. The patch from @Mur4ik corrects it. :thumbsup:

RBogie commented 8 years ago

Great to hear. I will merge the patch when I find some time to do it (Should be this weekend).

jltrem commented 8 years ago

Is there a PR? I can make one today if it is any help

On Thursday, December 17, 2015, Rob Bogie notifications@github.com wrote:

Great to hear. I will merge the patch when I find some time to do it (Should be this weekend).

— Reply to this email directly or view it on GitHub https://github.com/libgdx/gdx-video/issues/5#issuecomment-165538483.

RBogie commented 8 years ago

There is no PR yet. If you could make one, that would be great!

RBogie commented 8 years ago

Fixed by number #15.