使用固定功能渲染管道在 DirectX9 中按顶点预计算光照
我正在使用固定功能管道制作 DirectX 9 C++ 应用程序,给定每个顶点的预先计算光照(无论法线/等)如何将其应用到最终图像?
我目前正在使用纹理基元,并且正在尝试更改整体颜色(在整个基元上,而不是使用渐变),并且由于灯光数量和应用程序的设计,我必须预先计算照明即使在低端机器上也能获得不错的帧速率。 (即每个光一次传递太多)
我的顶点结构看起来像
struct Vertex
{
float x, y, z, u, v;
};
基本上我想为其添加一个照明值,并使用每个顶点的固定功能管道应用它(不使用实际的“光”)
任何帮助将不胜感激...
I'm making a DirectX 9 C++ application using the fixed function pipeline, given pre-computated lighting for each vertex, (Regardless of normals/etc) how can I apply this to the final image?
I'm currently using textured primitives and I'm trying to change colour as a whole (over the entire primitive -- rather than using a gradient) and I have to precalculate lighting because of the the number of lights and the application being designed to get decent framerates even on low-end machines. (IE one pass per light is one too many)
My vertex struct looks like
struct Vertex
{
float x, y, z, u, v;
};
Basically I want to add a lighting value to that and apply it using the fixed function pipeline per vertex (without using actual "lights")
Any help would be greatly appreciated...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不再使用固定功能管道,因为我像该领域的几乎其他人一样使用着色器,我忘记了细节,因此我无法提供完整且准备工作的答案,但这有望为您提供一个开始:
每顶点颜色状态 (Direct3D 9)< /a>.
您需要像这样使用 FVF:
并通过以下方式启用顶点颜色:
如果您不想使用任何照明,一种选择是使用具有漫反射分量黑色和环境分量白色的单向光。这样,照明将完全平坦,并且仅使用材质颜色。
也就是说,您真的需要关心固定功能渲染吗?使用着色器可以很容易地实现这一点,并且您可以找到很多人能够为您提供如何做到这一点的建议。
I no longer work with fixed function pipeline, as I am using shaders like almost anyone else in the field, I have forgotten the details and I am therefore unable to provide a complete and ready to work answer, but this could hopefully give you a start:
Per-Vertex Color State (Direct3D 9).
You need to use FVF like this:
and to enable using the vertex color by:
If you do not want to use any lighting, one option is to use a single directional light with diffuse component black and ambient component white. This way the lighting will be completely flat and only the material colors will be used.
That said, do you really need to be concerned about fixed function rendering? Using shaders it would be very easy to implement this and you can find a lot of people able to give you advice how to do that.