瀏覽代碼

Added more info about sprite material constants

Björn Ritzl 5 年之前
父節點
當前提交
9ca42f2815
共有 2 個文件被更改,包括 16 次插入2 次删除
  1. 1 1
      docs/en/manuals/material.md
  2. 15 1
      docs/en/manuals/sprite.md

+ 1 - 1
docs/en/manuals/material.md

@@ -68,7 +68,7 @@ CONSTANT_TYPE_NORMAL
 : A matrix to compute normal orientation. The world transform might include non-uniform scaling, which breaks the orthogonality of the combined world-view transform. The normal matrix is used to avoid issues with the direction when transforming normals. (The normal matrix is the transpose inverse of the world-view matrix).
 : A matrix to compute normal orientation. The world transform might include non-uniform scaling, which breaks the orthogonality of the combined world-view transform. The normal matrix is used to avoid issues with the direction when transforming normals. (The normal matrix is the transpose inverse of the world-view matrix).
 
 
 CONSTANT_TYPE_USER
 CONSTANT_TYPE_USER
-: A vector4 constant that you can use for any custom data you want to pass into your shader programs. You can set the initial value of the constant in the constant definition, but it is mutable through the functions `.set_constant()` and `.reset_constant()` for each component type (`sprite`, `model`, `spine`, `particlefx` and `tilemap`)
+: A vector4 constant that you can use for any custom data you want to pass into your shader programs. You can set the initial value of the constant in the constant definition, but it is mutable through the functions `.set_constant()` and `.reset_constant()` for each component type (`sprite`, `model`, `spine`, `particlefx` and `tilemap`). Changing a material constant of a single component instance [breaks render batching and will result in additional draw calls](/manuals/render/#draw-calls-and-batching).
 
 
 ## Samplers
 ## Samplers
 
 

+ 15 - 1
docs/en/manuals/sprite.md

@@ -27,7 +27,7 @@ Apart from the properties *Id*, *Position* and *Rotation* the following componen
 *Blend Mode*
 *Blend Mode*
 : The blend mode to use when rendering this component.
 : The blend mode to use when rendering this component.
 
 
-# Runtime manipulation
+## Runtime manipulation
 
 
 You can manipulate sprites in runtime through a number of different functions and properties (refer to the [API docs for usage](/ref/sprite/)). Functions:
 You can manipulate sprites in runtime through a number of different functions and properties (refer to the [API docs for usage](/ref/sprite/)). Functions:
 
 
@@ -39,6 +39,12 @@ A sprite also has a number of different properties that can be manipulated using
 `cursor`
 `cursor`
 : The normalized animation cursor (`number`).
 : The normalized animation cursor (`number`).
 
 
+`image`
+: The sprite image (`hash`). You can change this using an atlas or tilesource resource property and `go.set()`. Refer to the [API reference for an example](/ref/sprite/#image).
+
+`material`
+: The sprite material (`hash`). You can change this using a material resource property and `go.set()`. Refer to the [API reference for an example](/ref/sprite/#material).
+
 `playback_rate`
 `playback_rate`
 : The animation playback rate (`number`).
 : The animation playback rate (`number`).
 
 
@@ -47,3 +53,11 @@ A sprite also has a number of different properties that can be manipulated using
 
 
 `size`
 `size`
 : The size of the sprite (`vector3`) (READ ONLY).
 : The size of the sprite (`vector3`) (READ ONLY).
+
+
+## Sprite material constants
+
+The default sprite material has the following constants that can be changed using `sprite.set_constant()` and reset using `sprite.reset_constant()` (refer to the [Material manual for more details](/manuals/material/#vertex-and-fragment-constants)):
+
+`tint`
+: The color tint of the sprite (`vector4`). The vector4 is used to represent the tint with x, y, z, and w corresponding to the red, green, blue and alpha tint. Refer to the [API reference for an example](/ref/sprite/#sprite.set_constant:url-constant-value).