context
Encapsulates a reusable shader algorithm (like triplanar mapping) and applies it to other nodes, separating "what to do" from "how to do it".
Core Advantages
Greatly simplifies the main material's logic by encapsulating complex algorithms (like texture projection) into reusable modules, enhancing code readability, composability, and maintainability.
Common Uses
Implementing triplanar texture mapping
Creating Matcap or screen-space UV effects
Encapsulating custom color correction or procedural filters
Building reusable high-level functions
How to adjust
By passing a dynamically changing node (e.g., a scrolling texture using `timerLocal`) as input to the context, advanced dynamic effects can be achieved. For instance, feeding a scrolling texture into a `triplanarTexture` context will make the texture flow seamlessly and synchronously across all faces of the model.
Code Examples
1// Create a triplanar mapping context and get the final color directly
2const finalColor = context( triplanarTexture( rockTexture, normalWorld, 10.0 ) );