I 'm going to write the lighting for game. I have read many code, and finally conclude two way to draw light models.
1)
foreach(model in models)
{
model.draw(model.material, model.HitLights); // the hit lights are pick up by collision test.
// if no hit lights, it will be drawed with ambient.
}
To implement this method , it seems to precompile many technique, material + 1 light, material + 2 lights ....
2)
the so called forward lighting ????
drawall(models, ambient light);
foreach(light in lightlist)
{
find hit models;
bindpass(lightingpass);
foreach(model in hits)
draw(model, light);
}
this method look more simple, because I only need to write one shader file.
If not considering efficiency, the second one may look better. For the moment, I don't want to use deferred lighting technique.
How do you do forward lighting ?
In the second method, how to real time combine other shader into the main lighting shader ?
For instance, the main lighting shader code in the file lighting.shader. And a shader file aa.shader which has a function computeColor().
How to real time combine the code from aa.shader into the lightin.shader.
so the main() in lighting.shader can call the computeColor() ?
hehe, i'm now using dx11