Pixel Shader/ Vertex Shader or ID3DXEffect?

Started by
4 comments, last by ProgrammerDX 12 years ago
Hi,

I noticed there are 2 ways to make use of shaders in DirectX?

What's the difference between using SetPixelShader/SetVertexShader and ID3DXEffect::Begin()?

Thanks
Advertisement
Using the Effect interface allows you to keep your rendering code a lot more tidy, and store everything related to each other in one effect file. Using effects also allows for an interface to set/get any variables related to your shader code(constants). There is more work to using shaders if you don't use effect files. This being said, I have only ever used effect files, and never manually made my own shader handling system(needed when using the SetPixel/Vertex shader functions).
Effects can make things easier for you, due to the reason Slig already mentioned. If you do decide to use them, I would just recommend that you make sure that you understand what the effects framework is actually doing for you under the hood with regards to setting shaders, setting shader constants, setting render states, setting textures, etc. One helpful tool you can use is PIX, which will show you all of the raw D3D calls being made whenever you make a call on an ID3DXEffect.
Since no one's mentioned it, effects are a wrapper for shaders. So under the hood Set*Shader is still being used.
And I should also mention (although it isn't fully related to the question) that effects aren't necessarily tied to shaders, you can use them also with the fixed function pipeline, you can define a Technique which sets render states, transformation matrices etc. and no shaders.
Thanks all smile.png

This topic is closed to new replies.

Advertisement