Improvements to VRS/Foveated rendering

This commit is contained in:
Bastiaan Olij 2024-03-26 12:57:26 +11:00
parent 34b5e8f55c
commit 9042ddf19f
38 changed files with 708 additions and 124 deletions

View file

@ -4036,6 +4036,15 @@
The texture to use when the VRS mode is set to [constant RenderingServer.VIEWPORT_VRS_TEXTURE]. Equivalent to [member ProjectSettings.rendering/vrs/texture].
</description>
</method>
<method name="viewport_set_vrs_update_mode">
<return type="void" />
<param index="0" name="viewport" type="RID" />
<param index="1" name="mode" type="int" enum="RenderingServer.ViewportVRSUpdateMode" />
<description>
Sets the update mode for Variable Rate Shading (VRS) for the viewport. VRS requires the input texture to be converted to the format usable by the VRS method supported by the hardware. The update mode defines how often this happens. If the GPU does not support VRS, or VRS is not enabled, this property is ignored.
If set to [constant RenderingServer.VIEWPORT_VRS_UPDATE_ONCE], the input texture is copied once and the mode is changed to [constant RenderingServer.VIEWPORT_VRS_UPDATE_DISABLED].
</description>
</method>
<method name="visibility_notifier_create">
<return type="RID" />
<description>
@ -4976,11 +4985,23 @@
Variable rate shading uses a texture. Note, for stereoscopic use a texture atlas with a texture for each view.
</constant>
<constant name="VIEWPORT_VRS_XR" value="2" enum="ViewportVRSMode">
Variable rate shading texture is supplied by the primary [XRInterface].
Variable rate shading texture is supplied by the primary [XRInterface]. Note that this may override the update mode.
</constant>
<constant name="VIEWPORT_VRS_MAX" value="3" enum="ViewportVRSMode">
Represents the size of the [enum ViewportVRSMode] enum.
</constant>
<constant name="VIEWPORT_VRS_UPDATE_DISABLED" value="0" enum="ViewportVRSUpdateMode">
The input texture for variable rate shading will not be processed.
</constant>
<constant name="VIEWPORT_VRS_UPDATE_ONCE" value="1" enum="ViewportVRSUpdateMode">
The input texture for variable rate shading will be processed once.
</constant>
<constant name="VIEWPORT_VRS_UPDATE_ALWAYS" value="2" enum="ViewportVRSUpdateMode">
The input texture for variable rate shading will be processed each frame.
</constant>
<constant name="VIEWPORT_VRS_UPDATE_MAX" value="3" enum="ViewportVRSUpdateMode">
Represents the size of the [enum ViewportVRSUpdateMode] enum.
</constant>
<constant name="SKY_MODE_AUTOMATIC" value="0" enum="SkyMode">
Automatically selects the appropriate process mode based on your sky shader. If your shader uses [code]TIME[/code] or [code]POSITION[/code], this will use [constant SKY_MODE_REALTIME]. If your shader uses any of the [code]LIGHT_*[/code] variables or any custom uniforms, this uses [constant SKY_MODE_INCREMENTAL]. Otherwise, this defaults to [constant SKY_MODE_QUALITY].
</constant>

View file

@ -407,6 +407,9 @@
- 8×8 = rgb(255, 255, 0) - #ffff00 - Not supported on most hardware
[/codeblock]
</member>
<member name="vrs_update_mode" type="int" setter="set_vrs_update_mode" getter="get_vrs_update_mode" enum="Viewport.VRSUpdateMode" default="1">
Sets the update mode for Variable Rate Shading (VRS) for the viewport. VRS requires the input texture to be converted to the format usable by the VRS method supported by the hardware. The update mode defines how often this happens. If the GPU does not support VRS, or VRS is not enabled, this property is ignored.
</member>
<member name="world_2d" type="World2D" setter="set_world_2d" getter="get_world_2d">
The custom [World2D] which can be used as 2D environment source.
</member>
@ -664,5 +667,17 @@
<constant name="VRS_MAX" value="3" enum="VRSMode">
Represents the size of the [enum VRSMode] enum.
</constant>
<constant name="VRS_UPDATE_DISABLED" value="0" enum="VRSUpdateMode">
The input texture for variable rate shading will not be processed.
</constant>
<constant name="VRS_UPDATE_ONCE" value="1" enum="VRSUpdateMode">
The input texture for variable rate shading will be processed once.
</constant>
<constant name="VRS_UPDATE_ALWAYS" value="2" enum="VRSUpdateMode">
The input texture for variable rate shading will be processed each frame.
</constant>
<constant name="VRS_UPDATE_MAX" value="3" enum="VRSUpdateMode">
Represents the size of the [enum VRSUpdateMode] enum.
</constant>
</constants>
</class>

30
doc/classes/XRVRS.xml Normal file
View file

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="XRVRS" inherits="Object" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
Helper class for XR interfaces that generates VRS images.
</brief_description>
<description>
This class is used by various XR interfaces to generate VRS textures that can be used to speed up rendering.
</description>
<tutorials>
</tutorials>
<methods>
<method name="make_vrs_texture">
<return type="RID" />
<param index="0" name="target_size" type="Vector2" />
<param index="1" name="eye_foci" type="PackedVector2Array" />
<description>
Generates the VRS texture based on a render [param target_size] adjusted by our VRS tile size. For each eyes focal point passed in [param eye_foci] a layer is created. Focal point should be in NDC.
The result will be cached, requesting a VRS texture with unchanged parameters and settings will return the cached RID.
</description>
</method>
</methods>
<members>
<member name="vrs_min_radius" type="float" setter="set_vrs_min_radius" getter="get_vrs_min_radius" default="20.0">
The minimum radius around the focal point where full quality is guaranteed if VRS is used as a percentage of screen size.
</member>
<member name="vrs_strength" type="float" setter="set_vrs_strength" getter="get_vrs_strength" default="1.0">
The strength used to calculate the VRS density map. The greater this value, the more noticeable VRS is.
</member>
</members>
</class>