czm_viewportTransformation
An automatic GLSL uniform representing a 4x4 transformation matrix that
transforms normalized device coordinates to window coordinates. The context's
full viewport is used, and the depth range is assumed to be near = 0
and far = 1
.
This transform is useful when there is a need to manipulate window coordinates
in a vertex shader as done by BillboardCollection. In many cases,
this matrix will not be used directly; instead, czm_modelToWindowCoordinates
will be used to transform directly from model to window coordinates.
Do not confuse czm_viewportTransformation
with czm_viewportOrthographic.
The former transforms from normalized device coordinates to window coordinates; the later transforms
from window coordinates to clip coordinates, and is often used to assign to gl_Position
.
Example
// GLSL declaration uniform mat4 czm_viewportTransformation; // Use czm_viewportTransformation as part of the // transform from model to window coordinates. vec4 q = czm_modelViewProjection * positionMC; // model to clip coordinates q.xyz /= q.w; // clip to normalized device coordinates (ndc) q.xyz = (czm_viewportTransformation * vec4(q.xyz, 1.0)).xyz; // ndc to window coordinates
- uniformState#viewportTransformation
- czm_viewport
- czm_viewportOrthographic
- czm_modelToWindowCoordinates
- BillboardCollection