Texel snapping 'sun follow' script

This script moves a sun lamp to follow an object, while snapping to a texel (pixel) sized grid, corresponding to the shadow buffer map, thus maintaining the edge of the shadows of static objects consistent, getting rid of any ‘shimmering’, mostly produced by vertex parenting.


The scrip will try to take 3 game properties:

  • objtoFollow (String): the object to follow; if this property is not present, it will follow the active camera.
  • shadowSize (Integer): the size of the shadow buffer map, Lamp settings > Shadow > Quality > Size; if it is not present, it will default to 512. It is necessary for proper snapping.
  • moveParent (Boolean): move the parent of the sun lamp, instead of the lamp itself. When the sun lamp is moved, the relative position from the followed object is kept, naturally; when the parent is moved no relative position is kept.

Sun-Follow-texelSnap.blend (137.2 KB)

1 Like

can you show the same without your correction ? Its that those weird artifacts on shadow borders ?

yes, it’s like… the aliasing of the shadows don’t moves/changes/shimmers while the sun moves. Amazing!

Here’s how it looks when using vertex parenting: