Sign in to follow this  

[DX10] Shaders

This topic is 3313 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

A couple clarifications concerning the usage of shaders. 1) Does using shaders with DX10 imply using the Shader Model 4.0 or is it still possible to use 3.0 / 2.0? 2) Suppose I want to have five "rendering states" in my engine: Untextured, Textured, UntexturedTransparent, TexturedTransparent, Wireframe. Each one of those means writing a slightly different pixel (vertex?) shader. Is it better to write a single "RENDER" fx with different tecniques, or loading/using the five shaders separately? (I've heard that switching shaders is time costing) 3) What's the real difference between using DX's effect structure and directly using shaders? Thanks, a.

Share this post


Link to post
Share on other sites
Quote:
Original post by resle
1) Does using shaders with DX10 imply using the Shader Model 4.0 or is it still
possible to use 3.0 / 2.0?
You have no access to anything other than 4.0 with D3D 10.0.

Quote:
Original post by resle
Is it better to write a single "RENDER" fx with different tecniques, or
loading/using the five shaders separately? (I've heard that switching shaders
is time costing)
Switching shaders is costly, but if you manage it correctly (grouping related draw calls for example) it's not such a huge problem. In your particular example it'll likely make no difference, if possibly slower as multiple individual shaders/FX files.

Quote:
Original post by resle
3) What's the real difference between using DX's effect structure and directly using shaders?
How much work you want to do to integrate shaders and their respective management. Under a few domain-specific cases and where you can put in a huge amount of optimization effort you might get better performance via raw shaders but ultimately you're asking whether you can write better/faster code than Microsoft...

Stick with FX files until your profiling shows them to be a bottleneck. The amount of dev work required should not be underestimated and the cost/benefit is unlikely to add up favourably.


hth
Jack

Share this post


Link to post
Share on other sites
Thanks for your comprehensive answer.

In the end, correct me if I am wrong, in a scenario with only a few rendering "states", I could just write a single RENDER.FX effect with one technique for each "state". Something like this:


technique10 Basic
{
SetVertexShader (CompileShader( vs_4_0, BasicVertex()));
SetPixelShader (CompileShader( ps_4_0, BasicPixel()));
SetGeometryShader(NULL);
}

technique10 Transparent
{
SetVertexShader (CompileShader( vs_4_0, BasicVertex()));
SetPixelShader (CompileShader( ps_4_0, TransparentPixel()));
SetGeometryShader(NULL);
}

technique10 TransparentWobbly
{
SetVertexShader (CompileShader( vs_4_0, WobblyVertex()));
SetPixelShader (CompileShader( ps_4_0, TransparentPixel()));
SetGeometryShader(NULL);
}

etc. etc. ...




Then of course I'd organize my rendering queue so that calls to DrawWhatever are grouped by technique. Is this a correct approach?

Thanks again,

a.

Share this post


Link to post
Share on other sites

This topic is 3313 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