Difference between revisions of "Shader:sendColor"
m (→Other Languages: fixed i18n (Shader:send -> Shader:sendColor)) |
|||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
{{newin|[[0.10.0]]|100|type=function}} | {{newin|[[0.10.0]]|100|type=function}} | ||
− | Sends one or more colors to a special ( | + | Sends one or more colors to a special (''uniform'') vec3 or vec4 variable inside the shader. The color components must be in the range of [0, 1]. The colors are gamma-corrected if global [[love.graphics.isGammaCorrect|gamma-correction]] is enabled. |
− | + | Uniforms must be marked using the ''uniform'' keyword, e.g. | |
<source lang="glsl"> | <source lang="glsl"> | ||
− | + | uniform vec4 Color; | |
</source> | </source> | ||
Line 15: | Line 15: | ||
− | + | Uniforms can be accessed in both the Vertex and Pixel stages of a shader, as long as the variable is declared in each. | |
+ | |||
+ | In versions prior to [[11.0]], color component values were within the range of 0 to 255 instead of 0 to 1. | ||
== Function == | == Function == | ||
Line 23: | Line 25: | ||
</source> | </source> | ||
=== Arguments === | === Arguments === | ||
− | {{param|string|name|The name of the color | + | {{param|string|name|The name of the color uniform to send to in the shader.}} |
− | {{param|table|color|A table with red, green, blue, and optional alpha color components in the range of [0, | + | {{param|table|color|A table with red, green, blue, and optional alpha color components in the range of [0, 1] to send to the uniform as a vector.}} |
− | {{param|table|...|Additional colors to send in case the | + | {{param|table|...|Additional colors to send in case the uniform is an array. All colors need to be of the same size (e.g. only vec3's).}} |
=== Returns === | === Returns === | ||
Nothing. | Nothing. |
Latest revision as of 15:02, 19 September 2024
Available since LÖVE 0.10.0 |
This function is not supported in earlier versions. |
Sends one or more colors to a special (uniform) vec3 or vec4 variable inside the shader. The color components must be in the range of [0, 1]. The colors are gamma-corrected if global gamma-correction is enabled.
Uniforms must be marked using the uniform keyword, e.g.
uniform vec4 Color;
The corresponding sendColor call would be
shader:sendColor("Color", {r, g, b, a})
Uniforms can be accessed in both the Vertex and Pixel stages of a shader, as long as the variable is declared in each.
In versions prior to 11.0, color component values were within the range of 0 to 255 instead of 0 to 1.
Function
Synopsis
Shader:sendColor( name, color, ... )
Arguments
string name
- The name of the color uniform to send to in the shader.
table color
- A table with red, green, blue, and optional alpha color components in the range of [0, 1] to send to the uniform as a vector.
table ...
- Additional colors to send in case the uniform is an array. All colors need to be of the same size (e.g. only vec3's).
Returns
Nothing.
See Also
Other Languages
Dansk –
Deutsch –
English –
Español –
Français –
Indonesia –
Italiano –
Lietuviškai –
Magyar –
Nederlands –
Polski –
Português –
Română –
Slovenský –
Suomi –
Svenska –
Türkçe –
Česky –
Ελληνικά –
Български –
Русский –
Српски –
Українська –
עברית –
ไทย –
日本語 –
正體中文 –
简体中文 –
Tiếng Việt –
한국어
More info