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

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 on other sites
Quote:
 Original post by resle1) 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 resleIs 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 resle3) 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 on other sites

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.

1. 1
Rutin
23
2. 2
3. 3
4. 4
JoeJ
18
5. 5

• 14
• 15
• 11
• 11
• 9
• Forum Statistics

• Total Topics
631757
• Total Posts
3002146
×