设置透明度使纹理半透明

发布于 2024-09-24 14:23:48 字数 643 浏览 5 评论 0原文

好的,所以我的问题是我在 java3d 中有一个平面,上面画有纹理。该纹理是具有 Alpha 透明度的 PNG。渲染场景时,平面上的纹理部分半透明,就好像整个图像具有一定的透明度一样。我尝试过各种纹理和透明度设置,试图让它发挥作用

Appearance ap = new Appearance();
TextureLoader tl = new TextureLoader(textImage);
Texture tex = tl.getTexture();
TextureAttributes ta = new TextureAttributes();
ta.setTextureMode(TextureAttributes.MODULATE);
TransparencyAttributes transat = new TransparencyAttributes();
transat.setTransparencyMode(TransparencyAttributes.BLENDED);
transat.setTransparency(0f);

ap.setTextureAttributes(ta);
ap.setTexture(tex);
ap.setTransparencyAttributes(transat);

shape.setAppearance(ap);

任何帮助将不胜感激

Ok, so my problem is that I have a plane in java3d that has a texture painted on it. This texture is a PNG with alpha transparency. When the scene is rendered the texture on the plane is partially translucent, as if it has some transparency over the entire image. I have played around with a variety of texture and transparency settings trying to get it to work

Appearance ap = new Appearance();
TextureLoader tl = new TextureLoader(textImage);
Texture tex = tl.getTexture();
TextureAttributes ta = new TextureAttributes();
ta.setTextureMode(TextureAttributes.MODULATE);
TransparencyAttributes transat = new TransparencyAttributes();
transat.setTransparencyMode(TransparencyAttributes.BLENDED);
transat.setTransparency(0f);

ap.setTextureAttributes(ta);
ap.setTexture(tex);
ap.setTransparencyAttributes(transat);

shape.setAppearance(ap);

Any help would be appreciated

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

z祗昰~ 2024-10-01 14:23:48

如果您不希望任何纹理有任何透明度,请尝试以下操作:

TransparencyAttributes tAttr = new TransparencyAttributes();
tAttr.setTransparencyMode(NONE);
ap.setTransparencyAttributes(tAttr);

If you don't want any transparency at all for any of your texture, try this:

TransparencyAttributes tAttr = new TransparencyAttributes();
tAttr.setTransparencyMode(NONE);
ap.setTransparencyAttributes(tAttr);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文