You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`directionToColor( value )`| Converts direction vector to color. |`color`|
1135
1137
|`colorToDirection( value )`| Converts color to direction vector. |`vec3`|
1136
1138
1137
-
## Post-Processing
1139
+
## Render Pipeline
1140
+
1141
+
The `RenderPipeline` provides full control over the rendering process. It enables developers to build complex multi-pass rendering pipelines entirely in JavaScript, combining scene rendering, post-processing, and compute operations in a unified, composable workflow.
MRT allows capturing multiple outputs from a single render pass. Instead of rendering the scene multiple times to get different data (color, normals, depth, velocity), MRT captures all of them in one draw call—significantly improving performance.
1169
+
1170
+
#### Setting up MRT
1171
+
1172
+
Use `setMRT()` with the `mrt()` function to define which outputs to capture:
normal:directionToColor( normalView ), // View-space normals encoded as colors
1182
+
velocity: velocity // Motion vectors for temporal effects
1183
+
} ) );
1184
+
```
1185
+
1186
+
Each MRT entry accepts any TSL node, allowing you to customize outputs using formulas, encoders, or material accessors. For example, `directionToColor( normalView )` encodes view-space normals into RGB values. You can use any TSL function to transform, combine, or encode data before writing to the render target.
1187
+
1188
+
Within a TSL function `Fn( ( { material, object } ) => { ... } )`, you have complete access to the current material and object being rendered, enabling full customization of outputs.
1189
+
1190
+
#### Accessing MRT Buffers
1191
+
1192
+
Each MRT output becomes available as a texture node via `getTextureNode()`:
These texture nodes can be sampled, transformed, and passed to post-processing effects or other passes.
1205
+
1206
+
#### Optimizing MRT Textures
1207
+
1208
+
You can access the textures to optimize memory usage and bandwidth. Using smaller data types reduces GPU memory transfers, which is critical for performance on bandwidth-limited devices:
1209
+
1210
+
```js
1211
+
// Use 8-bit format for encoded normals, default is 16-bit
0 commit comments