Jump to content
  • Advertisement
Sign in to follow this  
YengaMatiC

OpenGL Lighting model

This topic is 4862 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In our render system (opengl) we can choose between use of vertex and pixel shaders or fixed-function pipeline. I've been playing with FFP to see what lighting model we can render. Here's what it does: -Diffuse (no bumpmapping): Unit0 : tiny normal map with only one normal (0,0,1) Unit1 : normalisation cubemap with tangent space light dir as texcoords We perform a dot3 operation so we get diffuse per-pixel. Then we modulate with albedo texture in unit 2 to get color. -Specular: Unit3: specular cubemap with Phong equation. Only for directional lights. Result is added to diffuse term. Then we interpolate with a reflection cubemap in unit 4 with a constant weighting factor to get more or less reflectivity. I think that diffuse dot3 with the normal as constant color (GL_CONSTANT), so we can save a texture unit for reflection cubemap (4 units total). The problem is specular cubemap. AFAIK it only works for directional lights, so is it possible to compute a specular cubemap for point lights (and spotlights)? I hope tomorrow i can upload some screenshots to show you the results. It looks cool ;)

Share this post


Link to post
Share on other sites
Advertisement
I got the demo working and there are some screenshots of it running.

Torus textured
Torus textured with reflections
Torus untextured
Torus untextured with reflections

You can download the demo from here (right click -> save as). I think the lighting is ok, but it would be grat to get some (constructive) criticism.

Finally the rendering is:
unit0 with normalised tangent space light vectors, we make a dot3 with GL_CONSTANT that contains normal vector (0,0,1)
unit1 with albedo texture (decal texture)
unit2 with environment map interpolated with previous result
unit3 with specular cube map added to previous result
And a second pass to add ambient lighting.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!