如何让 d3d 使用我的顶点 alpha 值?

发布于 2024-09-17 19:45:13 字数 265 浏览 2 评论 0原文

我正在尝试在 d3d 中渲染纹理四边形,并且它不使用纹理渲染到的四边形的 VERTICES 的 alpha 值。相反,它使用纹理的 Alpha。

我希望 d3d 使用它所在多边形的顶点的 alpha。

我有一个想法,它与 SetTextureStageState,不过我还没找到。。

I'm trying to render a textured quad in d3d, and its not using the alpha values of the VERTICES of the quad the texture is being rendered to. Rather it is using the alpha of the TEXTURE.

I want d3d to use the alpha of the VERTICES of the polygon it is placed upon.

I have an idea it has to do with SetTextureStageState, but I can't quite find it yet..

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

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

发布评论

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

评论(1

妄想挽回 2024-09-24 19:45:13

好的,这就是我得到的:

D3DTSS 枚举(包含 D3DTSS_* 设置的默认值)

D3DTA 枚举

// where does the SRC color come from?
// why, the currently bound texture of course!
d3d->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
// Default:  D3DTA_TEXTURE (anyway.  So this setting is redundant.)

下一步是重大变化:

// let the alpha component be read from the
// diffuse color of the vertex..
d3d->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);
// Default: D3DTA_TEXTURE (which would be "pull alpha from the texture")

// because my vertex declaration is set up to send 1 color, and
// D3DRS_DIFFUSEMATERIALSOURCE is set to D3DMCS_COLOR1, this means
// to use the vertex alpha i specify.  i think.

其余部分并没有真正改变默认值的任何内容,但它在这里所以一切都可以看到:

// DEST where does the alpha value come from?  also the
// diffuse component
d3d->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_CURRENT);
// Default:  D3DTA_CURRENT.  I believe this means "the destination will
// be whatever the existing color in the framebuffer already is"

// setting up as is default, 
d3d->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_CURRENT);
// Default:  D3DTA_CURRENT.  No change.

我认为这是可行的。

进一步理解:此链接包含一个旧的但非常简洁的工具,称为 MFCTex:

MFCTex program

因此,当您使用不同的参数时,很容易看到所发生的效果。

我意识到这不再是一种很酷的方法了,而且编写自己的顶点和像素着色器确实很酷的方法已经有一段时间了。

OK, here's what I got:

D3DTSS enumeration (containing default values for D3DTSS_* settings)

D3DTA enumeration

// where does the SRC color come from?
// why, the currently bound texture of course!
d3d->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
// Default:  D3DTA_TEXTURE (anyway.  So this setting is redundant.)

THE BIG CHANGE COMES NEXT:

// let the alpha component be read from the
// diffuse color of the vertex..
d3d->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);
// Default: D3DTA_TEXTURE (which would be "pull alpha from the texture")

// because my vertex declaration is set up to send 1 color, and
// D3DRS_DIFFUSEMATERIALSOURCE is set to D3DMCS_COLOR1, this means
// to use the vertex alpha i specify.  i think.

The rest doesn't really change anything from the default values, but its here so everything can be seen:

// DEST where does the alpha value come from?  also the
// diffuse component
d3d->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_CURRENT);
// Default:  D3DTA_CURRENT.  I believe this means "the destination will
// be whatever the existing color in the framebuffer already is"

// setting up as is default, 
d3d->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_CURRENT);
// Default:  D3DTA_CURRENT.  No change.

I think that works.

Further to understanding: this link contains an old but very neat tool called MFCTex:

MFCTex program

So its very easy to see the effect of what's going on when you use different args.

I realize this is not the cool way to do this anymore, and really the cool way has been for some time to write your own vertex and pixel shaders.

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