DirectX 9 固定功能纹理
使用 DirectX 9 中的固定函数渲染管道,通过执行以下操作来设置纹理和渲染顶点非常容易:
struct vert { float x, y, z, u, v; };
device->SetFVF(D3DFVF_XYZ | D3DFVF_TEX1);
device->SetTexture(0, MyTexture);
//Draw vertices here
但是,我想向每个顶点添加一个额外的浮点值,然后将其乘以结果颜色输出从纹理上看。 (所以该值将在 0 和 1 之间)
EG (psuedocode) Colour = TextureColour(u, v) * CustomFloat
我认为有一种使用 device->SetTextureStageState
的方法>,但我不确定该怎么做...任何人都可以帮助我吗?
Using the Fixed Function rendering pipeline in DirectX 9, it's quite easy to set a texture and render vertices by doing the following:
struct vert { float x, y, z, u, v; };
device->SetFVF(D3DFVF_XYZ | D3DFVF_TEX1);
device->SetTexture(0, MyTexture);
//Draw vertices here
However, I'd like to add an additional float value to each vertex, which is then multiplied by the resulting colour output from the texture. (So the value would be between 0 and 1)
EG (psuedocode) Colour = TextureColour(u, v) * CustomFloat
I think there is a way using device->SetTextureStageState
, but I am unsure of how to do it... Can anyone help me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以将一维线性灰度纹理设置为第二个纹理,配置为调制第一个纹理。然后发送第二个纹理的单个纹理坐标(我认为通过为其指定 D3DFVF_TEXCOORDSIZE1 )。这里推测——我自己没有尝试过。
解释一下你的伪代码:
Colour = Texture0Colour(u0, v0) * Texture1Colour(u1)
编辑 我认为你需要:
MSDN 也有 类似示例。
You could set a 1D linear grayscale texture as a second texture, configured to modulate the first. Then send a single texture coordinate for the second texture (by specifying D3DFVF_TEXCOORDSIZE1 for it, I think). Speculating here -- haven't tried it myself.
To paraphrase your pseudocode:
Colour = Texture0Colour(u0, v0) * Texture1Colour(u1)
Edit I think you need:
MSDN also has a similar example.
这有望帮助您开始:每顶点颜色状态 (Direct3D 9)。
您需要像这样使用 FVF:
并通过以下方式启用使用顶点颜色:
这是 另一个链接,显示有关如何设置纹理组合器的更多详细信息。该示例使用 alpha 组合,但修改它以使用颜色组合器应该很简单。
This could hopefully get you started: Per-Vertex Color State (Direct3D 9).
You need to use FVF like this:
and to enable using the vertex color by:
This is another link, showing more details about how to set the texture combiners. The example uses alpha combine, but it should be trivial to modify it to use color combiners instead.