I'm not exactly sure what you're up to.

The easiest way to use dynamic lights is tu just place dynamic lights in your lite-c script via the entities' lightrange and red green and blue parameters. You can then use vecLightPos and vecLightColor in your shader. Thats even the way the shaders of Gamestudio work.

In order to have a lightsource per material you can set the material's skills and then access these in the shader via the vecSkill1 .. vecSkill17 variables. It would work out very similarly for a per entity solution.

Given your code above you just had to replace vecSunDir with the variable you wanted to use instead. Don't forget to declare them in shader as well. Sorry if that is too obvious to you, I don't know you shader skill level... ;-)


Always learn from history, to be sure you make the same mistakes again...