Quellcode durchsuchen

Added note on culling of meshes

Björn Ritzl vor 2 Jahren
Ursprung
Commit
4f2a5feb5c
1 geänderte Dateien mit 25 neuen und 18 gelöschten Zeilen
  1. 25 18
      docs/en/manuals/mesh.md

+ 25 - 18
docs/en/manuals/mesh.md

@@ -46,24 +46,7 @@ With the mesh component in place you are free to edit and manipulate the compone
 
 ## Runtime manipulation
 
-You can manipulate meshes at runtime using Defold buffers.
-
-## Material constants
-
-{% include shared/material-constants.md component='mesh' variable='tint' %}
-
-`tint`
-: The color tint of the mesh (`vector4`). The vector4 is used to represent the tint with x, y, z, and w corresponding to the red, green, blue and alpha tint.
-
-## Vertex local vs world space
-If the Vertex Space setting of the mesh material is set to Local Space the data will be provided as-is to you in your shader, and you will have to transform vertices/normals as usual on the GPU.
-
-If the Vertex Space setting of the mesh material is set to World Space you have to either provide a default “position” and “normal”, stream, or you can select it from the dropdown, when editing the mesh. This is so that the engine can transform the data to world space for batching with other objects.
-
-## Examples
-Refer to the [forum announcement post for more information](https://forum.defold.com/t/mesh-component-in-defold-1-2-169-beta/65137) on how to use the Mesh component, including sample projects and code snippets.
-
-Example of creating a cube from triangle strips:
+You can manipulate meshes at runtime using Defold buffers. Example of creating a cube from triangle strips:
 
 ```Lua
 
@@ -100,3 +83,27 @@ end
 local res = go.get("#mesh", "vertices")
 resource.set_buffer(res, buf)
 ```
+
+Refer to the [forum announcement post for more information](https://forum.defold.com/t/mesh-component-in-defold-1-2-169-beta/65137) on how to use the Mesh component, including sample projects and code snippets.
+
+
+## Frustum culling
+
+Mesh components are not automatically culled due to their dynamic nature and the fact that it is not possible to know for sure how the positional data is encoded. In order to cull a mesh the axis-aligned bounding box of the mesh needs to be set as meta data on the buffer using 6 floats (AABB min/max):
+
+```lua
+buffer.set_metadata(buf, hash("AABB"), { 0, 0, 0, 1, 1, 1 }, buffer.VALUE_TYPE_FLOAT32)
+```
+
+
+## Material constants
+
+{% include shared/material-constants.md component='mesh' variable='tint' %}
+
+`tint`
+: The color tint of the mesh (`vector4`). The vector4 is used to represent the tint with x, y, z, and w corresponding to the red, green, blue and alpha tint.
+
+## Vertex local vs world space
+If the Vertex Space setting of the mesh material is set to Local Space the data will be provided as-is to you in your shader, and you will have to transform vertices/normals as usual on the GPU.
+
+If the Vertex Space setting of the mesh material is set to World Space you have to either provide a default “position” and “normal”, stream, or you can select it from the dropdown, when editing the mesh. This is so that the engine can transform the data to world space for batching with other objects.