I added a more complex ambient term to my base CG realtime shader.
Classically, a basic shading model will contain a diffuse and ambient term, and usually a specular term. After implementing a soft texture-mapped shadow-catching function in my CG shader, i really missed having some dynamic modeling of light going on in the ambient end of the shader.
I use a classic technique of offline 3d rendering to add interest to my ambient term - sampling an ambient environment map.
Using the shading normal, I cast an environment lookup into a cube map, mapped with a simple sky-blue-to-earth-orange gradient.
The shader finally multiplies the ambient term by a baked ambient occlusion map.
In the fragment shader, the lookup is done like this:
float3 ambCube = texCUBE(ambientCubeMap, IN.nm ).xyz;
where IN.nm is the (object space) normal passed in from the vertex shader output struct.
The model was made in xsi.
The realtime display uses python-ogre to import the model, apply the CG shader, and take mouse input for interaction.
The video was captured with fraps.Tags: ogre3d, python-ogre, realtime, robot, shader, xsi