Optimization by sharing

Quite often you can amortize the cost of two pieces of code in different parts of the engine by merging them together, reusing the results from one part in another part. For example, say you have:

  • a character controller (CCT) moving your characters in the world
  • old style projected shadows below your characters
  • a portal engine using a downward raycast per character to find in what region they are
  • a sound module using a downward raycast per character to find what footstep sound to play

It’s rather obvious but you can easily optimize away the 3 last parts. The CCT module already knows what triangles each character is touching. If you set it up correctly, those triangles can be the same as the ones you want to render your projected shadows on. And the same triangles already tell you in what region you are, what material you’re touching, and what sound is associated with them.

It may sound obvious but it’s not always done…

Comments are closed.

shopfr.org cialis