Skip to content

Commit f95b911

Browse files
authored
Small note about setting non-v4 and m4 attributes with less data (#597)
* Small note about setting non-v4 and m4 attributes with less data * Update material.md
1 parent e2b9894 commit f95b911

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

docs/en/manuals/material.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,16 @@ There are some caveats to updating the vertex attributes however, whether or not
140140
Setting custom vertex data in runtime is currently only supported for sprite components.
141141
:::
142142

143+
In cases where that a vertex attribute is either a scalar or a vector type other than a `Vec4` you can still set the data using `go.set`:
144+
145+
```lua
146+
-- The last two components in the vec4 will not be used!
147+
go.set("#sprite", "sprite_position_2d", vmath.vector4(my_x,my_y,0,0))
148+
go.animate("#sprite", "sprite_position_2d", go.PLAYBACK_LOOP_PINGPONG, vmath.vector4(1,2,0,0), go.EASING_LINEAR, 2)
149+
```
150+
151+
The same is true for matrix attributes, if the attribute is a matrix type other than a `Mat4` you can still set the data using `go.set`.
152+
143153
### Instancing
144154

145155
Instancing is a technique used to efficiently draw multiple copies of the same object in a scene. Instead of creating a separate copy of the object each time it's used, instancing allows the graphics engine to create a single object and then reuse it multiple times. For example, in a game with a large forest, instead of creating a separate tree model for each tree, instancing allows you to create one tree model and then place it hundreds or thousands of times with different positions and scales. The forest can now be rendered with a single draw call instead of individual draw calls for each tree.

0 commit comments

Comments
 (0)