Struct gdnative_bindings_lily::VisualServer[][src]

pub struct VisualServer { /* fields omitted */ }
Expand description

core singleton class VisualServer inherits Object (unsafe).

Official documentation

See the documentation of this class in the Godot engine’s official documentation. The method descriptions are generated from it and typically contain code samples in GDScript, not Rust.

Class hierarchy

VisualServer inherits methods from:

Safety

All types in the Godot API have “interior mutability” in Rust parlance. To enforce that the official thread-safety guidelines are followed, the typestate pattern is used in the Ref and TRef smart pointers, and the Instance API. The typestate Access in these types tracks whether the access is unique, shared, or exclusive to the current thread. For more information, see the type-level documentation on Ref.

Implementations

Constants

Returns a reference to the singleton instance.

Safety

This singleton server is only safe to access from outside the main thread if thread-safe operations are enabled in the project settings. See the official thread-safety guidelines for more information.

Sets images to be rendered in the window margin.

Sets margin size, where black bars (or images, if [method black_bars_set_images] was used) are rendered.

Creates a camera and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all camera_* VisualServer functions. Once finished with your RID, you will want to free the RID using the VisualServer’s [method free_rid] static method.

Sets the cull mask associated with this camera. The cull mask describes which 3D layers are rendered by this camera. Equivalent to [member Camera.cull_mask].

Sets the environment used by this camera. Equivalent to [member Camera.environment].

Sets camera to use frustum projection. This mode allows adjusting the offset argument to create “tilted frustum” effects.

Sets camera to use orthogonal projection, also known as orthographic projection. Objects remain the same size on the screen no matter how far away they are.

Sets camera to use perspective projection. Objects on the screen becomes smaller when they are far away.

Sets Transform of camera.

If true, preserves the horizontal aspect ratio which is equivalent to [constant Camera.KEEP_WIDTH]. If false, preserves the vertical aspect ratio which is equivalent to [constant Camera.KEEP_HEIGHT].

Creates a canvas and returns the assigned [RID]. It can be accessed with the RID that is returned. This RID will be used in all canvas_* VisualServer functions. Once finished with your RID, you will want to free the RID using the VisualServer’s [method free_rid] static method.

Adds a circle command to the CanvasItem’s draw commands.

If ignore is true, the VisualServer does not perform clipping.

Adds a line command to the CanvasItem’s draw commands.

Default Arguments

  • width - 1.0
  • antialiased - false

Adds a mesh command to the CanvasItem’s draw commands.

Default Arguments

  • transform - Transform2D( 1, 0, 0, 1, 0, 0 )
  • modulate - Color( 1, 1, 1, 1 )

Adds a MultiMesh to the CanvasItem’s draw commands. Only affects its aabb at the moment.

Adds a nine patch image to the CanvasItem’s draw commands. See NinePatchRect for more explanation.

Default Arguments

  • x_axis_mode - 0
  • y_axis_mode - 0
  • draw_center - true
  • modulate - Color( 1, 1, 1, 1 )

Adds a particle system to the CanvasItem’s draw commands.

Adds a polygon to the CanvasItem’s draw commands.

Default Arguments

  • uvs - PoolVector2Array( )
  • antialiased - false

Adds a polyline, which is a line from multiple points with a width, to the CanvasItem’s draw commands.

Default Arguments

  • width - 1.0
  • antialiased - false

Adds a primitive to the CanvasItem’s draw commands.

Default Arguments

  • width - 1.0

Adds a rectangle to the CanvasItem’s draw commands.

Adds a Transform2D command to the CanvasItem’s draw commands. This sets the extra_matrix uniform when executed. This affects the later commands of the canvas item.

Adds a textured rect to the CanvasItem’s draw commands.

Default Arguments

  • tile - false
  • modulate - Color( 1, 1, 1, 1 )
  • transpose - false

Adds a texture rect with region setting to the CanvasItem’s draw commands.

Default Arguments

  • modulate - Color( 1, 1, 1, 1 )
  • transpose - false
  • clip_uv - true

Adds a triangle array to the CanvasItem’s draw commands.

Default Arguments

  • uvs - PoolVector2Array( )
  • bones - PoolIntArray( )
  • weights - PoolRealArray( )
  • count - -1
  • antialiased - false
  • antialiasing_use_indices - false

Clears the CanvasItem and removes all commands in it.

Creates a new CanvasItem and returns its [RID]. It can be accessed with the RID that is returned. This RID will be used in all canvas_item_* VisualServer functions. Once finished with your RID, you will want to free the RID using the VisualServer’s [method free_rid] static method.

Sets clipping for the CanvasItem.

Sets the CanvasItem to copy a rect to the backbuffer.

Defines a custom drawing rectangle for the CanvasItem.

Default Arguments

  • rect - Rect2( 0, 0, 0, 0 )

Enables the use of distance fields for GUI elements that are rendering distance field based fonts.

Sets CanvasItem to be drawn behind its parent.

Sets the index for the CanvasItem.

The light mask. See LightOccluder2D for more information on light masks.

Sets a new material to the CanvasItem.

Sets the color that modulates the CanvasItem and its children.

Sets the parent for the CanvasItem. The parent can be another canvas item, or it can be the root canvas that is attached to the viewport.

Sets the color that modulates the CanvasItem without children.

Sets if CanvasItem’s children should be sorted by y-position.

Sets the CanvasItem’s Transform2D.

Sets if the CanvasItem uses its parent’s material.

Sets if the canvas item (including its children) is visible.

If this is enabled, the Z index of the parent will be added to the children’s Z index.

Sets the CanvasItem’s Z index, i.e. its draw order (lower indexes are drawn first).

Attaches the canvas light to the canvas. Removes it from its previous canvas.

Creates a canvas light and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all canvas_light_* VisualServer functions. Once finished with your RID, you will want to free the RID using the VisualServer’s [method free_rid] static method.

Attaches a light occluder to the canvas. Removes it from its previous canvas.

Creates a light occluder and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all canvas_light_ocluder_* VisualServer functions. Once finished with your RID, you will want to free the RID using the VisualServer’s [method free_rid] static method.

Enables or disables light occluder.

The light mask. See LightOccluder2D for more information on light masks.

Sets a light occluder’s polygon.

Sets a light occluder’s Transform2D.

Sets the color for a light.

Enables or disables a canvas light.

Sets a canvas light’s energy.

Sets a canvas light’s height.

The light mask. See LightOccluder2D for more information on light masks.

The binary mask used to determine which layers this canvas light’s shadows affects. See LightOccluder2D for more information on light masks.

The layer range that gets rendered with this light.

The mode of the light, see [enum CanvasLightMode] constants.

Sets the texture’s scale factor of the light. Equivalent to [member Light2D.texture_scale].

Sets the width of the shadow buffer, size gets scaled to the next power of two for this.

Sets the color of the canvas light’s shadow.

Enables or disables the canvas light’s shadow.

Sets the canvas light’s shadow’s filter, see [enum CanvasLightShadowFilter] constants.

Sets the length of the shadow’s gradient.

Smoothens the shadow. The lower, the smoother.

Sets texture to be used by light. Equivalent to [member Light2D.texture].

Sets the offset of the light’s texture. Equivalent to [member Light2D.offset].

Sets the canvas light’s Transform2D.

Sets the Z range of objects that will be affected by this light. Equivalent to [member Light2D.range_z_min] and [member Light2D.range_z_max].

Creates a new light occluder polygon and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all canvas_occluder_polygon_* VisualServer functions. Once finished with your RID, you will want to free the RID using the VisualServer’s [method free_rid] static method.

Sets an occluder polygons cull mode. See [enum CanvasOccluderPolygonCullMode] constants.

Sets the shape of the occluder polygon.

Sets the shape of the occluder polygon as lines.

A copy of the canvas item will be drawn with a local offset of the mirroring Vector2.

Modulates all colors in the given canvas.

Creates a directional light and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID can be used in most light_* VisualServer functions. Once finished with your RID, you will want to free the RID using the VisualServer’s [method free_rid] static method. To place in a scene, attach this directional light to an instance using [method instance_set_base] using the returned RID.

Draws a frame. [i]This method is deprecated[/i], please use [method force_draw] instead.

Default Arguments

  • swap_buffers - true
  • frame_step - 0.0

Creates an environment and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all environment_* VisualServer functions. Once finished with your RID, you will want to free the RID using the VisualServer’s [method free_rid] static method.

Sets the values to be used with the “Adjustment” post-process effect. See Environment for more details.

Sets the ambient light parameters. See Environment for more details.

Default Arguments

  • energy - 1.0
  • sky_contibution - 0.0

Sets the [i]BGMode[/i] of the environment. Equivalent to [member Environment.background_mode].

Color displayed for clear areas of the scene (if using Custom color or Color+Sky background modes).

Sets the intensity of the background color.

Sets the maximum layer to use if using Canvas background mode.

Sets the values to be used with the “DoF Far Blur” post-process effect. See Environment for more details.

Sets the values to be used with the “DoF Near Blur” post-process effect. See Environment for more details.

Sets the variables to be used with the scene fog. See Environment for more details.

Sets the variables to be used with the fog depth effect. See Environment for more details.

Sets the variables to be used with the fog height effect. See Environment for more details.

Sets the variables to be used with the “glow” post-process effect. See Environment for more details.

Sets the Sky to be used as the environment’s background when using [i]BGMode[/i] sky. Equivalent to [member Environment.background_sky].

Sets a custom field of view for the background Sky. Equivalent to [member Environment.background_sky_custom_fov].

Sets the rotation of the background Sky expressed as a Basis. Equivalent to [member Environment.background_sky_orientation].

Sets the variables to be used with the “Screen Space Ambient Occlusion (SSAO)” post-process effect. See Environment for more details.

Sets the variables to be used with the “screen space reflections” post-process effect. See Environment for more details.

Sets the variables to be used with the “tonemap” post-process effect. See Environment for more details.

Removes buffers and clears testcubes.

Forces a frame to be drawn when the function is called. Drawing a frame updates all Viewports that are set to update. Use with extreme caution.

Default Arguments

  • swap_buffers - true
  • frame_step - 0.0

Synchronizes threads.

Tries to free an object in the VisualServer.

Returns a certain information, see [enum RenderInfo] for options.

Returns the id of the test cube. Creates one if none exists.

Returns the id of the test texture. Creates one if none exists.

Returns the name of the video adapter (e.g. “GeForce GTX 1080/PCIe/SSE2”). Note: When running a headless or server binary, this function returns an empty string.

Returns the vendor of the video adapter (e.g. “NVIDIA Corporation”). Note: When running a headless or server binary, this function returns an empty string.

Returns the id of a white texture. Creates one if none exists.

Creates a GI probe and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all gi_probe_* VisualServer functions. Once finished with your RID, you will want to free the RID using the VisualServer’s [method free_rid] static method. To place in a scene, attach this GI probe to an instance using [method instance_set_base] using the returned RID.

Returns the bias value for the GI probe. Bias is used to avoid self occlusion. Equivalent to [member GIProbeData.bias].

Returns the axis-aligned bounding box that covers the full extent of the GI probe.

Returns the cell size set by [method gi_probe_set_cell_size].

Returns the data used by the GI probe.

Returns the dynamic range set for this GI probe. Equivalent to [member GIProbe.dynamic_range].

Returns the energy multiplier for this GI probe. Equivalent to [member GIProbe.energy].

Returns the normal bias for this GI probe. Equivalent to [member GIProbe.normal_bias].

Returns the propagation value for this GI probe. Equivalent to [member GIProbe.propagation].

Returns the Transform set by [method gi_probe_set_to_cell_xform].

Returns true if the GI probe data associated with this GI probe is compressed. Equivalent to [member GIProbe.compress].

Returns true if the GI probe is set to interior, meaning it does not account for sky light. Equivalent to [member GIProbe.interior].

Sets the bias value to avoid self-occlusion. Equivalent to [member GIProbe.bias].

Sets the axis-aligned bounding box that covers the extent of the GI probe.

Sets the size of individual cells within the GI probe.

Sets the compression setting for the GI probe data. Compressed data will take up less space but may look worse. Equivalent to [member GIProbe.compress].

Sets the data to be used in the GI probe for lighting calculations. Normally this is created and called internally within the GIProbe node. You should not try to set this yourself.

Sets the dynamic range of the GI probe. Dynamic range sets the limit for how bright lights can be. A smaller range captures greater detail but limits how bright lights can be. Equivalent to [member GIProbe.dynamic_range].

Sets the energy multiplier for this GI probe. A higher energy makes the indirect light from the GI probe brighter. Equivalent to [member GIProbe.energy].

Sets the interior value of this GI probe. A GI probe set to interior does not include the sky when calculating lighting. Equivalent to [member GIProbe.interior].

Sets the normal bias for this GI probe. Normal bias behaves similar to the other form of bias and may help reduce self-occlusion. Equivalent to [member GIProbe.normal_bias].

Sets the propagation of light within this GI probe. Equivalent to [member GIProbe.propagation].

Sets the to cell Transform for this GI probe.

Returns true if changes have been made to the VisualServer’s data. [method draw] is usually called if this happens.

Not yet implemented. Always returns false.

Returns true if the OS supports a certain feature. Features might be s3tc, etc, etc2 and pvrtc.

Sets up ImmediateGeometry internals to prepare for drawing. Equivalent to [method ImmediateGeometry.begin].

Clears everything that was set up between [method immediate_begin] and [method immediate_end]. Equivalent to [method ImmediateGeometry.clear].

Sets the color to be used with next vertex. Equivalent to [method ImmediateGeometry.set_color].

Creates an immediate geometry and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all immediate_* VisualServer functions. Once finished with your RID, you will want to free the RID using the VisualServer’s [method free_rid] static method. To place in a scene, attach this immediate geometry to an instance using [method instance_set_base] using the returned RID.

Ends drawing the ImmediateGeometry and displays it. Equivalent to [method ImmediateGeometry.end].

Returns the material assigned to the ImmediateGeometry.

Sets the normal to be used with next vertex. Equivalent to [method ImmediateGeometry.set_normal].

Sets the material to be used to draw the ImmediateGeometry.

Sets the tangent to be used with next vertex. Equivalent to [method ImmediateGeometry.set_tangent].

Sets the UV to be used with next vertex. Equivalent to [method ImmediateGeometry.set_uv].

Sets the UV2 to be used with next vertex. Equivalent to [method ImmediateGeometry.set_uv2].

Adds the next vertex using the information provided in advance. Equivalent to [method ImmediateGeometry.add_vertex].

Adds the next vertex using the information provided in advance. This is a helper class that calls [method immediate_vertex] under the hood. Equivalent to [method ImmediateGeometry.add_vertex].

Initializes the visual server. This function is called internally by platform-dependent code during engine initialization. If called from a running game, it will not do anything.

Attaches a unique Object ID to instance. Object ID must be attached to instance for proper culling with [method instances_cull_aabb], [method instances_cull_convex], and [method instances_cull_ray].

Attaches a skeleton to an instance. Removes the previous skeleton from the instance.

Creates a visual instance and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all instance_* VisualServer functions. Once finished with your RID, you will want to free the RID using the VisualServer’s [method free_rid] static method. An instance is a way of placing a 3D object in the scenario. Objects like particles, meshes, and reflection probes need to be associated with an instance to be visible in the scenario using [method instance_set_base].

Creates a visual instance, adds it to the VisualServer, and sets both base and scenario. It can be accessed with the RID that is returned. This RID will be used in all instance_* VisualServer functions. Once finished with your RID, you will want to free the RID using the VisualServer’s [method free_rid] static method.

Not implemented in Godot 3.x.

Sets the shadow casting setting to one of [enum ShadowCastingSetting]. Equivalent to [member GeometryInstance.cast_shadow].

Not implemented in Godot 3.x.

Sets the flag for a given [enum InstanceFlags]. See [enum InstanceFlags] for more details.

Sets a material that will override the material for all surfaces on the mesh associated with this instance. Equivalent to [member GeometryInstance.material_override].

Sets the base of the instance. A base can be any of the 3D objects that are created in the VisualServer that can be displayed. For example, any of the light types, mesh, multimesh, immediate geometry, particle system, reflection probe, lightmap capture, and the GI probe are all types that can be set as the base of an instance in order to be displayed in the scenario.

Sets the weight for a given blend shape associated with this instance.

Sets a custom AABB to use when culling objects from the view frustum. Equivalent to [method GeometryInstance.set_custom_aabb].

Function not implemented in Godot 3.x.

Sets a margin to increase the size of the AABB when culling objects from the view frustum. This allows you avoid culling objects that fall outside the view frustum. Equivalent to [member GeometryInstance.extra_cull_margin].

Sets the render layers that this instance will be drawn to. Equivalent to [member VisualInstance.layers].

Sets the scenario that the instance is in. The scenario is the 3D world that the objects will be displayed in.

Sets the material of a specific surface. Equivalent to [method MeshInstance.set_surface_material].

Sets the world space transform of the instance. Equivalent to [member Spatial.transform].

Sets the lightmap to use with this instance.

Sets whether an instance is drawn or not. Equivalent to [member Spatial.visible].

Returns an array of object IDs intersecting with the provided AABB. Only visual 3D nodes are considered, such as MeshInstance or DirectionalLight. Use [method @GDScript.instance_from_id] to obtain the actual nodes. A scenario RID must be provided, which is available in the World you want to query. This forces an update for all resources queued to update. Warning: This function is primarily intended for editor usage. For in-game use cases, prefer physics collision.

Returns an array of object IDs intersecting with the provided convex shape. Only visual 3D nodes are considered, such as MeshInstance or DirectionalLight. Use [method @GDScript.instance_from_id] to obtain the actual nodes. A scenario RID must be provided, which is available in the World you want to query. This forces an update for all resources queued to update. Warning: This function is primarily intended for editor usage. For in-game use cases, prefer physics collision.

Returns an array of object IDs intersecting with the provided 3D ray. Only visual 3D nodes are considered, such as MeshInstance or DirectionalLight. Use [method @GDScript.instance_from_id] to obtain the actual nodes. A scenario RID must be provided, which is available in the World you want to query. This forces an update for all resources queued to update. Warning: This function is primarily intended for editor usage. For in-game use cases, prefer physics collision.

If false, disables rendering completely, but the engine logic is still being processed. You can call [method force_draw] to draw a frame even with rendering disabled.

If true, this directional light will blend between shadow map splits resulting in a smoother transition between them. Equivalent to [member DirectionalLight.directional_shadow_blend_splits].

Sets the shadow depth range mode for this directional light. Equivalent to [member DirectionalLight.directional_shadow_depth_range]. See [enum LightDirectionalShadowDepthRangeMode] for options.

Sets the shadow mode for this directional light. Equivalent to [member DirectionalLight.directional_shadow_mode]. See [enum LightDirectionalShadowMode] for options.

Sets whether to use vertical or horizontal detail for this omni light. This can be used to alleviate artifacts in the shadow map. Equivalent to [member OmniLight.omni_shadow_detail].

Sets whether to use a dual paraboloid or a cubemap for the shadow map. Dual paraboloid is faster but may suffer from artifacts. Equivalent to [member OmniLight.omni_shadow_mode].

Sets the color of the light. Equivalent to [member Light.light_color].

Sets the cull mask for this Light. Lights only affect objects in the selected layers. Equivalent to [member Light.light_cull_mask].

If true, light will subtract light instead of adding light. Equivalent to [member Light.light_negative].

Sets the specified light parameter. See [enum LightParam] for options. Equivalent to [method Light.set_param].

Not implemented in Godot 3.x.

If true, reverses the backface culling of the mesh. This can be useful when you have a flat mesh that has a light behind it. If you need to cast a shadow on both sides of the mesh, set the mesh to use double sided shadows with [method instance_geometry_set_cast_shadows_setting]. Equivalent to [member Light.shadow_reverse_cull_face].

If true, light will cast shadows. Equivalent to [member Light.shadow_enabled].

Sets the color of the shadow cast by the light. Equivalent to [member Light.shadow_color].

Sets whether GI probes capture light information from this light.

Creates a lightmap capture and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all lightmap_capture_* VisualServer functions. Once finished with your RID, you will want to free the RID using the VisualServer’s [method free_rid] static method. To place in a scene, attach this lightmap capture to an instance using [method instance_set_base] using the returned RID.

Returns the size of the lightmap capture area.

Returns the energy multiplier used by the lightmap capture.

Returns the octree used by the lightmap capture.

Returns the cell subdivision amount used by this lightmap capture’s octree.

Returns the cell transform for this lightmap capture’s octree.

Sets the size of the area covered by the lightmap capture. Equivalent to [member BakedLightmapData.bounds].

Sets the energy multiplier for this lightmap capture. Equivalent to [member BakedLightmapData.energy].

Sets the octree to be used by this lightmap capture. This function is normally used by the BakedLightmap node. Equivalent to [member BakedLightmapData.octree].

Sets the subdivision level of this lightmap capture’s octree. Equivalent to [member BakedLightmapData.cell_subdiv].

Sets the octree cell transform for this lightmap capture’s octree. Equivalent to [member BakedLightmapData.cell_space_transform].

Returns a mesh of a sphere with the given amount of horizontal and vertical subdivisions.

Creates an empty material and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all material_* VisualServer functions. Once finished with your RID, you will want to free the RID using the VisualServer’s [method free_rid] static method.

Returns the value of a certain material’s parameter.

Returns the default value for the param if available. Otherwise returns an empty Variant.

Returns the shader of a certain material’s shader. Returns an empty RID if the material doesn’t have a shader.

Sets a material’s line width.

Sets an object’s next material.

Sets a material’s parameter.

Sets a material’s render priority.

Sets a shader material’s shader.

Adds a surface generated from the Arrays to a mesh. See [enum PrimitiveType] constants for types.

Default Arguments

  • blend_shapes - [ ]
  • compress_format - 97280

Removes all surfaces from a mesh.

Creates a new mesh and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all mesh_* VisualServer functions. Once finished with your RID, you will want to free the RID using the VisualServer’s [method free_rid] static method. To place in a scene, attach this mesh to an instance using [method instance_set_base] using the returned RID.

Returns a mesh’s blend shape count.

Returns a mesh’s blend shape mode.

Returns a mesh’s custom aabb.

Returns a mesh’s number of surfaces.

Removes a mesh’s surface.

Sets a mesh’s blend shape count.

Sets a mesh’s blend shape mode.

Sets a mesh’s custom aabb.

Returns a mesh’s surface’s aabb.

Returns a mesh’s surface’s vertex buffer.

Returns a mesh’s surface’s amount of indices.

Returns a mesh’s surface’s amount of vertices.

Returns a mesh’s surface’s buffer arrays.

Returns a mesh’s surface’s arrays for blend shapes.

Returns the format of a mesh’s surface.

Function is unused in Godot 3.x.

Function is unused in Godot 3.x.

Returns a mesh’s surface’s index buffer.

Returns a mesh’s surface’s material.

Returns the primitive type of a mesh’s surface.

Returns the aabb of a mesh’s surface’s skeleton.

Sets a mesh’s surface’s material.

Updates a specific region of a vertex buffer for the specified surface. Warning: this function alters the vertex buffer directly with no safety mechanisms, you can easily corrupt your mesh.

Allocates space for the multimesh data. Format parameters determine how the data will be stored by OpenGL. See [enum MultimeshTransformFormat], [enum MultimeshColorFormat], and [enum MultimeshCustomDataFormat] for usage. Equivalent to [member MultiMesh.instance_count].

Default Arguments

  • custom_data_format - 0

Creates a new multimesh on the VisualServer and returns an [RID] handle. This RID will be used in all multimesh_* VisualServer functions. Once finished with your RID, you will want to free the RID using the VisualServer’s [method free_rid] static method. To place in a scene, attach this multimesh to an instance using [method instance_set_base] using the returned RID.

Calculates and returns the axis-aligned bounding box that encloses all instances within the multimesh.

Returns the number of instances allocated for this multimesh.

Returns the RID of the mesh that will be used in drawing this multimesh.

Returns the number of visible instances for this multimesh.

Returns the color by which the specified instance will be modulated.

Returns the custom data associated with the specified instance.

Returns the Transform of the specified instance.

Returns the Transform2D of the specified instance. For use when the multimesh is set to use 2D transforms.

Sets the color by which this instance will be modulated. Equivalent to [method MultiMesh.set_instance_color].

Sets the custom data for this instance. Custom data is passed as a Color, but is interpreted as a vec4 in the shader. Equivalent to [method MultiMesh.set_instance_custom_data].

Sets the Transform for this instance. Equivalent to [method MultiMesh.set_instance_transform].

Sets the Transform2D for this instance. For use when multimesh is used in 2D. Equivalent to [method MultiMesh.set_instance_transform_2d].

Sets all data related to the instances in one go. This is especially useful when loading the data from disk or preparing the data from GDNative.

All data is packed in one large float array. An array may look like this: Transform for instance 1, color data for instance 1, custom data for instance 1, transform for instance 2, color data for instance 2, etc.

Transform is stored as 12 floats, Transform2D is stored as 8 floats, COLOR_8BIT / CUSTOM_DATA_8BIT is stored as 1 float (4 bytes as is) and COLOR_FLOAT / CUSTOM_DATA_FLOAT is stored as 4 floats.

Sets the mesh to be drawn by the multimesh. Equivalent to [member MultiMesh.mesh].

Sets the number of instances visible at a given time. If -1, all instances that have been allocated are drawn. Equivalent to [member MultiMesh.visible_instance_count].

Creates a new omni light and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID can be used in most light_* VisualServer functions. Once finished with your RID, you will want to free the RID using the VisualServer’s [method free_rid] static method. To place in a scene, attach this omni light to an instance using [method instance_set_base] using the returned RID.

Creates a particle system and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all particles_* VisualServer functions. Once finished with your RID, you will want to free the RID using the VisualServer’s [method free_rid] static method. To place in a scene, attach these particles to an instance using [method instance_set_base] using the returned RID.

Calculates and returns the axis-aligned bounding box that contains all the particles. Equivalent to [method Particles.capture_aabb].

Returns true if particles are currently set to emitting.

Returns true if particles are not emitting and particles are set to inactive.

Add particle system to list of particle systems that need to be updated. Update will take place on the next frame, or on the next call to [method instances_cull_aabb], [method instances_cull_convex], or [method instances_cull_ray].

Reset the particles on the next update. Equivalent to [method Particles.restart].

Sets the number of particles to be drawn and allocates the memory for them. Equivalent to [member Particles.amount].

Sets a custom axis-aligned bounding box for the particle system. Equivalent to [member Particles.visibility_aabb].

Sets the draw order of the particles to one of the named enums from [enum ParticlesDrawOrder]. See [enum ParticlesDrawOrder] for options. Equivalent to [member Particles.draw_order].

Sets the mesh to be used for the specified draw pass. Equivalent to [member Particles.draw_pass_1], [member Particles.draw_pass_2], [member Particles.draw_pass_3], and [member Particles.draw_pass_4].

Sets the number of draw passes to use. Equivalent to [member Particles.draw_passes].

Sets the Transform that will be used by the particles when they first emit.

If true, particles will emit over time. Setting to false does not reset the particles, but only stops their emission. Equivalent to [member Particles.emitting].

Sets the explosiveness ratio. Equivalent to [member Particles.explosiveness].

Sets the frame rate that the particle system rendering will be fixed to. Equivalent to [member Particles.fixed_fps].

If true, uses fractional delta which smooths the movement of the particles. Equivalent to [member Particles.fract_delta].

Sets the lifetime of each particle in the system. Equivalent to [member Particles.lifetime].

If true, particles will emit once and then stop. Equivalent to [member Particles.one_shot].

Sets the preprocess time for the particles animation. This lets you delay starting an animation until after the particles have begun emitting. Equivalent to [member Particles.preprocess].

Sets the material for processing the particles. Note: this is not the material used to draw the materials. Equivalent to [member Particles.process_material].

Sets the emission randomness ratio. This randomizes the emission of particles within their phase. Equivalent to [member Particles.randomness].

Sets the speed scale of the particle system. Equivalent to [member Particles.speed_scale].

If true, particles use local coordinates. If false they use global coordinates. Equivalent to [member Particles.local_coords].

Creates a reflection probe and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all reflection_probe_* VisualServer functions. Once finished with your RID, you will want to free the RID using the VisualServer’s [method free_rid] static method. To place in a scene, attach this reflection probe to an instance using [method instance_set_base] using the returned RID.

If true, reflections will ignore sky contribution. Equivalent to [member ReflectionProbe.interior_enable].

Sets the render cull mask for this reflection probe. Only instances with a matching cull mask will be rendered by this probe. Equivalent to [member ReflectionProbe.cull_mask].

If true, uses box projection. This can make reflections look more correct in certain situations. Equivalent to [member ReflectionProbe.box_projection].

If true, computes shadows in the reflection probe. This makes the reflection much slower to compute. Equivalent to [member ReflectionProbe.enable_shadows].

Sets the size of the area that the reflection probe will capture. Equivalent to [member ReflectionProbe.extents].

Sets the intensity of the reflection probe. Intensity modulates the strength of the reflection. Equivalent to [member ReflectionProbe.intensity].

Sets the ambient light color for this reflection probe when set to interior mode. Equivalent to [member ReflectionProbe.interior_ambient_color].

Sets the energy multiplier for this reflection probes ambient light contribution when set to interior mode. Equivalent to [member ReflectionProbe.interior_ambient_energy].

Sets the contribution value for how much the reflection affects the ambient light for this reflection probe when set to interior mode. Useful so that ambient light matches the color of the room. Equivalent to [member ReflectionProbe.interior_ambient_contrib].

Sets the max distance away from the probe an object can be before it is culled. Equivalent to [member ReflectionProbe.max_distance].

Sets the origin offset to be used when this reflection probe is in box project mode. Equivalent to [member ReflectionProbe.origin_offset].

Sets how often the reflection probe updates. Can either be once or every frame. See [enum ReflectionProbeUpdateMode] for options.

Schedules a callback to the corresponding named method on where after a frame has been drawn. The callback method must use only 1 argument which will be called with userdata.

Creates a scenario and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all scenario_* VisualServer functions. Once finished with your RID, you will want to free the RID using the VisualServer’s [method free_rid] static method. The scenario is the 3D world that all the visual instances exist in.

Sets the [enum ScenarioDebugMode] for this scenario. See [enum ScenarioDebugMode] for options.

Sets the environment that will be used with this scenario.

Sets the fallback environment to be used by this scenario. The fallback environment is used if no environment is set. Internally, this is used by the editor to provide a default environment.

Sets the size of the reflection atlas shared by all reflection probes in this scenario.

Sets a boot image. The color defines the background color. If scale is true, the image will be scaled to fit the screen size. If use_filter is true, the image will be scaled with linear interpolation. If use_filter is false, the image will be scaled with nearest-neighbor interpolation.

Default Arguments

  • use_filter - true

If true, the engine will generate wireframes for use with the wireframe debug mode.

Sets the default clear color which is used when a specific clear color has not been selected.

If false, disables rendering completely, but the engine logic is still being processed. You can call [method force_draw] to draw a frame even with rendering disabled.

Sets the scale to apply to the passage of time for the shaders’ TIME builtin. The default value is 1.0, which means TIME will count the real time as it goes by, without narrowing or stretching it.

Creates an empty shader and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all shader_* VisualServer functions. Once finished with your RID, you will want to free the RID using the VisualServer’s [method free_rid] static method.

Returns a shader’s code.

Returns a default texture from a shader searched by name.

Returns the parameters of a shader.

Sets a shader’s code.

Sets a shader’s default texture. Overwrites the texture given by name.

Allocates the GPU buffers for this skeleton.

Default Arguments

  • is_2d_skeleton - false

Returns the Transform set for a specific bone of this skeleton.

Returns the Transform2D set for a specific bone of this skeleton.

Sets the Transform for a specific bone of this skeleton.

Sets the Transform2D for a specific bone of this skeleton.

Creates a skeleton and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all skeleton_* VisualServer functions. Once finished with your RID, you will want to free the RID using the VisualServer’s [method free_rid] static method.

Returns the number of bones allocated for this skeleton.

Creates an empty sky and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all sky_* VisualServer functions. Once finished with your RID, you will want to free the RID using the VisualServer’s [method free_rid] static method.

Sets a sky’s texture.

Creates a spot light and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID can be used in most light_* VisualServer functions. Once finished with your RID, you will want to free the RID using the VisualServer’s [method free_rid] static method. To place in a scene, attach this spot light to an instance using [method instance_set_base] using the returned RID.

Not implemented in Godot 3.x.

Allocates the GPU memory for the texture.

Default Arguments

  • flags - 7

Binds the texture to a texture slot.

Creates an empty texture and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all texture_* VisualServer functions. Once finished with your RID, you will want to free the RID using the VisualServer’s [method free_rid] static method.

Creates a texture, allocates the space for an image, and fills in the image.

Default Arguments

  • flags - 7

Returns a list of all the textures and their information.

Returns a copy of a texture’s image unless it’s a CubeMap, in which case it returns the [RID] of the image at one of the cubes sides.

Default Arguments

  • cube_side - 0

Returns the depth of the texture.

Returns the flags of a texture.

Returns the format of the texture’s image.

Returns the texture’s height.

Returns the texture’s path.

Returns the opengl id of the texture’s image.

Returns the type of the texture, can be any of the [enum TextureType].

Returns the texture’s width.

Sets the texture’s image data. If it’s a CubeMap, it sets the image data at a cube side.

Default Arguments

  • layer - 0

Sets a part of the data for a texture. Warning: this function calls the underlying graphics API directly and may corrupt your texture if used improperly.

Default Arguments

  • layer - 0

Sets the texture’s flags. See [enum TextureFlags] for options.

Sets the texture’s path.

If true, sets internal processes to shrink all image data to half the size.

Resizes the texture to the specified dimensions.

If true, the image will be stored in the texture’s images array if overwritten.

Sets a viewport’s camera.

Sets a viewport’s canvas.

Sample code is GDScript unless otherwise noted.

Copies viewport to a region of the screen specified by rect. If [member Viewport.render_direct_to_screen] is true, then viewport does not use a framebuffer and the contents of the viewport are rendered directly to screen. However, note that the root viewport is drawn last, therefore it will draw over the screen. Accordingly, you must set the root viewport to an area that does not cover the area that you have attached this viewport to. For example, you can set the root viewport to not render at all with the following code:

func _ready():
    get_viewport().set_attach_to_screen_rect(Rect2())
    $Viewport.set_attach_to_screen_rect(Rect2(0, 0, 600, 600))

Using this can result in significant optimization, especially on lower-end devices. However, it comes at the cost of having to manage your viewports manually. For a further optimization see, [method viewport_set_render_direct_to_screen].

Default Arguments

  • rect - Rect2( 0, 0, 0, 0 )
  • screen - 0

Creates an empty viewport and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all viewport_* VisualServer functions. Once finished with your RID, you will want to free the RID using the VisualServer’s [method free_rid] static method.

Detaches the viewport from the screen.

Returns a viewport’s render information. For options, see the [enum ViewportRenderInfo] constants.

Returns the viewport’s last rendered frame.

Detaches a viewport from a canvas and vice versa.

If true, sets the viewport active, else sets it inactive.

Sets the stacking order for a viewport’s canvas. layer is the actual canvas layer, while sublayer specifies the stacking order of the canvas among those in the same layer.

Sets the transformation of a viewport’s canvas.

Sets the clear mode of a viewport. See [enum ViewportClearMode] for options.

Sets the debug draw mode of a viewport. See [enum ViewportDebugDraw] for options.

If true, a viewport’s 3D rendering is disabled.

If true, rendering of a viewport’s environment is disabled.

Sets the viewport’s global transformation matrix.

If true, the viewport renders to hdr.

If true, the viewport’s canvas is not rendered.

Currently unimplemented in Godot 3.x.

Sets the anti-aliasing mode. See [enum ViewportMSAA] for options.

Sets the viewport’s parent to another viewport.

If true, render the contents of the viewport directly to screen. This allows a low-level optimization where you can skip drawing a viewport to the root viewport. While this optimization can result in a significant increase in speed (especially on older devices), it comes at a cost of usability. When this is enabled, you cannot read from the viewport or from the SCREEN_TEXTURE. You also lose the benefit of certain window settings, such as the various stretch modes. Another consequence to be aware of is that in 2D the rendering happens in window coordinates, so if you have a viewport that is double the size of the window, and you set this, then only the portion that fits within the window will be drawn, no automatic scaling is possible, even if your game scene is significantly larger than the window size.

Sets a viewport’s scenario. The scenario contains information about the [enum ScenarioDebugMode], environment information, reflection atlas etc.

Sets the shadow atlas quadrant’s subdivision.

Sets the size of the shadow atlas’s images (used for omni and spot lights). The value will be rounded up to the nearest power of 2.

Sets the viewport’s width and height.

If true, the viewport renders its background as transparent.

Sets when the viewport should be updated. See [enum ViewportUpdateMode] constants for options.

Sets the viewport’s 2D/3D mode. See [enum ViewportUsage] constants for options.

If true, the viewport uses augmented or virtual reality technologies. See ARVRInterface.

If true, the viewport’s rendering is flipped vertically.

Methods from Deref<Target = Object>

Adds a user-defined signal. Arguments are optional, but can be added as an [Array] of dictionaries, each containing name: String and type: int (see [enum Variant.Type]) entries.

Default Arguments

  • arguments - [ ]

Sample code is GDScript unless otherwise noted.

Calls the method on the object and returns the result. This method supports a variable number of arguments, so parameters are passed as a comma separated list. Example:

call("set", "position", Vector2(42.0, 0.0))

Note: In C#, the method name must be specified as snake_case if it is defined by a built-in Godot node. This doesn’t apply to user-defined methods where you should use the same convention as in the C# source (typically PascalCase).

Safety

This function bypasses Rust’s static type checks (aliasing, thread boundaries, calls to free(), …).

Sample code is GDScript unless otherwise noted.

Calls the method on the object during idle time. This method supports a variable number of arguments, so parameters are passed as a comma separated list. Example:

call_deferred("set", "position", Vector2(42.0, 0.0))

Note: In C#, the method name must be specified as snake_case if it is defined by a built-in Godot node. This doesn’t apply to user-defined methods where you should use the same convention as in the C# source (typically PascalCase).

Safety

This function bypasses Rust’s static type checks (aliasing, thread boundaries, calls to free(), …).

Sample code is GDScript unless otherwise noted.

Calls the method on the object and returns the result. Contrarily to [method call], this method does not support a variable number of arguments but expects all parameters to be via a single [Array].

callv("set", [ "position", Vector2(42.0, 0.0) ])

Safety

This function bypasses Rust’s static type checks (aliasing, thread boundaries, calls to free(), …).

Returns true if the object can translate strings. See [method set_message_translation] and [method tr].

Sample code is GDScript unless otherwise noted.

Connects a signal to a method on a target object. Pass optional binds to the call as an [Array] of parameters. These parameters will be passed to the method after any parameter used in the call to [method emit_signal]. Use flags to set deferred or one-shot connections. See [enum ConnectFlags] constants. A signal can only be connected once to a method. It will throw an error if already connected, unless the signal was connected with [constant CONNECT_REFERENCE_COUNTED]. To avoid this, first, use [method is_connected] to check for existing connections. If the target is destroyed in the game’s lifecycle, the connection will be lost. Examples:

connect("pressed", self, "_on_Button_pressed") # BaseButton signal
connect("text_entered", self, "_on_LineEdit_text_entered") # LineEdit signal
connect("hit", self, "_on_Player_hit", [ weapon_type, damage ]) # User-defined signal

An example of the relationship between binds passed to [method connect] and parameters used when calling [method emit_signal]:

connect("hit", self, "_on_Player_hit", [ weapon_type, damage ]) # weapon_type and damage are passed last
emit_signal("hit", "Dark lord", 5) # "Dark lord" and 5 are passed first
func _on_Player_hit(hit_by, level, weapon_type, damage):
    print("Hit by %s (lvl %d) with weapon %s for %d damage" % [hit_by, level, weapon_type, damage])

Default Arguments

  • binds - [ ]
  • flags - 0

Disconnects a signal from a method on the given target. If you try to disconnect a connection that does not exist, the method will throw an error. Use [method is_connected] to ensure that the connection exists.

Sample code is GDScript unless otherwise noted.

Emits the given signal. The signal must exist, so it should be a built-in signal of this class or one of its parent classes, or a user-defined signal. This method supports a variable number of arguments, so parameters are passed as a comma separated list. Example:

emit_signal("hit", weapon_type, damage)
emit_signal("game_over")

Returns the Variant value of the given property. If the property doesn’t exist, this will return null. Note: In C#, the property name must be specified as snake_case if it is defined by a built-in Godot node. This doesn’t apply to user-defined properties where you should use the same convention as in the C# source (typically PascalCase).

Returns the object’s class as a String.

Returns an [Array] of dictionaries with information about signals that are connected to the object. Each Dictionary contains three String entries:

  • source is a reference to the signal emitter.
  • signal_name is the name of the connected signal.
  • method_name is the name of the method to which the signal is connected.

Gets the object’s property indexed by the given NodePath. The node path should be relative to the current object and can use the colon character (:) to access nested properties. Examples: "position:x" or "material:next_pass:blend_mode".

Returns the object’s unique instance ID. This ID can be saved in EncodedObjectAsID, and can be used to retrieve the object instance with [method @GDScript.instance_from_id].

Returns the object’s metadata entry for the given name.

Returns the object’s metadata as a [PoolStringArray].

Returns the object’s methods and their signatures as an [Array].

Returns the object’s property list as an [Array] of dictionaries. Each property’s Dictionary contain at least name: String and type: int (see [enum Variant.Type]) entries. Optionally, it can also include hint: int (see [enum PropertyHint]), hint_string: String, and usage: int (see [enum PropertyUsageFlags]).

Returns the object’s Script instance, or null if none is assigned.

Returns an [Array] of connections for the given signal.

Returns the list of signals as an [Array] of dictionaries.

Returns true if a metadata entry is found with the given name.

Returns true if the object contains the given method.

Returns true if the given signal exists.

Returns true if the given user-defined signal exists. Only signals added using [method add_user_signal] are taken into account.

Returns true if signal emission blocking is enabled.

Returns true if the object inherits from the given class.

Returns true if a connection exists for a given signal, target, and method.

Returns true if the [method Node.queue_free] method was called for the object.

Send a given notification to the object, which will also trigger a call to the [method _notification] method of all classes that the object inherits from. If reversed is true, [method _notification] is called first on the object’s own class, and then up to its successive parent classes. If reversed is false, [method _notification] is called first on the highest ancestor (Object itself), and then down to its successive inheriting classes.

Default Arguments

  • reversed - false

Notify the editor that the property list has changed, so that editor plugins can take the new values into account. Does nothing on export builds.

Removes a given entry from the object’s metadata. See also [method set_meta].

Assigns a new value to the given property. If the property does not exist, nothing will happen. Note: In C#, the property name must be specified as snake_case if it is defined by a built-in Godot node. This doesn’t apply to user-defined properties where you should use the same convention as in the C# source (typically PascalCase).

If set to true, signal emission is blocked.

Assigns a new value to the given property, after the current frame’s physics step. This is equivalent to calling [method set] via [method call_deferred], i.e. call_deferred("set", property, value). Note: In C#, the property name must be specified as snake_case if it is defined by a built-in Godot node. This doesn’t apply to user-defined properties where you should use the same convention as in the C# source (typically PascalCase).

Sample code is GDScript unless otherwise noted.

Assigns a new value to the property identified by the NodePath. The node path should be relative to the current object and can use the colon character (:) to access nested properties. Example:

set_indexed("position", Vector2(42, 0))
set_indexed("position:y", -10)
print(position) # (42, -10)

Defines whether the object can translate strings (with calls to [method tr]). Enabled by default.

Adds, changes or removes a given entry in the object’s metadata. Metadata are serialized and can take any Variant value. To remove a given entry from the object’s metadata, use [method remove_meta]. Metadata is also removed if its value is set to null. This means you can also use set_meta("name", null) to remove metadata for "name".

Assigns a script to the object. Each object can have a single script assigned to it, which are used to extend its functionality. If the object already had a script, the previous script instance will be freed and its variables and state will be lost. The new script’s [method _init] method will be called.

Returns a String representing the object. If not overridden, defaults to "[ClassName:RID]". Override the method [method _to_string] to customize the String representation.

Translates a message using translation catalogs configured in the Project Settings. Only works if message translation is enabled (which it is by default), otherwise it returns the message unchanged. See [method set_message_translation].

Trait Implementations

Formats the value using the given formatter. Read more

The resulting type after dereferencing.

Dereferences the value.

Mutably dereferences the value.

The memory management kind of this type. This modifies the behavior of the Ref smart pointer. See its type-level documentation for more information. Read more

Creates an explicitly null reference of Self as a method argument. This makes type inference easier for the compiler compared to Option. Read more

Creates a new instance of Self using a zero-argument constructor, as a Unique reference. Read more

Performs a dynamic reference downcast to target type. Read more

Performs a static reference upcast to a supertype that is guaranteed to be valid. Read more

Creates a persistent reference to the same Godot object with shared thread access. Read more

Creates a persistent reference to the same Godot object with thread-local thread access. Read more

Creates a persistent reference to the same Godot object with unique access. Read more

Recovers a instance ID previously returned by Object::get_instance_id if the object is still alive. See also TRef::try_from_instance_id. Read more

Recovers a instance ID previously returned by Object::get_instance_id if the object is still alive, and panics otherwise. This does NOT guarantee that the resulting reference is safe to use. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.