简体   繁体   中英

Render with multiple textures in managed Direct3D 9

I am pretty new Direct3D and have been looking for a solution to my problem for a couple of days. Most of the tutorials I have seen that cover textures only use one texture. For my program I have multiple textures that map to a specific collection of vertices that make up my mesh.

My question is how do I load multiple textures into my scene? and how do I map a collection of vertices to only one texture?

For example if I had a mesh of a car and I had a collection of textures like:

 Tyres.dds
 Body.dds
 Cabin.dds

Given the car, how do I map the vertices that make up the tyre to the tyres.dds texture, body to body.dds and cabin to cabin.dds. All these textures have to render not just one.

Any help would be greatly appreciated, Thank You

Usually this is done via submeshes. That means that the mesh consists of several parts that are represented as eg triangle lists. Each submesh is assigned a material. This material can be defined as you need. It may include diffuse color, roughness and the texture.

So when rendering the mesh, you would basically iterate every submesh, send the material parameters to the graphics card and then draw it.

Another possible solution in DirectX 10 would be to extend the vertex declaration by a TextureIndex variable. Or you could use 3d texture coordinates. This way, you can send all textures as a texture array to the graphics card and draw the mesh with one draw call. However, texture arrays are not suppported in DirectX 9. So you can either stick to method 1 or try to emulate a texture array.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM