mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-04 14:11:02 +03:00
More Godot 4 rename fixes (#6315)
* Spatial -> 3D, Transform, Quaternion * File -> FileAccess * Camera -> Camera3D * Update references to MeshInstance and MultiMeshInstance * ImmediateGeometry -> ImmediateMesh, misc renames
This commit is contained in:
@@ -53,7 +53,7 @@ efficient for millions of objects, but for a few thousands, GDScript should be f
|
||||
.. tabs::
|
||||
.. code-tab:: gdscript GDScript
|
||||
|
||||
extends MultiMeshInstance
|
||||
extends MultiMeshInstance3D
|
||||
|
||||
|
||||
func _ready():
|
||||
@@ -77,7 +77,7 @@ efficient for millions of objects, but for a few thousands, GDScript should be f
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
public class YourClassName : MultiMeshInstance
|
||||
public class YourClassName : MultiMeshInstance3D
|
||||
{
|
||||
public override void _Ready()
|
||||
{
|
||||
|
||||
@@ -66,7 +66,7 @@ For nodes, there are many functions available:
|
||||
* For Viewport, the :ref:`Viewport.get_viewport_rid() <class_Viewport_method_get_viewport_rid>`
|
||||
method will return the viewport RID in the server.
|
||||
* For 3D, the :ref:`World3D <class_World3D>` resource (obtainable in the :ref:`Viewport <class_Viewport>`
|
||||
and :ref:`Spatial <class_Spatial>` nodes)
|
||||
and :ref:`Node3D <class_Node3D>` nodes)
|
||||
contains functions to get the *RenderingServer Scenario*, and the *PhysicsServer Space*. This
|
||||
allows creating 3D objects directly with the server API and using them.
|
||||
* For 2D, the :ref:`World2D <class_World2D>` resource (obtainable in the :ref:`Viewport <class_Viewport>`
|
||||
@@ -132,7 +132,7 @@ The 3D APIs are different from the 2D ones, so the instantiation API must be use
|
||||
.. tabs::
|
||||
.. code-tab:: gdscript GDScript
|
||||
|
||||
extends Spatial
|
||||
extends Node3D
|
||||
|
||||
|
||||
# RenderingServer expects references to be kept around.
|
||||
@@ -193,7 +193,7 @@ and moves a :ref:`CanvasItem <class_CanvasItem>` when the body moves.
|
||||
Physics2DServer.body_set_force_integration_callback(body, self, "_body_moved", 0)
|
||||
|
||||
The 3D version should be very similar, as 2D and 3D physics servers are identical (using
|
||||
:ref:`RigidBody <class_RigidBody>` and :ref:`PhysicsServer <class_PhysicsServer>` respectively).
|
||||
:ref:`RigidBody3D <class_RigidBody3D>` and :ref:`PhysicsServer <class_PhysicsServer>` respectively).
|
||||
|
||||
Getting data from the servers
|
||||
-----------------------------
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
.. _doc_animating_thousands_of_fish:
|
||||
|
||||
Animating thousands of fish with MultiMeshInstance
|
||||
==================================================
|
||||
Animating thousands of fish with MultiMeshInstance3D
|
||||
====================================================
|
||||
|
||||
This tutorial explores a technique used in the game `ABZU <https://www.gdcvault.com/play/1024409/Creating-the-Art-of-ABZ>`_
|
||||
for rendering and animating thousands of fish using vertex animation and
|
||||
static mesh instancing.
|
||||
|
||||
In Godot, this can be accomplished with a custom :ref:`Shader <class_Shader>` and
|
||||
a :ref:`MultiMeshInstance <class_MultiMeshInstance>`. Using the following technique you
|
||||
a :ref:`MultiMeshInstance3D <class_MultiMeshInstance3D>`. Using the following technique you
|
||||
can render thousands of animated objects, even on low end hardware.
|
||||
|
||||
We will start by animating one fish. Then, we will see how to extend that animation to
|
||||
@@ -17,7 +17,7 @@ thousands of fish.
|
||||
Animating one Fish
|
||||
------------------
|
||||
|
||||
We will start with a single fish. Load your fish model into a :ref:`MeshInstance <class_MeshInstance>`
|
||||
We will start with a single fish. Load your fish model into a :ref:`MeshInstance3D <class_MeshInstance3D>`
|
||||
and add a new :ref:`ShaderMaterial <class_ShaderMaterial>`.
|
||||
|
||||
Here is the fish we will be using for the example images, you can use any fish model you like.
|
||||
@@ -181,13 +181,13 @@ find that you can create a wide variety of swim styles using these four motions.
|
||||
Making a school of fish
|
||||
-----------------------
|
||||
|
||||
Godot makes it easy to render thousands of the same object using a MultiMeshInstance node.
|
||||
Godot makes it easy to render thousands of the same object using a MultiMeshInstance3D node.
|
||||
|
||||
A MultiMeshInstance node is created and used the same way you would make a MeshInstance node.
|
||||
For this tutorial, we will name the MultiMeshInstance node ``School``, because it will contain
|
||||
A MultiMeshInstance3D node is created and used the same way you would make a MeshInstance3D node.
|
||||
For this tutorial, we will name the MultiMeshInstance3D node ``School``, because it will contain
|
||||
a school of fish.
|
||||
|
||||
Once you have a MultiMeshInstance add a :ref:`MultiMesh <class_MultiMesh>`, and to that
|
||||
Once you have a MultiMeshInstance3D add a :ref:`MultiMesh <class_MultiMesh>`, and to that
|
||||
MultiMesh add your :ref:`Mesh <class_Mesh>` with the shader from above.
|
||||
|
||||
MultiMeshes draw your Mesh with three additional per-instance properties: Transform (rotation,
|
||||
@@ -212,7 +212,7 @@ Now, set ``instance_count`` to the number of fish you want to have.
|
||||
Next we need to set the per-instance transforms.
|
||||
|
||||
There are two ways to set per-instance transforms for MultiMeshes. The first is entirely in editor
|
||||
and is described in the :ref:`MultiMeshInstance tutorial <doc_using_multi_mesh_instance>`.
|
||||
and is described in the :ref:`MultiMeshInstance3D tutorial <doc_using_multi_mesh_instance>`.
|
||||
|
||||
The second is to loop over all the instances and set their transforms in code. Below, we use GDScript
|
||||
to loop over all the instances and set their transform to a random position.
|
||||
@@ -225,7 +225,7 @@ to loop over all the instances and set their transform to a random position.
|
||||
$School.multimesh.set_instance_transform(i, position)
|
||||
|
||||
Running this script will place the fish in random positions in a box around the position of the
|
||||
MultiMeshInstance.
|
||||
MultiMeshInstance3D.
|
||||
|
||||
.. note:: If performance is an issue for you, try running the scene with GLES2 or with fewer fish.
|
||||
|
||||
@@ -268,7 +268,7 @@ custom value.
|
||||
|
||||
One problem that you will run into at this point is that the fish are animated, but they are not
|
||||
moving. You can move them by updating the per-instance transform for each fish every frame. Although
|
||||
doing so will be faster than moving thousands of MeshInstances per frame, it'll still likely be
|
||||
doing so will be faster than moving thousands of MeshInstance3Ds per frame, it'll still likely be
|
||||
slow.
|
||||
|
||||
In the next tutorial we will cover how to use :ref:`GPUParticles3D <class_GPUParticles3D>` to take advantage
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
Controlling thousands of fish with Particles
|
||||
============================================
|
||||
|
||||
The problem with :ref:`MeshInstances <class_MeshInstance>` is that it is expensive to
|
||||
The problem with :ref:`MeshInstance3D <class_MeshInstance3D>` is that it is expensive to
|
||||
update their transform array. It is great for placing many static objects around the
|
||||
scene. But it is still difficult to move the objects around the scene.
|
||||
|
||||
@@ -11,7 +11,7 @@ To make each instance move in an interesting way, we will use a
|
||||
:ref:`GPUParticles3D <class_GPUParticles3D>` node. Particles take advantage of GPU acceleration
|
||||
by computing and setting the per-instance information in a :ref:`Shader <class_Shader>`.
|
||||
|
||||
.. note:: Particles are not available in GLES2, instead use :ref:`CPUParticles <class_CPUParticles>`,
|
||||
.. note:: Particles are not available in GLES2, instead use :ref:`CPUParticles3D <class_CPUParticles3D>`,
|
||||
which do the same thing as Particles, but do not benefit from GPU acceleration.
|
||||
|
||||
First create a Particles node. Then, under "Draw Passes" set the Particle's "Draw Pass 1" to your
|
||||
@@ -52,7 +52,7 @@ These functions come from the default :ref:`ParticleProcessMaterial <class_Parti
|
||||
They are used to generate a random number from each particle's ``RANDOM_SEED``.
|
||||
|
||||
A unique thing about particle shaders is that some built-in variables are saved across frames.
|
||||
``TRANSFORM``, ``COLOR``, and ``CUSTOM`` can all be accessed in the Spatial shader of the mesh, and
|
||||
``TRANSFORM``, ``COLOR``, and ``CUSTOM`` can all be accessed in the shader of the mesh, and
|
||||
also in the particle shader the next time it is run.
|
||||
|
||||
Next, setup your ``vertex`` function. Particles shaders only contain a vertex function
|
||||
|
||||
Reference in New Issue
Block a user