transformed
(vec3)Vertex position in model space with skinning applied.
// begin_vertex.glsl.js
vec3 transformed = vec3( position );
It's adjusted in skinning_vertex.glsl.js
if USE_SKINNING
is defined, but in most cases this is synonymous with vertex position.
mvPosition
(vec4)Vertex position in camera space. Remember that +Z points out from the screen, so all the stuff in the camera's view will have a negative Z value for this vector.
This can also be interpreted as a vector pointing from the camera to the vertex in camera space
// project_vertex.glsl.js
vec4 mvPosition = vec4( transformed, 1.0 );
mvPosition = modelViewMatrix * mvPosition;
vViewPosition
(vec3)Negated XYZ components of mvPosition
. You should interpret this as the camera position in "vertex space" (I don't know if that's a real term — I mean the camera position relative to an origin at the vertex).
This can also be interpreted as a vector pointing from the vertex to the camera in camera space.
// meshphysical_vert.glsl.js
vViewPosition = - mvPosition.xyz;
Here's a shitty sketch attempting to summarize these variables in two dimensions:
viewDir
(vec3)Normalized version of vViewPosition
. This is a unit vector pointing from the vertex to the camera in camera space.
// meshmatcap_frag.glsl.js
vec3 viewDir = normalize( vViewPosition );