在没有顶点缓冲区漫反射的情况下为纹理着色
我目前正在开发一个二维 Direct3D 应用程序,并且正在尝试弄清楚如何向不同的纹理正确添加色调和 Alpha 效果。
我以前让它工作过,但我这样做的方式是:
- 锁定顶点缓冲区。
- 更改每个顶点的漫反射颜色。
- 解锁顶点缓冲区。
从那时起我就听说并了解到,这是一个相当繁重的操作,每帧执行数十次,所以我想知道我还能怎么做。
我正在研究漫射照明,但我不确定这是否允许我为纹理添加不透明度。如果我向纹理添加不透明度为 50% 的漫射光,纹理的不透明度是否也会为 50%?
感谢任何指导,教程和示例代码更是如此:),
詹格勒
I'm currently working on a two-dimensional Direct3D application, and I'm trying to figure out how to properly add a hue and alpha effect to different textures.
I had it working previously, but the way I was doing it was by:
- Locking the vertex buffer.
- Changing the diffuse colour on each of the vertices.
- Unlocking the vertex buffer.
I've heard and learned since then that this is a pretty heavy operation to do dozens of times per frame, so I want to know how else I could do it.
I was looking into diffuse lighting, but I'm not sure whether that allows me to add opacity to textures. If I add a diffuse light with 50% opacity to a texture, will the texture have 50% opacity?
Any guidance is appreciated, tutorials and sample code more so :),
Jengerer
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不这么认为 - 根据 MSDN 文档D3D 照明:
编写一个着色器来调整每个顶点的颜色听起来就像您所追求的那样,它在 GPU 中运行,与修改 CPU 上的每个顶点相比,性能开销很小。网络上有很多 D3D 教程,例如
http://gpwiki.org /index.php/DirectX:Direct3D:教程:Shaders_Introduction
http://www .toymaker.info/Games/html/shaders.html
I don't think so - as per MSDN docs on D3D lighting:
Writing a shader to adjust the color for each vertex sounds like what you're after, which runs in the GPU and has little performance overhead compared to modifying each vertex on the CPU. There's lots of tutorials around for D3D on the web, e.g.
http://gpwiki.org/index.php/DirectX:Direct3D:Tutorials:Shaders_Introduction
http://www.toymaker.info/Games/html/shaders.html