如何在 DirectX 上启用 Alpha 混合?
如何在 DirectX 中执行此操作?
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
不知怎的,我似乎无法让它发挥作用。我使用代码:
d3ddev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCCOLOR);
d3ddev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCCOLOR);
d3ddev->SetRenderState(D3DRS_ALPHABLENDENABLE, 1);
d3ddev->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL);
d3ddev->SetRenderState(D3DRS_ALPHAREF, (DWORD)50);
d3ddev->SetRenderState(D3DRS_ALPHATESTENABLE, 1);
但它会用某种幻影方法渲染我的多边形,我可以看透我所有的多边形!我只想用 Alpha 通道制作纹理,以通过那些完全透明的纹理片段显示出来。这适用于 alphatest,但它仍然显示黑色边缘,所以我猜混合没有启用,即使我已经设置了 D3DRS_ALPHABLENDENABLE !我做错了什么?
How to do this in DirectX?
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
Somehow i just cant seem to get it work. Im using code:
d3ddev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCCOLOR);
d3ddev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCCOLOR);
d3ddev->SetRenderState(D3DRS_ALPHABLENDENABLE, 1);
d3ddev->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL);
d3ddev->SetRenderState(D3DRS_ALPHAREF, (DWORD)50);
d3ddev->SetRenderState(D3DRS_ALPHATESTENABLE, 1);
But it will render my polygon with some sort of ghosted method, i can see through all my polygons! i just want to make the texture with alpha channel to show through those fully transparent pieces of texture. this works with alphatest, but it still shows black edges, so i guess the blending isnt enabled, even though i have set D3DRS_ALPHABLENDENABLE ! What im doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我需要使用 SRCALPHA 而不是 SRCCOLOR:
instead of SRCCOLOR i needed to use SRCALPHA: