technique RenderLightingPass
{
pass p0
{
VertexShader = compile vs_1_1 LightingPassVS();
#IF shaderver >= 2
PixelShader = compile ps_2_0 LightingPassPS_SM2();
#ELSEIF shaderver = 1
PixelShader = compile ps_1_1 LightingPassPS_SM1();
#ENDIF
}
}
[Resolved]A few questions about selecting codepaths in HLSL
Hey everyone, I've got a few questions. In my engine, I'm going to use a different shader for every shader level. What I mean is,
Shader 1 has a SM 1 and 2 codepath
Shader 2 has a SM 1, 2 and 3 codepath
In my application, I want to define the highest shader codepath it will compile. Example, SM2
Shader 1 will compile the SM2 codepath
Shader 2 will compile the SM3 codepath
How would I go about doing that? I was thinking
But I don't know how to pass in shaderver. Anyone?
[Edited by - CadeF on March 13, 2006 12:55:16 AM]
In the case you use the effect framework you should use different techniques for this.
You can now select the technique you want to use with “SetTechnique”. You will need some additional code that maps from the caps to the right Technique. The easiest way is to use always the same technique names. But with some additional code you can make it much more flexible and configurable.
technique ShaderModel1{ pass p0 { VertexShader = compile vs_1_1 LightingPassVS(); PixelShader = compile ps_1_1 LightingPassPS_SM1(); }}technique ShaderModel2{ pass p0 { VertexShader = compile vs_1_1 LightingPassVS(); PixelShader = compile ps_2_0 LightingPassPS_SM2(); }}
You can now select the technique you want to use with “SetTechnique”. You will need some additional code that maps from the caps to the right Technique. The easiest way is to use always the same technique names. But with some additional code you can make it much more flexible and configurable.
Quote:Original post by CadeF
Thanks, but I'm looking for other methods, in which no higher version is compiled.
I have found the easiest way to do this is to simply place the higher-profile techniques above the lower-profile techniques. This way, no compile errors are generated, but they aren't validated either. Then your application can simply use the first validated technique.
If you *really* want to avoid compiling them at all, you could just #define different identifiers from within the application (remember the effect compiler allows you to add in different defines at runtime). For example, #define SM_3_0 and whatnot.
In Direct3D.Effect.FromFile, where do I pass in "#define ShaderModel == 2;"?
Or, if not Effect.FromFile, which function?
[Edited by - CadeF on March 12, 2006 5:36:12 PM]
Or, if not Effect.FromFile, which function?
[Edited by - CadeF on March 12, 2006 5:36:12 PM]
Quote:Original post by CadeF
In Direct3D.Effect.FromFile, where do I pass in "#define ShaderModel == 2;"?
Or, if not Effect.FromFile, which function?
Well, I have only use the unmanaged version (D3DXCreateEffectFromFile()). There, you just specify a null-terminated array of defines for the pDefines structure.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement