I just wanted to share my month work on GLSL shaders (I use them for my hobbyst project) for all the 3 lighting source types to help those beginning with shaders.
GLSL shader sources:
http://realitystream...pl/Phong.tar.gz
btw: I licensed it LGPL, so I can receive patches or enhancements, but I never saw any shaders to be licensed LGPL (didn't search much though). Hope LGPL is permissive enough and ok for shaders.
btw2: Shaders can be much more optimized by moving calculations (like length from light) to vertex shaders. This will however cause error with low poly (low tesselated) meshes. Lets say you have plane, very large plane with 4 vertices. There is a light in the middle of the plane. At each vertex shader computes the length, but the length is too large, because the light is too far from the vertex. You got 4 very high values, try to interpolate them :lol: You will get another high distance which might not be true (for the center of the plane). Because of this I moved length calculation to fragment shader.
How to use these shaders in your project:
I assume you have some GLSL environment ready (see lighthouse glsl tutorials for some GLSL set up code or use any open source engine capable of GLSL).
Set up the material in this way:
1) render ambient pass using AmbientOneTextureVS/FS shaders
2) render directional light (DirectionalLightVS/FS) with one one blending mode (additive pass) for each directional light
3) render point light (PointLightVS/FS) with one one blending mode (additive pass) for each spot light
4) render spot light (SpotLightVS/FS) with one one blending mode (additive pass) for each directional light
note: light passes should be rendered with diffuse texture bound!
EDIT: I uploaded some screenshots, so you got the idea how it looks.
All lights combined (I know it's overbright :wink: )
http://realitystream...s/screenie0.jpg
Just directional light
http://realitystream...s/screenie1.jpg
Directional light + spotlight
http://realitystream...s/screenie2.jpg
Just point light
http://realitystream...s/screenie3.jpg
Just spot light
http://realitystream...s/screenie4.jpg
Multipass GLSL shaders for all 3 light types
Started by kulik, Mar 31 2006 04:12 PM
3 replies to this topic
#1
Posted 31 March 2006 - 04:12 PM
#2
Posted 31 March 2006 - 07:32 PM
Nice work.
reedbeta.com - developer blog, OpenGL demos, and other projects
#3
Posted 02 April 2006 - 04:38 AM
Cool, I'll bookmark these and take a look at them later. I'm writing an xml based material system for my engine that can link with GLSL files and I could use some traditional shaders to start with and work my way from there. These will definitely be faster than typing them all in by hand from the orange book.
#4
Posted 06 April 2006 - 04:08 PM
I also thought about some kind of Unified shading and lighting to implement. Got no useful ideas yet though ...
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












