Docs for the VertexLights2DServer.

This commit is contained in:
Relintai 2024-03-27 08:58:40 +01:00
parent cd8f79865e
commit 7f5b9650d9

View File

@ -1,8 +1,15 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="VertexLights2DServer" inherits="Object" version="4.3"> <class name="VertexLights2DServer" inherits="Object" version="4.3">
<brief_description> <brief_description>
A server that provides a way to store static lights that can be used to bake lighting information into mesh vertex data, or [CanvasItem]'s color modulation.
</brief_description> </brief_description>
<description> <description>
A server that provides a way to store static lights that can be used to bake lighting information into mesh vertex data, or [CanvasItem]'s color modulation.
With this class extremely complex light information can be stored and used with no additional cost on the GPU side.
After adding lights, you can use [member sample_light] to sample lighting at a specified point in the map's space, then use the resulting [Color] to either further modifty the modulate property of [CanvasItem]s, or you can render meshes using this color in you custom _draw methods.
The drawback of this method is that it's more expensive change lights.
Note that you can use the normal 2D lighting system on top of this if you need dynamic lights (like [Light2D]). That system is better suited for that purpose.
Currently this class stores lights inside quadrants. Their optimal size should be a bit more than the radius of the biggest light you want to have.
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>
@ -10,82 +17,96 @@
<method name="flush_notifications"> <method name="flush_notifications">
<return type="void" /> <return type="void" />
<description> <description>
Flushes map changed notifications. This will get called automatically.
</description> </description>
</method> </method>
<method name="free"> <method name="free">
<return type="void" /> <return type="void" />
<argument index="0" name="rid" type="RID" /> <argument index="0" name="rid" type="RID" />
<description> <description>
Frees an allocated resource.
</description> </description>
</method> </method>
<method name="get_default_quadrant_size" qualifiers="const"> <method name="get_default_quadrant_size" qualifiers="const">
<return type="Vector2i" /> <return type="Vector2i" />
<description> <description>
Get the default internal quadrant size.
</description> </description>
</method> </method>
<method name="light_create"> <method name="light_create">
<return type="RID" /> <return type="RID" />
<description> <description>
Create a light.
</description> </description>
</method> </method>
<method name="light_get_attenuation"> <method name="light_get_attenuation">
<return type="float" /> <return type="float" />
<argument index="0" name="light" type="RID" /> <argument index="0" name="light" type="RID" />
<description> <description>
Get a light's attenuation property.
</description> </description>
</method> </method>
<method name="light_get_color"> <method name="light_get_color">
<return type="Color" /> <return type="Color" />
<argument index="0" name="light" type="RID" /> <argument index="0" name="light" type="RID" />
<description> <description>
Get a light's color property.
</description> </description>
</method> </method>
<method name="light_get_is_enabled"> <method name="light_get_is_enabled">
<return type="bool" /> <return type="bool" />
<argument index="0" name="light" type="RID" /> <argument index="0" name="light" type="RID" />
<description> <description>
Get a light's enabled property.
</description> </description>
</method> </method>
<method name="light_get_item_cull_mask"> <method name="light_get_item_cull_mask">
<return type="int" /> <return type="int" />
<argument index="0" name="light" type="RID" /> <argument index="0" name="light" type="RID" />
<description> <description>
Get a light's item cull mask property.
</description> </description>
</method> </method>
<method name="light_get_layer_range"> <method name="light_get_layer_range">
<return type="Vector2i" /> <return type="Vector2i" />
<argument index="0" name="light" type="RID" /> <argument index="0" name="light" type="RID" />
<description> <description>
Get a light's layer range property.
</description> </description>
</method> </method>
<method name="light_get_map"> <method name="light_get_map">
<return type="RID" /> <return type="RID" />
<argument index="0" name="light" type="RID" /> <argument index="0" name="light" type="RID" />
<description> <description>
Get a light's map.
</description> </description>
</method> </method>
<method name="light_get_mode"> <method name="light_get_mode">
<return type="int" enum="VertexLights2DServer.VertexLight2DMode" /> <return type="int" enum="VertexLights2DServer.VertexLight2DMode" />
<argument index="0" name="light" type="RID" /> <argument index="0" name="light" type="RID" />
<description> <description>
Get a light's mix mode.
</description> </description>
</method> </method>
<method name="light_get_position"> <method name="light_get_position">
<return type="Vector2" /> <return type="Vector2" />
<argument index="0" name="light" type="RID" /> <argument index="0" name="light" type="RID" />
<description> <description>
Get a light's position.
</description> </description>
</method> </method>
<method name="light_get_range"> <method name="light_get_range">
<return type="Vector2i" /> <return type="Vector2i" />
<argument index="0" name="light" type="RID" /> <argument index="0" name="light" type="RID" />
<description> <description>
Get a light's range.
</description> </description>
</method> </method>
<method name="light_get_z_range"> <method name="light_get_z_range">
<return type="Vector2i" /> <return type="Vector2i" />
<argument index="0" name="light" type="RID" /> <argument index="0" name="light" type="RID" />
<description> <description>
Get a light's z range property.
</description> </description>
</method> </method>
<method name="light_set_attenuation"> <method name="light_set_attenuation">
@ -93,6 +114,7 @@
<argument index="0" name="light" type="RID" /> <argument index="0" name="light" type="RID" />
<argument index="1" name="attenuation" type="float" /> <argument index="1" name="attenuation" type="float" />
<description> <description>
Set a light's attenuation property.
</description> </description>
</method> </method>
<method name="light_set_color"> <method name="light_set_color">
@ -100,6 +122,7 @@
<argument index="0" name="light" type="RID" /> <argument index="0" name="light" type="RID" />
<argument index="1" name="color" type="Color" /> <argument index="1" name="color" type="Color" />
<description> <description>
Set a light's color property.
</description> </description>
</method> </method>
<method name="light_set_enabled"> <method name="light_set_enabled">
@ -107,6 +130,7 @@
<argument index="0" name="light" type="RID" /> <argument index="0" name="light" type="RID" />
<argument index="1" name="enabled" type="bool" /> <argument index="1" name="enabled" type="bool" />
<description> <description>
Set a light's enabled property.
</description> </description>
</method> </method>
<method name="light_set_item_cull_mask"> <method name="light_set_item_cull_mask">
@ -114,6 +138,7 @@
<argument index="0" name="light" type="RID" /> <argument index="0" name="light" type="RID" />
<argument index="1" name="item_cull_mask" type="int" /> <argument index="1" name="item_cull_mask" type="int" />
<description> <description>
Set a light's item cull mask property.
</description> </description>
</method> </method>
<method name="light_set_layer_range"> <method name="light_set_layer_range">
@ -121,6 +146,7 @@
<argument index="0" name="light" type="RID" /> <argument index="0" name="light" type="RID" />
<argument index="1" name="layer_range" type="Vector2i" /> <argument index="1" name="layer_range" type="Vector2i" />
<description> <description>
Set a light's layer range property.
</description> </description>
</method> </method>
<method name="light_set_map"> <method name="light_set_map">
@ -128,6 +154,7 @@
<argument index="0" name="light" type="RID" /> <argument index="0" name="light" type="RID" />
<argument index="1" name="map" type="RID" /> <argument index="1" name="map" type="RID" />
<description> <description>
Set a light's map.
</description> </description>
</method> </method>
<method name="light_set_mode"> <method name="light_set_mode">
@ -135,6 +162,7 @@
<argument index="0" name="light" type="RID" /> <argument index="0" name="light" type="RID" />
<argument index="1" name="mode" type="int" enum="VertexLights2DServer.VertexLight2DMode" /> <argument index="1" name="mode" type="int" enum="VertexLights2DServer.VertexLight2DMode" />
<description> <description>
Set a light's mix mode.
</description> </description>
</method> </method>
<method name="light_set_position"> <method name="light_set_position">
@ -142,6 +170,7 @@
<argument index="0" name="light" type="RID" /> <argument index="0" name="light" type="RID" />
<argument index="1" name="position" type="Vector2" /> <argument index="1" name="position" type="Vector2" />
<description> <description>
Set a light's position.
</description> </description>
</method> </method>
<method name="light_set_range"> <method name="light_set_range">
@ -149,6 +178,7 @@
<argument index="0" name="light" type="RID" /> <argument index="0" name="light" type="RID" />
<argument index="1" name="range" type="Vector2i" /> <argument index="1" name="range" type="Vector2i" />
<description> <description>
Set a light's range.
</description> </description>
</method> </method>
<method name="light_set_z_range"> <method name="light_set_z_range">
@ -156,35 +186,41 @@
<argument index="0" name="light" type="RID" /> <argument index="0" name="light" type="RID" />
<argument index="1" name="z_range" type="Vector2i" /> <argument index="1" name="z_range" type="Vector2i" />
<description> <description>
Set a light's z range property.
</description> </description>
</method> </method>
<method name="map_clear"> <method name="map_clear">
<return type="void" /> <return type="void" />
<argument index="0" name="map" type="RID" /> <argument index="0" name="map" type="RID" />
<description> <description>
Clears a map of all lights.
</description> </description>
</method> </method>
<method name="map_create"> <method name="map_create">
<return type="RID" /> <return type="RID" />
<description> <description>
Creates a map.
</description> </description>
</method> </method>
<method name="map_get_base_color" qualifiers="const"> <method name="map_get_base_color" qualifiers="const">
<return type="Color" /> <return type="Color" />
<argument index="0" name="map" type="RID" /> <argument index="0" name="map" type="RID" />
<description> <description>
Returns the base color of a map.
</description> </description>
</method> </method>
<method name="map_get_lights" qualifiers="const"> <method name="map_get_lights" qualifiers="const">
<return type="Array" /> <return type="Array" />
<argument index="0" name="map" type="RID" /> <argument index="0" name="map" type="RID" />
<description> <description>
Returns all lights in a map.
</description> </description>
</method> </method>
<method name="map_get_quadrant_size" qualifiers="const"> <method name="map_get_quadrant_size" qualifiers="const">
<return type="Vector2i" /> <return type="Vector2i" />
<argument index="0" name="map" type="RID" /> <argument index="0" name="map" type="RID" />
<description> <description>
Returns a map's quadrant size.
</description> </description>
</method> </method>
<method name="map_set_base_color"> <method name="map_set_base_color">
@ -192,6 +228,7 @@
<argument index="0" name="map" type="RID" /> <argument index="0" name="map" type="RID" />
<argument index="1" name="base_color" type="Color" /> <argument index="1" name="base_color" type="Color" />
<description> <description>
Sets the base color of a map.
</description> </description>
</method> </method>
<method name="map_set_quadrant_size"> <method name="map_set_quadrant_size">
@ -199,6 +236,7 @@
<argument index="0" name="map" type="RID" /> <argument index="0" name="map" type="RID" />
<argument index="1" name="size" type="Vector2i" /> <argument index="1" name="size" type="Vector2i" />
<description> <description>
Sets a map's quadrant size.
</description> </description>
</method> </method>
<method name="sample_light"> <method name="sample_light">
@ -208,12 +246,14 @@
<argument index="2" name="item_cull_mask" type="int" default="1" /> <argument index="2" name="item_cull_mask" type="int" default="1" />
<argument index="3" name="layer" type="int" default="0" /> <argument index="3" name="layer" type="int" default="0" />
<description> <description>
Sample the lighing information at a specific position.
</description> </description>
</method> </method>
<method name="set_default_quadrant_size"> <method name="set_default_quadrant_size">
<return type="void" /> <return type="void" />
<argument index="0" name="size" type="Vector2i" /> <argument index="0" name="size" type="Vector2i" />
<description> <description>
Set the default internal quadrant size.
</description> </description>
</method> </method>
</methods> </methods>
@ -221,15 +261,19 @@
<signal name="map_changed"> <signal name="map_changed">
<argument index="0" name="map" type="RID" /> <argument index="0" name="map" type="RID" />
<description> <description>
Emitted after a map changed (only once per frame).
</description> </description>
</signal> </signal>
</signals> </signals>
<constants> <constants>
<constant name="VERTEX_LIGHT_2D_MODE_ADD" value="0" enum="VertexLight2DMode"> <constant name="VERTEX_LIGHT_2D_MODE_ADD" value="0" enum="VertexLight2DMode">
The light's color gets added to the resulting colors.
</constant> </constant>
<constant name="VERTEX_LIGHT_2D_MODE_SUB" value="1" enum="VertexLight2DMode"> <constant name="VERTEX_LIGHT_2D_MODE_SUB" value="1" enum="VertexLight2DMode">
The light's color gets substracted to the resulting colors.
</constant> </constant>
<constant name="VERTEX_LIGHT_2D_MODE_MIX" value="2" enum="VertexLight2DMode"> <constant name="VERTEX_LIGHT_2D_MODE_MIX" value="2" enum="VertexLight2DMode">
The light's color gets blended with the resulting colors.
</constant> </constant>
</constants> </constants>
</class> </class>