Tuesday, 9 March 2010

Rendering a face

In my previous message I described the pipeline for rendering a frame. Today I will talk about the common material shader I use for pretty much all objects in the new demo.
  • I use Lambert shading, almost all faces are flat (hard edges in Wings3D). However, object are well tessellated.
  • There is an ambient component, a very slight diffuse (the difference in intensity between the face looking towards the light and away is less than 20%) and in most cases no specular.
  • UV coordinates for texturing are calculated on the fly, based on direction of normal (vertex shader). I never store UVs in a file (although I could, using wings3D's auto-UVing, but it would be a waste of time: I get a very good result with my own auto UV-ing anyway). Needless to say, all textures are tileable. I do a couple of passes adding different octaves of textures to reduce any sense of repetition.
  • Shadow mapping is performed as usual with projected texture look-ups. Sometimes I do more than one passes with slightly different projection matrix to smooth-out the artifacts on the edges of shadows.
  • On top of everything I project and multiply a "Gaussian blob" texture in the direction of the camera. This adds a slight spotlight effect and improves realism quite a bit. An extra step here is to alter the projection matrix by a factor determined by the texture underneath. This way I can emulate pretty well a very soft "bump/gritty" effect. You can see this effect in the bathroom scene in Lifeforce.
  • Then there is an element of fog - furthest objects appear darker. Pretty easy that.
That list covers, more or less, the vast majority of material shaders that I use.

1 comment:

  1. Hello, it really sounds interesting don't to save uv coordinates and to calculate on the fly them. Could you explain a bit more (the algorithm) as is made this? . Thx very much