Skip to main content
GameDev.net gamedev.net
🔒 Locked

Skip a pass of a technique.

Started by Black Knight Sep 21, 2009 at 7:27 PM 2 replies 700+ views
Original Post
Black Knight
Black Knight
Hey, Is it possible to skip the second pass of a technique based on a bool flag? Here is a small example :

..
bool someFlag; // setable from app code
..
..
technique fooTech
{
 pass P0
 {
    VertexShader = compile vs_2_0 myVertexShader();
    PixelShader  = compile ps_2_0 myPixelShader();
 }
 if(someFlag == true)
{
 pass P1
 {
    VertexShader = compile vs_2_0 mySecondVertexShader();
    PixelShader  = compile ps_2_0 mySecondPixelShader();
 }
}
}

I know this won't work but it displays what I'm trying to do.I could check the flag inside mySecondVertexShader and mySecondPixelShader and do nothing in the vertex shader and just use discard; in mySecondPixelShader but I want to know if there is a better alternative.
Namethatnobodyelsetook
Namethatnobodyelsetook
You could encode the conditions in the name of the pass, or as a series of annotations. When you load the FX file, get each pass description, and set some flags/struct to indicate what conditions the shader depends on. When it comes time to begin the pass, check the flags vs. whatever they represent to determine if you should skip the pass or not.
Black Knight
Black Knight
Well the engine im using is scripted so I don't really want to modify the c++ code and how it works and sets the passes.It lets me expose variables from effect files to the scipting language so for example I can set the bool flag from the scripts.

Is there a way to discard a vertex at the vertex shader?I mean is there an equivalent to discard in vertex shaders?
mast10
mast10
You could maybe make a different technique with that pass in it and then render it if your bool is true

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.