Difference between revisions of "PixelEffect:send"

m (clarify difference between sending a table and sending multiple values)
(Remove wrong(!) documentation for sending a vector. Add documentation for sending arrays.)
Line 1: Line 1:
 
{{newin|[[0.8.0]]|080|type=function}}
 
{{newin|[[0.8.0]]|080|type=function}}
Sends one or more values to a pixel effect using the specified name.
+
Sends one or more values to a special (''extern'') variable inside the pixel effect. Extern variables have to be marked using the ''extern'' keyword, e.g.
  
This function allows certain aspects of a pixel effect to be controlled by Lua code.
+
<source lang="glsl">
 +
extern number time;
 +
extern vec2 light_pos;
 +
extern vec4 colors[4];
 +
</source>
 +
 
 +
The corresponding send calls would be
 +
 
 +
<source lang="lua">
 +
effect:send("number", t)
 +
effect:send("light_pos", {light_x, light_y})
 +
effect:send("colors", {r1, g1, b1, a1},  {r2, g2, b2, a2},  {r3, g3, b3, a3},  {r4, g4, b4, a4})
 +
</source>
  
 
== Function ==
 
== Function ==
 
=== Synopsis ===
 
=== Synopsis ===
 
<source lang="lua">
 
<source lang="lua">
PixelEffect:send( name, number )
+
PixelEffect:send( name, number, ... )
 
</source>
 
</source>
 
=== Arguments ===
 
=== Arguments ===
 
{{param|string|name|Name of the number to send to the pixel effect.}}
 
{{param|string|name|Name of the number to send to the pixel effect.}}
{{param|number|number|Number to send to the pixel effect.}}
+
{{param|number|number|Number to send to store in the extern.}}
 +
{{param|number|...|Additional numbers to send in case the extern is an array.}}
 
=== Returns ===
 
=== Returns ===
 
Nothing.
 
Nothing.
  
== Function ==
 
=== Synopsis ===
 
<source lang="lua">
 
PixelEffect:send( name, ... )
 
</source>
 
=== Arguments ===
 
{{param|string|name|Name of the array to send to the pixel effect.}}
 
{{param|number|...|Numbers to send to the pixel effect as a vector. Up to four can be sent. These values can be accessed inside the shader via an array.}}
 
 
=== Returns ===
 
=== Returns ===
 
Nothing.
 
Nothing.
Line 29: Line 34:
 
=== Synopsis ===
 
=== Synopsis ===
 
<source lang="lua">
 
<source lang="lua">
PixelEffect:send( name, values )
+
PixelEffect:send( name, vector, ... )
 
</source>
 
</source>
 
=== Arguments ===
 
=== Arguments ===
 
{{param|string|name|Name of the vector to send to the pixel effect.}}
 
{{param|string|name|Name of the vector to send to the pixel effect.}}
{{param|table|values|Numbers to send to the pixel effect as a vector. At least two and up to four can be sent. These values can be accessed inside the shader via a vector.}}
+
{{param|table|vector|Numbers to send to the extern as a vector. The number of elements in the table determines the type of the vector (e.g. two numbers -> vec2). At least two and at most four numbers can be used.}}
 +
{{param|table|...|Additional vectors to send in case the extern is an array. All vectors need to be of the same size (e.g. only vec3's)}}
 
=== Returns ===
 
=== Returns ===
 
Nothing.
 
Nothing.
Line 40: Line 46:
 
=== Synopsis ===
 
=== Synopsis ===
 
<source lang="lua">
 
<source lang="lua">
PixelEffect:send( name, matrix )
+
PixelEffect:send( name, matrix, ... )
 
</source>
 
</source>
 
=== Arguments ===
 
=== Arguments ===
 
{{param|string|name|Name of the matrix to send to the pixel effect.}}
 
{{param|string|name|Name of the matrix to send to the pixel effect.}}
{{param|table|matrix|2x2, 3x3, or 4x4 matrix to send to the pixel effect. Using table form: <code><nowiki>{{a,b,c,d}, {e,f,g,h}, ... }</nowiki></code>}}
+
{{param|table|matrix|2x2, 3x3, or 4x4 matrix to send to the extern. Using table form: <code><nowiki>{{a,b,c,d}, {e,f,g,h}, ... }</nowiki></code>}}
 +
{{param|table|...|Additional matrices of the same type as ''matrix'' to store in the extern array.}}
 
=== Returns ===
 
=== Returns ===
 
Nothing.
 
Nothing.
Line 51: Line 58:
 
=== Synopsis ===
 
=== Synopsis ===
 
<source lang="lua">
 
<source lang="lua">
PixelEffect:send( name, image )
+
PixelEffect:send( name, image, ... )
 
</source>
 
</source>
 
=== Arguments ===
 
=== Arguments ===
 
{{param|string|name|Name of the Image to send to the pixel effect.}}
 
{{param|string|name|Name of the Image to send to the pixel effect.}}
{{param|Image|image|Image to send to the pixel effect for use as extra data.}}
+
{{param|Image|image|Image to send to the extern.}}
 +
{{param|Image|...|Additional images in case the extern is an array.}}
 
=== Returns ===
 
=== Returns ===
 
Nothing.
 
Nothing.
Line 62: Line 70:
 
=== Synopsis ===
 
=== Synopsis ===
 
<source lang="lua">
 
<source lang="lua">
PixelEffect:send( name, canvas )
+
PixelEffect:send( name, canvas, ... )
 
</source>
 
</source>
 
=== Arguments ===
 
=== Arguments ===
 
{{param|string|name|Name of the Canvas to send to the pixel effect.}}
 
{{param|string|name|Name of the Canvas to send to the pixel effect.}}
{{param|Canvas|canvas|Canvas to send to the pixel effect for use as extra data.}}
+
{{param|Canvas|canvas|Canvas to send to the extern. The pixel effect type is ''Image''.}}
 +
{{param|Image|...|Additional canvases to send to the extern array.}}
 
=== Returns ===
 
=== Returns ===
 
Nothing.
 
Nothing.

Revision as of 13:10, 3 September 2012

Available since LÖVE 0.8.0
This function is not supported in earlier versions.

Sends one or more values to a special (extern) variable inside the pixel effect. Extern variables have to be marked using the extern keyword, e.g.

extern number time;
extern vec2 light_pos;
extern vec4 colors[4];

The corresponding send calls would be

effect:send("number", t)
effect:send("light_pos", {light_x, light_y})
effect:send("colors", {r1, g1, b1, a1},  {r2, g2, b2, a2},  {r3, g3, b3, a3},  {r4, g4, b4, a4})

Function

Synopsis

PixelEffect:send( name, number, ... )

Arguments

string name
Name of the number to send to the pixel effect.
number number
Number to send to store in the extern.
number ...
Additional numbers to send in case the extern is an array.

Returns

Nothing.

Returns

Nothing.

Function

Synopsis

PixelEffect:send( name, vector, ... )

Arguments

string name
Name of the vector to send to the pixel effect.
table vector
Numbers to send to the extern as a vector. The number of elements in the table determines the type of the vector (e.g. two numbers -> vec2). At least two and at most four numbers can be used.
table ...
Additional vectors to send in case the extern is an array. All vectors need to be of the same size (e.g. only vec3's)

Returns

Nothing.

Function

Synopsis

PixelEffect:send( name, matrix, ... )

Arguments

string name
Name of the matrix to send to the pixel effect.
table matrix
2x2, 3x3, or 4x4 matrix to send to the extern. Using table form: {{a,b,c,d}, {e,f,g,h}, ... }
table ...
Additional matrices of the same type as matrix to store in the extern array.

Returns

Nothing.

Function

Synopsis

PixelEffect:send( name, image, ... )

Arguments

string name
Name of the Image to send to the pixel effect.
Image image
Image to send to the extern.
Image ...
Additional images in case the extern is an array.

Returns

Nothing.

Function

Synopsis

PixelEffect:send( name, canvas, ... )

Arguments

string name
Name of the Canvas to send to the pixel effect.
Canvas canvas
Canvas to send to the extern. The pixel effect type is Image.
Image ...
Additional canvases to send to the extern array.

Returns

Nothing.

See Also

Other Languages