Libgdx 3D Texture Transparency

最后都变了- 提交于 2019-12-07 10:20:41

问题


I'm having a problem with a texture on a cylinder. Basically it is a coin with a texture on it, I have done this before as demo but lost the code. Now the problem I'm facing is that I cant get the edge of the coin to be transparent anymore. The transparent parts of the png appear white on the cylinder, or even the box I tried.

I enabled G20.GL_Blend, have the blending function with alpha_src and one_minus_alpha_src, enabled something like texture_2d. (Srry for the wrong variable names, only on my phone atm, will change @home)

I have tried everything I can find online, but it just doesnt change. It doesnt seem like the blendfunction affects the texture at all.

Oh I'm running the latest nightly for this project, the one before, when it worked, was an older one...could that be it?

Hope someone can help, will post code and photos when i get home if needed

EDIT:

Here is what I get, a box shows it better. Forgott to add a directional light, the grey is white, NOT grey!!

This is the code I use in the render() method(I tried different combinations, so thats why there are so many):

    Gdx.gl20.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
    Gdx.gl20.glEnable(GL20.GL_BLEND);
    Gdx.gl20.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    Gdx.gl20.glEnable(GL20.GL_TEXTURE_2D);
    Gdx.gl20.glBlendEquation(GL20.GL_BLEND);

    modelBatch.begin(cam);
    texture.bind();
    modelBatch.render(instance, environment);
    modelBatch.end();

    Gdx.gl20.glDisable(GL20.GL_TEXTURE_2D);

回答1:


Add a blending attribute to the model:

http://www.badlogicgames.com/forum/viewtopic.php?f=11&t=10016&p=45952#p45369



来源:https://stackoverflow.com/questions/19112349/libgdx-3d-texture-transparency

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!