Libgdx 3D纹理透明度 [英] Libgdx 3D Texture Transparency

查看:319
本文介绍了Libgdx 3D纹理透明度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在圆柱体上有纹理问题.基本上,它是一枚带有纹理的硬币, 我之前已经作为演示完成了此操作,但丢失了代码. 现在我面临的问题是我无法再使硬币的边缘变得透明. png的透明部分在圆柱上,甚至在我尝试过的盒子上都显示为白色.

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.

我启用了G20.GL_Blend, 具有alpha_src和one_minus_alpha_src的混合功能,启用了诸如texture_2d之类的功能. (对错误的变量名表示抱歉,仅在我的电话atm上,它将更改@home)

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)

我已经尝试了所有可以在网上找到的内容,但是并没有改变.看来blend功能完全不会影响纹理.

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

这就是我得到的,一个框显示它会更好.忘记添加定向灯, 灰色是白色,而不是灰色!

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

这是我在render()方法中使用的代码(我尝试了不同的组合,所以这就是为什么这么多的原因):

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);

推荐答案

向模型添加混合属性:

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

这篇关于Libgdx 3D纹理透明度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆