Rakkar
September 29th, 2007, 18:02
If I want to export a shader with support for 3 lights I have to add 9 lights, 3 of each type. However, I don't want a shader that has to evaluate 9 lights, just 3 lights of whatever type they may be. How do I do this? It's possible coding by hand, and this seems like a very common operation.
ruediger
October 5th, 2007, 16:23
If I understood you right, you want to use the the interface mechanism that is provided when you export a shader using "Export for > Cg FX > Component Shaders with interfaces". This exports the selected shader with interfaces which you can connect dynamically.
You can export interface-versions of the light shaders by selecting them and exporting them the same way as a surface shader.
Along with the CG Runtime Library you can connect instances of your (different) light shaders to your surface shader which you can compile in a final step. The 'Cg Toolkit User's Manual' describes how to do this in your program. Along with the cg Toolkit there's also some example provided where you can take a look at the code and see how this works.