Hi everyone. I’ve ported my rendering engine from a fixed function pipeline to the Core (OpenGL 3.2>) profile. My engine now has 2 code paths - legacy and modern. The performance increase is nice (from 570fps (legacy) to 730fps (modern) on my test scene), and the codepaths are nicely abstracted away from the client code. Yay!!!
However, I’ve noticed a striking difference in lighting quality. I’ve used the fixed function lighting equations in the past, and have never been impressed by them. I’ve had fireballs lighting a hallway and such, and the quality was ‘meh’. You can see the lighting effects in action, but they were nothing spectacular. I figured that was normal and never gave it a second thought.
After transitioning the code path to use shader based lighting, I am genuinely suprised at how much better lighting appears in my test scene. Even the most simple shading technique (Lambert colour = max(L.n, 0)*diffuse) gives a greatly superior contrast between surfaces facing the light and surfaces facing away from the light. Eg. my test scene has a cylinder in the world, and as the light rotates around the scene, you can clearly tell where the light position is based on cylinder shading. With the fixed function pipeline, I have a general idea of light position, but you couldn’t tell if the light was behind and to slightly to the left, or behind and slightly to the right (obviously, for other light positions you could roughly estimate the position). For shader based lighting, the cylinder clearly shows which triangles are not facing the light. The contrast between shader based lighting and fixed function lighting is striking.
Typically, when I encounter weird behavior like this, my first instinct is to question my methods. I am obviously missing a configuration parameter in the fixed function pipeline which is causing my lights to not appear as “vivid” as when doing the math myself. I’ve gone through the RedBook with a comb, looked at tutorials on the net, and cannot see anything which I might have missed. My shader based lighting codepath is using the Redbook lighting equations, so I should be doing the exact same thing as fixed function. I’m using the same data sets. I must stress that lighting with fixed function pipeline works, you can clearly see the triangle shading as the light moves around the scene. However, with shader based lighting (also per vertex), the contrast between shaded and unshaded areas is really vivid.
Both codepaths use the same light/material properties. For the FF codepath, I also need to toggle the following (which are different from the default settings).
Has anyone encountered anything similar with fixed function lighting? Is there something I might have missed? Again, I must stress that lighting works with FF codepath, it just isn’t as vivid.