Skip to main content
GameDev.net gamedev.net
🔒 Locked

One 3d model - different shaders?

Started by MrSparkle Jun 28, 2006 at 2:50 AM 2 replies 450+ views
Original Post
MrSparkle
MrSparkle
Hi, I'm new to this game development topic and I'm looking for some assistance... My question is about DirectX models and shaders, and how it is possible to assign different shaders to the model's polygons. E.g., when I have a model of a building and I want to assign different shaders to the windows, doors and stone walls, do I have to split the model and create a single object for each window and door? Or is there an easier way? Thanks, Christian
ET3D
ET3D
You have to make different drawing calls for different shaders. You can still keep the data in the same vertex buffer, if you want. If you're using D3DX meshes, you might create parts with different materials and draw them as subsets. In some cases it could be good to use different objects. For example, if your doors or windows can open, then it makes sense to make them separate. (You can reuse objects, for example have one window object and draw it several times at different places.)
MrSparkle
MrSparkle
Hi,

I noticed that the Panda DirectX Exporter actually exports the MaterialIDs of the object's polygons. I wonder how I can access them in my GameEngine to render them with different shaders.
Can anyone help me with this problem?

Thanks,
Christian
DXnut
DXnut
If you have different materials, then your mesh should have different subsets defined for each. So,before you do each pMesh-DrawSubset(x) call, you can setup your effect or vertex/pixel shaders to what ever you want to use.
--------------------------Most of what I know came from Frank D. Luna's DirectX books

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.