Foveated rendering shader functions reference
Explore the HLSL functions you can use to remap screen-space coordinates in custom shaders that must work under foveated rendering.
Read time 2 minutesLast updated 23 days ago
The file on GitHub defines a set of functions that you can use to support foveated rendering in your custom shaders. These functions return the correct results whether the current raster space is linear or non-uniform, and when foveated rendering isn't active. The functions also handle inverting the y-axis according to whether the platform places the screen-space origin at the top or bottom of the screen.
FoveatedRendering.hlslTo add these functions to a shader, refer to Adapt custom shaders for foveated rendering.
UV coordinate remapping functions
Use these functions to convert UV coordinates between the linear and non-uniform raster spaces:
Declaration | Description |
|---|---|
| Converts linear screen-space UV coordinates to non-uniform screen-space UV coordinates, including any necessary y-axis inversion. If foveated rendering isn't active or the platform doesn't use non-uniform rasterization, the function returns the UV coordinates unchanged. |
| Converts non-uniform screen-space UV coordinates to linear screen-space UV coordinates, including any necessary y-axis inversion. If foveated rendering isn't active or the platform doesn't use non-uniform rasterization, the function returns the UV coordinates unchanged. |
| Remaps linear screen-space UV coordinates based on the previously rendered frame. Not implemented on Metal. |
| Remaps non-uniform screen-space UV coordinates based on the previously rendered frame. Not implemented on Metal. |
Density functions
Use the following functions to find the ratio between the screen resolution and the raster resolution, for example when you update a screen-space effect:
Declaration | Description |
|---|---|
| Returns the ratio between the screen resolution and the raster resolution at the specified screen UV coordinate. If foveated rendering isn't active or the platform doesn't use non-uniform rasterization, the function returns |
| Returns the density ratio for the previous frame. Not implemented on Metal. |
Screen coordinate remapping functions
Use the following functions to convert clip-space screen coordinates rather than UV coordinates:
Declaration | Description |
|---|---|
| Converts linear-space screen coordinates to non-uniform-space screen coordinates. If foveated rendering isn't active or the platform doesn't use non-uniform rasterization, the function returns the coordinates unchanged. |
| Converts non-uniform-space screen coordinates to linear-space screen coordinates. If foveated rendering isn't active or the platform doesn't use non-uniform rasterization, the function returns the coordinates unchanged. |