Skip to content

Commit

Permalink
Document VERTEX_ID, INSTANCE_ID built-ins for vertex shaders
Browse files Browse the repository at this point in the history
  • Loading branch information
kleonc committed Nov 7, 2023
1 parent e6c5c0b commit 4148b45
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tutorials/2d/using_tilemaps.rst
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ Autotiles allow you to define a group of tiles, then add rules to control which
tile gets used for drawing based on the content of adjacent cells.

Click "New Autotile" and drag to select the tiles you wish to use. You can add
collisions, occlusion, navigation shapes, tile priorties, and select an icon
collisions, occlusion, navigation shapes, tile priorities, and select an icon
tile in the same manner as for atlas tiles.

Tile selection is controlled by bitmasks. Bitmasks can be added by clicking
Expand Down
2 changes: 1 addition & 1 deletion tutorials/3d/using_transforms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ Setting information

There are, of course, cases where you want to set information to a transform. Imagine a first person controller or orbiting camera. Those are definitely done using angles, because you *do want* the transforms to happen in a specific order.

For such cases, keep the angles and rotations *outside* the transform and set them every frame. Don't try to retrieve and re-use them because the transform is not meant to be used this way.
For such cases, keep the angles and rotations *outside* the transform and set them every frame. Don't try to retrieve and reuse them because the transform is not meant to be used this way.

Example of looking around, FPS style:

Expand Down
2 changes: 1 addition & 1 deletion tutorials/best_practices/scene_organization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ initialize it:
GetNode(TargetPath); // Use parent-defined NodePath.

These options hide the points of access from the child node. This in turn
keeps the child **loosely coupled** to its environment. One can re-use it
keeps the child **loosely coupled** to its environment. One can reuse it
in another context without any extra changes to its API.

.. note::
Expand Down
2 changes: 1 addition & 1 deletion tutorials/performance/gpu_optimization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ possible. Godot's priorities are:
scene, the faster the rendering will be. If a scene has a huge amount
of objects (in the hundreds or thousands), try reusing the materials.
In the worst case, use atlases to decrease the amount of texture changes.
- **Reusing Shaders:** If materials can't be reused, at least try to re-use
- **Reusing Shaders:** If materials can't be reused, at least try to reuse
shaders. Note: shaders are automatically reused between
SpatialMaterials that share the same configuration (features
that are enabled or disabled with a check box) even if they have different
Expand Down
6 changes: 6 additions & 0 deletions tutorials/shaders/shader_reference/canvas_item_shader.rst
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,18 @@ is usually:
+--------------------------------+----------------------------------------------------------------+
| in mat4 **PROJECTION_MATRIX** | View space to clip space transform. |
+--------------------------------+----------------------------------------------------------------+
| in int **INSTANCE_ID** | Instance ID for instancing. Not supported in GLES2 (returns |
| | 0). |
+--------------------------------+----------------------------------------------------------------+
| in vec4 **INSTANCE_CUSTOM** | Instance custom data. |
+--------------------------------+----------------------------------------------------------------+
| in bool **AT_LIGHT_PASS** | ``true`` if this is a light pass. |
+--------------------------------+----------------------------------------------------------------+
| inout vec2 **VERTEX** | Vertex, in image space. |
+--------------------------------+----------------------------------------------------------------+
| in int **VERTEX_ID** | The index of the current vertex in the vertex buffer. Not |
| | supported in GLES2 (returns 0). |
+--------------------------------+----------------------------------------------------------------+
| in vec2 **TEXTURE_PIXEL_SIZE** | Normalized pixel size of default 2D texture. |
| | For a Sprite with a texture of size 64x32px, |
| | **TEXTURE_PIXEL_SIZE** = :code:`vec2(1/64, 1/32)` |
Expand Down
6 changes: 5 additions & 1 deletion tutorials/shaders/shader_reference/spatial_shader.rst
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ shader, this value can be used as desired.
+--------------------------------------+--------------------------------------------------------+
| inout vec3 **VERTEX** | Vertex in local coordinates. |
+--------------------------------------+--------------------------------------------------------+
| in int **VERTEX_ID** | The index of the current vertex in the vertex buffer. |
| | Not supported in GLES2 (returns 0). |
+--------------------------------------+--------------------------------------------------------+
| out vec4 **POSITION** | If written to, overrides final vertex position. |
+--------------------------------------+--------------------------------------------------------+
| inout vec3 **NORMAL** | Normal in local coordinates. |
Expand All @@ -183,7 +186,8 @@ shader, this value can be used as desired.
+--------------------------------------+--------------------------------------------------------+
| inout float **POINT_SIZE** | Point size for point rendering. |
+--------------------------------------+--------------------------------------------------------+
| in int **INSTANCE_ID** | Instance ID for instancing. |
| in int **INSTANCE_ID** | Instance ID for instancing. Not supported in GLES2 |
| | (returns 0). |
+--------------------------------------+--------------------------------------------------------+
| in vec4 **INSTANCE_CUSTOM** | Instance custom data (for particles, mostly). |
+--------------------------------------+--------------------------------------------------------+
Expand Down

0 comments on commit 4148b45

Please sign in to comment.