Sign in to follow this  
brekehan

shader variables - unset?

Recommended Posts

brekehan    101
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
ET3D    810
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

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