Allow changing the anisotropic filter level at run-time per Viewport

This commit is contained in:
Wagner 2024-11-30 00:50:45 -03:00
parent 893bbdfde8
commit 6995b6a03e
21 changed files with 173 additions and 7 deletions

View file

@ -3842,6 +3842,17 @@
If [code]true[/code], sets the viewport active, else sets it inactive.
</description>
</method>
<method name="viewport_set_anisotropic_filtering_level">
<return type="void" />
<param index="0" name="viewport" type="RID" />
<param index="1" name="anisotropic_filtering_level" type="int" enum="RenderingServer.ViewportAnisotropicFiltering" />
<description>
Sets the maximum number of samples to take when using anisotropic filtering on textures (as a power of two). A higher sample count will result in sharper textures at oblique angles, but is more expensive to compute. A value of [code]0[/code] forcibly disables anisotropic filtering, even on materials where it is enabled.
The anisotropic filtering level also affects decals and light projectors if they are configured to use anisotropic filtering. See [member ProjectSettings.rendering/textures/decals/filter] and [member ProjectSettings.rendering/textures/light_projectors/filter].
[b]Note:[/b] In 3D, for this setting to have an effect, set [member BaseMaterial3D.texture_filter] to [constant BaseMaterial3D.TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC] or [constant BaseMaterial3D.TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC] on materials.
[b]Note:[/b] In 2D, for this setting to have an effect, set [member CanvasItem.texture_filter] to [constant CanvasItem.TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC] or [constant CanvasItem.TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC] on the [CanvasItem] node displaying the texture (or in [CanvasTexture]). However, anisotropic filtering is rarely useful in 2D, so only enable it for textures in 2D if it makes a meaningful visual difference.
</description>
</method>
<method name="viewport_set_canvas_cull_mask">
<return type="void" />
<param index="0" name="viewport" type="RID" />
@ -4998,6 +5009,24 @@
<constant name="VIEWPORT_MSAA_MAX" value="4" enum="ViewportMSAA">
Represents the size of the [enum ViewportMSAA] enum.
</constant>
<constant name="VIEWPORT_ANISOTROPY_DISABLED" value="0" enum="ViewportAnisotropicFiltering">
Anisotropic filtering is disabled.
</constant>
<constant name="VIEWPORT_ANISOTROPY_2X" value="1" enum="ViewportAnisotropicFiltering">
Use 2× anisotropic filtering.
</constant>
<constant name="VIEWPORT_ANISOTROPY_4X" value="2" enum="ViewportAnisotropicFiltering">
Use 4× anisotropic filtering. This is the default value.
</constant>
<constant name="VIEWPORT_ANISOTROPY_8X" value="3" enum="ViewportAnisotropicFiltering">
Use 8× anisotropic filtering.
</constant>
<constant name="VIEWPORT_ANISOTROPY_16X" value="4" enum="ViewportAnisotropicFiltering">
Use 16× anisotropic filtering.
</constant>
<constant name="VIEWPORT_ANISOTROPY_MAX" value="5" enum="ViewportAnisotropicFiltering">
Represents the size of the [enum ViewportAnisotropicFiltering] enum.
</constant>
<constant name="VIEWPORT_SCREEN_SPACE_AA_DISABLED" value="0" enum="ViewportScreenSpaceAA">
Do not perform any antialiasing in the full screen post-process.
</constant>