PDA

View Full Version : shading a scene when using shaders



milankoko
12-27-2008, 06:27 AM
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?

Ilian Dinev
12-27-2008, 09:53 AM
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)

http://www.lighthouse3d.com/opengl/glsl/index.php?lights

ZbuffeR
12-27-2008, 02:13 PM
If you want to mimic exactly fixed function, try ShaderGen here :
http://3dshaders.com/home/index.php?option=com_weblinks&catid=14&Itemid=34

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

milankoko
12-28-2008, 03:39 AM
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.