diff --git a/doc/en/scripting/builtins/libgfx-posteffects.md b/doc/en/scripting/builtins/libgfx-posteffects.md index ffd6c502..9cf9222f 100644 --- a/doc/en/scripting/builtins/libgfx-posteffects.md +++ b/doc/en/scripting/builtins/libgfx-posteffects.md @@ -34,4 +34,24 @@ gfx.posteffect.is_active(slot: int) --> bool -- Sets parameters values ('param' directives) gfx.posteffect.set_params(params: table) + +-- Sets values to an array +gfx.posteffect.set_array( + -- effect slot index + slot: int, + -- parameter (array) name + name: str + -- data string (use Bytearray_as_string function) + data: str +) + +-- Example of filling an array `#param vec3 u_arrayName[64]`: +local buffer = Bytearray(0) +for i = 0, 63 do + local x = math.random() * 2.0 - 1.0 + local y = math.random() * 2.0 - 1.0 + local z = math.random() * 2.0 - 1.0 + Bytearray.append(buffer, byteutil.pack("fff", x, y, z)) +end +gfx.posteffects.set_array(slot, "u_arrayName", Bytearray_as_string(buffer)) ``` diff --git a/doc/ru/scripting/builtins/libgfx-posteffects.md b/doc/ru/scripting/builtins/libgfx-posteffects.md index f0a75011..bdc45864 100644 --- a/doc/ru/scripting/builtins/libgfx-posteffects.md +++ b/doc/ru/scripting/builtins/libgfx-posteffects.md @@ -34,4 +34,24 @@ gfx.posteffect.is_active(slot: int) --> bool -- Устанавливает значения параметров (директивы 'param') gfx.posteffect.set_params(params: table) + +-- Устанавливает значения в массив +gfx.posteffect.set_array( + -- индекс слота эффектов + slot: int, + -- имя параметра (массива) + name: str + -- строка данных (используйте функцию Bytearray_as_string) + data: str +) + +-- Пример заполнения массива `#param vec3 u_имяМассива[64]`: +local buffer = Bytearray(0) +for i = 0, 63 do + local x = math.random() * 2.0 - 1.0 + local y = math.random() * 2.0 - 1.0 + local z = math.random() * 2.0 - 1.0 + Bytearray.append(buffer, byteutil.pack("fff", x, y, z)) +end +gfx.posteffects.set_array(slot, "u_имяМассива", Bytearray_as_string(buffer)) ```