开发者

Colouring Textures Without Vertex Buffer Diffuse

开发者 https://www.devze.com 2023-03-07 17:53 出处:网络
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'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:

  1. Locking the vertex buffer.
  2. Changing the diffuse colour on each of the vertices.
  3. 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 w开发者_Go百科ant 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


I don't think so - as per MSDN docs on D3D lighting:

Note that although Direct3D uses RGBA values for lights, the alpha color component is not used.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消