• Advertisement
Sign in to follow this  

shader variables - unset?

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

Is there a way to tell inside the shader code if a constant was never "set" i.e my application never called ID3D10Effect::GetVariableByName Id3D10EffectVectorVariable::SetFloatVectorArray I'd like to include some lighting code in my shader, but want the option of using 'no lights' i.e the application never fills those variables. Then I could so a simple if(the lighting variables were set) { do lighting } else { just use an ambient light with intensity of 1.0 } I am trying to get around having to write multple shaders for every scenario somehow. I guess I could do a buffer of boolean 'lightUsed', one for each light if I had to, but would rather not if I can get around it.

Share this post


Link to post
Share on other sites
Advertisement
I see two reasonable options: one is to use uniform variables and compile several variations of your shader, and the other to use constants. The first should result in better performance, but the second is simpler to manage.

In either case you don't need to write multiple shader. At most you create several techniques using the same shader (with different options).

IMO regardless of the choice (uniforms vs. constants), a good way to go would be an integer variable with the number of lights, instead of a boolean. It's simpler to use that in a loop.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement