Sign in to follow this  

Shader implementation

This topic is 3460 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have started to study shaders and found out that there are more than one implementation approach. - individual shader (using D3DXCompileShader or something) - effect file What are the pro(s) and con(s) of each? Do they have performance differences? Is one preferable than the other? I have hanged around the individual shader (or is that what is supposed to be called) for now. I created wrapper classes for a specific shader (like a TextureColorModulationPS, it loads itself, I can set the color to modulate through it, I can set it as the current shader through it). Is this the right way? I'm still looking for a good way of modularizing shader files.

Share this post


Link to post
Share on other sites
Effects can be extremely convenient. A single effect file can actually wrap many pairs of vertex and pixel shaders using techniques and passes which can be very useful for certain shaders. For example, you may have a blur effect with 5 techniques, each technique using a different radius for the blur. Or you might have a lighting shader that can have 0, 1, 2, or 3 light sources and so you have a technique for each.

Effects are also nice because you can use them to set render and sampler states right in the .fx file. This means you don't have to set them in your application code, and you can very easily associate different rendering states (like alpha blending) with different material types.

One final advantage of effects is that if you add SAS annotations, you can use your effect in 3D modeling applications like 3dsmax or XSI ModTool.

Share this post


Link to post
Share on other sites

This topic is 3460 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this