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

shaders

Started by giugio Mar 26, 2009 at 10:22 AM 0 replies 600+ views
Original Post
giugio
giugio
How work shaders in directx? can i apply more than one shader to a mesh for example? one for the normal mapping and one for the skin animation? How? A shader has affect only to one mesh or to all the meshes in the shene? Thanks.
MJP
MJP
You can only have 1 vertex shader and 1 pixel shader active at the same time. You can't have the runtime "combine" shaders for you, because the runtime would have no idea how to combine two abstract concepts like "skinning" and "normal mapping". You'll need to create a matched set of a vertex and pixel shader that accomplishes what you want...which means either combining the code manually or creating/using some sort of tool that assembles full shaders from HLSL fragments.

When you set a shader for the device, it remains active for any DrawPrimitive/DrawIndexedPrimitive callsyou make until you set a new shader. So you can set a shader, draw some geometry, switch the shader, and then draw some more. Typically you'll want to minimize shader switching as much as possible, as it adds CPU overhead.

Topic Locked

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

Sign in to reply to this topic.