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.
Here is a vimeo of the ambient cube lookup in action:
ambient cube realtime CG shader from benp on Vimeo.
The ambient occlusion map was baked in xsi, through mentalray.
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
Do you think you could make a reflected ray and look up a reflection map?
As for the reflection occlusion that could be a little bit harder, but I guess you could use bent normals to get any displacement detail.
Also if the robot was fighting a ninja it would be much more dramatic
for sure! I’d actualy use the same half-angle i create in the vertex shader to calculate a specular term.
I’m still yet to really think about my reflection term. Certainly it will be HDR and masked by something in the cracks, probably just a map. What’s a robot without reflections?
.. well, that’s just obvious. :)
mind sharing a bit more about the python-ogre work you did?
did you use an existing ‘model viewer’ in that package? or did you make your own using the modules that come with python-ogre?
thanks for sharing
steven
Sure! (I’ll probably make a dedicated post about my current ogre viewer stuff one day)
I started by butchering the demos that come with python-ogre.
I basically have my own framework now for model viewing, using python-ogre. The hardest part for me was working out how to ween myself off the SampleFramework that all the python-ogre demos use. Now i kind of know what is the least amount of steps necessary, using the api calls, to setup an ogre scene for viewing.
This python-ogre wiki article is great for explaining how to create ogre stuff without the SampleFramework.
Before I actually started getting right into this python-ogre stuff, I was getting prepared to write my own model exporter for XSI until i found this Open Source project (xsi plugin under 1.4.6 release)!
It’s a lot of fun :D
I’ll try to make a few of my python-ogre modules available in the future ..
Thx for the comment!
great, these will get me started!
thanks for your time, please keep posting about python, ice, xsi, and everything else cg.