2
\$\begingroup\$

I'm going through HLSL tutorials and I have lighting and texturing setup. Right now in my shader I take a texture, but if I leave that variable blank it gives me an error. Half of my models have textures and the other half don't, is there a way to "skip" the texturing part for the models that don't have them and set it for the models that do without having to make a completely seperate shader that only deals with lighting?

Also, whilst I'm asking this, is saturate and normalize the same thing?

Thanks

\$\endgroup\$
1

2 Answers 2

2
\$\begingroup\$

You will have to use two separate shaders to achieve this. Probably the best way to go about this is to add preprocessor directives to remove your texture code when a certain symbol is defined i.e.:

#if USE_TEXTURES
//texturing sctuff here
#endif

This makes it easier to maintain changes that would affect both shaders.

\$\endgroup\$
1
\$\begingroup\$

There is no way to "skip" texturing, but if you don't want to make two separate shaders, you could simply create a 1x1 white texture and use that for all the untextured models.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .