getScreenPosition
Maps a 3D point from view space to 2D screen coordinates (in a [0, 1] range), used for implementing screen-space effects or debugging coordinate transforms.
Core Advantages
Encapsulates the complex coordinate transformation (projection, perspective divide, range remapping) into a single function, greatly simplifying the implementation of screen-space effects, improving code readability, and avoiding common errors in manual calculations.
Common Uses
Screen-space effects (e.g., vignette, scanlines)
Debugging coordinate transforms (visualizing screen coordinates as color)
Non-photorealistic rendering (NPR) with fixed screen-space patterns
Interacting with post-processing effects (e.g., sampling a distortion map)
How to adjust
This node has no direct parameters. Its effect is adjusted by changing its implicit inputs (view position and projection matrix). For example, changing the camera's field of view (FOV) alters the projection matrix, which in turn affects the scale and intensity of screen-space effects like vignettes.
Code Examples
1// Visualize screen coordinates as color for debugging
2// The object's surface will show a fixed gradient from top-left to bottom-right
3material.colorNode = vec4( getScreenPosition(), 0.0, 1.0 );