shading a scene when using shaders

I have created a simple point-based drawing engine that uses shaders(in Cg language) to draw a scene. Now I do not know how to light the scene. Defining lights and properties that worked in fixed pipeline obviously does not work here. I am interested in two things:

  • is it possible to automatically light a pixel/scene like it was using only fixed pipeline rendering? If, how can I do this?
  • if I have to perform all the calculations manually, can you tell m how do I do that or point me in the right direction? I was thinking I would have to pass all lights and properties as static values and use them to calculate proper color in fragment shader. What equations do I need for that?

with shaders, you do all calculations yourself. But there are snippets around the net, which you can use. (I can barely find them, though) (maybe FX Composer has implementations, too)

If you want to mimic exactly fixed function, try ShaderGen here :

Not that I recommend ‘fixed shading’ for the long term, but it can serve as bootstrap.

I will look into it, thanks. All I really need is one light and imitation of fixed pipeline shading would be exactly what I want.