mrdoob/three.js — pull request #5785 by bhouston (2014-12-19 16:16:33+00:00)
Title: creation common.glsl utilities shader chunk and adopt it (fixes one bug)

This adds common.glsl, a common file of GLSL shader utilities.

The idea is to add useful commonly used functions to this so that we do not have to replicate code unnecessary across all shaders. The hope is that more centralization of utility functions will simplify the shader code.

I actually found a bug while doing this. In apply the transformNormal() function to envmap_fragment.glsl, I noticed that the order of the vector and matrix were inverted:

https://github.com/mrdoob/three.js/blob/dev/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl#L10

All other matrix-vector multiplications are in the opposite order.

PS. This is part one of a couple PRs related to adding Physically-Based Rendering materials to Three.JS.