Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3D Api: textures changes randomly #1472

Closed
bosoni opened this issue Mar 15, 2014 · 7 comments
Closed

3D Api: textures changes randomly #1472

bosoni opened this issue Mar 15, 2014 · 7 comments
Labels
bug

Comments

@bosoni
Copy link

@bosoni bosoni commented Mar 15, 2014

I tested xoppa's newest tutorial (frustum culling), it works fine with desktop and bluestacks emu, but when I test it in my phone (galaxy mini), models' textures changed when rotating/moving. It's like it doesnt always bind right texture. My test works like that too (textures changing), even I dont use frustum culling.
Using newest libgdx from git.

http://i58.tinypic.com/2lt5w5v.png
(you can see there are some invaders with ship's texture, and when rotating, other object's will change texture too)

@badlogic badlogic added the bug label Mar 18, 2014
@xoppa
Copy link
Member

@xoppa xoppa commented Mar 18, 2014

Would you mind to include a small test to reproduce the issue? If you work from source, it should be ok to reference the textures/assets of the tests.

@bosoni
Copy link
Author

@bosoni bosoni commented Mar 28, 2014

I just used your https://github.com/xoppa/blog/blob/master/tutorials/src/com/xoppa/blog/libgdx/g3d/frustumculling/step1/FrustumCullingTest.java and step4 code too.

Today I have played with this:
when I removed if (currentShader != renderable.shader) line in ModelBatch.java (flush() method at line 208), then tests seems to work. Hopefully this helps find the actual problem.

@badlogic
Copy link
Member

@badlogic badlogic commented Apr 9, 2014

can reproduce this with basic3dscenetest on a HTC Desire HD. The texture of the ship and the first 2 ufos got swapped randomly when rotating the view.

@xoppa
Copy link
Member

@xoppa xoppa commented Apr 9, 2014

Can you try to use only one texture unit:

RenderContext context;

In create();

context = new DefaultTextureBinder(DefaultTextureBinder.WEIGHTED, 1, 1));
modelBatch = new ModelBatch(context);

In render():

context.begin();
modelBatch.begin(cam);
... // render instances
modelBatch.end();
context.end();
@bosoni
Copy link
Author

@bosoni bosoni commented Apr 15, 2014

That
context = new DefaultTextureBinder(DefaultTextureBinder.WEIGHTED, 1, 1));
line doesnt compile. I tried with
context=new RenderContext( new DefaultTextureBinder( DefaultTextureBinder.WEIGHTED, 1, 1) );
(is that the same?) and added lines in render() but textures still flickers.

@crazysaem
Copy link

@crazysaem crazysaem commented Aug 6, 2014

http://androidblog.reindustries.com/hack-bad-gpu-fix-not-using-correct-texture-opengl/
Could this be the cause of the Problem?

The Galaxy mini seems to have a Adreno 200 GPU so it would fit, see http://en.wikipedia.org/wiki/Samsung_Galaxy_Mini

I had some Texture problems on my phone (HTC DESIRE Z, Adreno 205 GPU), could be the same issue as described here. I fixed it for me on my fork like so: crazysaem@ef152e0

//EDIT: The HTC DESIRE HD also has a Adreno 205 GPU (http://en.wikipedia.org/wiki/HTC_Desire_HD)

@xoppa
Copy link
Member

@xoppa xoppa commented Jan 8, 2015

If anyone is experiencing this problem then please add this class to your project (make sure to update the package name): https://gist.github.com/xoppa/2a1e1adfa3f4764f17f2 and add GL20Adreno20X.enable(); to your create() method. This will rebind the current shader everytime a texture is bound, which is basically the work-a-round proposed in the first link of @crazysaem. I wouldn't suggest doing this by default, you probably only want to do this when the device has an Adreno 20x gpu and is experiencing this issue.

I'm not sure how widely used the Adreno 20x is. We could (conditionally, based on the gpu?) integrate this fix in the android backend. Although I'm personally leaning in favor of not fixing this in core.

@xoppa xoppa closed this Mar 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.