Skip to content

Instantly share code, notes, and snippets.

@aras-p
Created June 6, 2011 17:30
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save aras-p/1010683 to your computer and use it in GitHub Desktop.
Save aras-p/1010683 to your computer and use it in GitHub Desktop.
UNITY_MATRIX_MVP et al equivalents in script
// world, view, projection matrices
var world = obj.transform.localToWorldMatrix;
var view = cam.worldToCameraMatrix;
var proj = cam.projectionMatrix;
// the actual projection matrix used in shaders
// is actually massaged a bit to work across all platforms
// (different Z value ranges etc.)
var gpuProj = GL.GetGPUProjectionMatrix (proj, false);
var gpuMV = view * world; // UNITY_MATRIX_MV
var gpuMVP = gpuProj * view * world; // UNITY_MATRIX_MVP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment