Phong interpolation and ray trace shadows

To mimic smooth surfaces, most rendering software uses Phong interpolation of the vertex-normals to give the shaded impression. However, when ray tracing shadows, errors can occur on the boundaries, when the shadow area starts overlapping the shaded area. This is because raytracing happens on the geometry itself, and not on its faked appearance.

 

Literature on this issue was hard to find, apart from a (fun read!) article by Andrew Woo (Alias) It's really not a render bug, you see! (pdf) (cached version)

Woo defines it as the "Terminator problem" and suggests to either use finer subdivision or use an artificial offset for shadow rays, slightly moving a ray in the direction of its normal. This causes artifacts on small details, however.

The solution as added in Blender doesn't patch the shadow ray tracer, which is working exactly as it should, but it narrows the range of Phong interpolated shading with the exact amount to hide the problem completely.

 

The algorithm works in two stages. First it calculates per object the average dot product between vertex normals and face normals (i). This is converted to a threshold value (t):

 

t= cos(0.5*PI - acos(i))

 

The threshold (t) then is applied to the result of diffuse shaders with the following formula;

 

result *= (i-t)/(i-t*i)

 

Where i is the dot product of the (interpolated) surface normal with the lamp vector.

 

Interface

Since it affects the appearance slightly, I've decided to make it an option for now, "Bias", which can be found below the Material "Shadow" button.

 

The pictures show the results on a 16-segmented sphere, and on a subdivided one.

Terminator problem
Bias applied on shading

More blending options for textures

New blending modes for the material "Map To" panel and ramps have been added:

  • Divide: Divides by texture color/intensity
  • Screen: Is like Multiply, but works opposite (makes lighter)
  • Difference: The difference between texture color/intensity and material
  • Lighten: If texture is lighter it shows (per component)
  • Darken: if texture is darker it shows (per component)

Static particles (hair) on characters

Until now static particles were only possible on stills, or for rigid characters.

Now you can also use Lattice or Armature deformed Meshes as basis for static particles. It is recalculated for each frame while rendering.

Note: now only works on subsurf Mesh.

 

This movie shows the snowman in motion (1.3M, copyright @ndy)

Ipo for textures

You can now animate texture variables using Ipos. This is different from the existing mapping in materials as it allows for greater texture control.

 

The channels available are: NSize, NDepth, NType, Turb, Vnw1, Vnw2, Vnw3, Vnw4, MinkMExp, DistM, ColT, iScale, DistA, MgType, MgH, Lacu, Oct, MgOff, MgGan, NBase1, NBase2.

 

An example of what you can do with it: erosion2.avi