Difference between revisions of "love.graphics.newPixelEffect"

m (info for "effect" function)
(Note placement of origin)
 
(9 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{newin|[[0.8.0]]|080|type=function}}
+
{{newinoldin|[[0.8.0]]|080|[[0.9.0]]|090|type=function|text=It has been renamed to [[love.graphics.newShader]]}}
 
Creates a new PixelEffect object for hardware-accelerated pixel level effects.
 
Creates a new PixelEffect object for hardware-accelerated pixel level effects.
  
Line 13: Line 13:
 
=== Returns ===
 
=== Returns ===
 
{{param|PixelEffect|pixeleffect|A PixelEffect object for use in drawing operations.}}
 
{{param|PixelEffect|pixeleffect|A PixelEffect object for use in drawing operations.}}
 +
 +
== Effect Language ==
 +
Pixel effects are not programmed in Lua, but by using a special effect language instead. The effect language is basically [http://www.opengl.org/sdk/docs/manglsl/ GLSL 1.20] ([http://www.opengl.org/registry/doc/GLSLangSpec.Full.1.20.8.pdf specs]) with a few aliases added for existing types:
 +
 +
{|cellpadding="5"
 +
!GLSL              || Effect language
 +
|-
 +
|float              || number
 +
|-
 +
|sampler2D          || Image
 +
|-
 +
|uniform            || extern
 +
|-
 +
|texture2D(tex, uv) || Texel(tex, uv)
 +
|}
  
 
== Effect Function ==
 
== Effect Function ==
 
=== Synopsis ===
 
=== Synopsis ===
 
<source lang="glsl">
 
<source lang="glsl">
vec4 effect( vec4 color, sampler2D texture, vec2 texture_coords, vec2 pixel_coords )
+
vec4 effect( vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords )
 
</source>
 
</source>
 
=== Arguments ===
 
=== Arguments ===
{{param|vec4|color|The color of the polygon itself. The same as the last [[love.graphics.setColor]] call}}
+
{{param|vec4|color|The drawing color set with [[love.graphics.setColor]].}}
{{param|sampler2D|texture|The texture currently used by the polygon, if it has one.}}
+
{{param|Image|texture|The texture of the image or canvas being drawn.}}
{{param|vec2|texture_coords|The current texture coordinates.}}
+
{{param|vec2|texture_coords|Coordinates of the pixel relative to the texture. The y-axis of canvases are inverted. Coordinates (1,1) would be the top right corner of the canvas.}}
{{param|vec2|pixel_coords|The current pixel coordinates.}}
+
{{param|vec2|screen_coords|Coordinates of the pixel on the screen. Pixel coordinates are not normalized (unlike texture coordinates). (0.5, 0.5) is the bottom left of the screen.}}
 
=== Returns ===
 
=== Returns ===
{{param|vec4|output_color|The color to set the current pixel to.}}
+
{{param|vec4|output_color|The color of the pixel.}}
  
* Note: LÖVE defines the types <code>Image</code> and <code>Texel</code>, which can be used instead of <code>sampler2D</code> and <code>texture2D</code>, respectively.
 
  
 
== See Also ==
 
== See Also ==
Line 34: Line 48:
 
* [[love.graphics.setPixelEffect]]
 
* [[love.graphics.setPixelEffect]]
 
[[Category:Functions]]
 
[[Category:Functions]]
 +
[[Sub-Category::Object Creation| ]]
 
{{#set:Description=Creates a new [[PixelEffect]].}}
 
{{#set:Description=Creates a new [[PixelEffect]].}}
 
== Other Languages ==
 
== Other Languages ==
 
{{i18n|love.graphics.newPixelEffect}}
 
{{i18n|love.graphics.newPixelEffect}}

Latest revision as of 21:50, 27 October 2016

Available since LÖVE 0.8.0 and removed in LÖVE 0.9.0
It has been renamed to love.graphics.newShader.

Creates a new PixelEffect object for hardware-accelerated pixel level effects.

A PixelEffect contains at least one function, named effect, which is the effect itself, but it can contain additional functions.

Function

Synopsis

pixeleffect = love.graphics.newPixelEffect( code )

Arguments

string code
The pixel effect code.

Returns

PixelEffect pixeleffect
A PixelEffect object for use in drawing operations.

Effect Language

Pixel effects are not programmed in Lua, but by using a special effect language instead. The effect language is basically GLSL 1.20 (specs) with a few aliases added for existing types:

GLSL Effect language
float number
sampler2D Image
uniform extern
texture2D(tex, uv) Texel(tex, uv)

Effect Function

Synopsis

vec4 effect( vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords )

Arguments

vec4 color
The drawing color set with love.graphics.setColor.
Image texture
The texture of the image or canvas being drawn.
vec2 texture_coords
Coordinates of the pixel relative to the texture. The y-axis of canvases are inverted. Coordinates (1,1) would be the top right corner of the canvas.
vec2 screen_coords
Coordinates of the pixel on the screen. Pixel coordinates are not normalized (unlike texture coordinates). (0.5, 0.5) is the bottom left of the screen.

Returns

vec4 output_color
The color of the pixel.


See Also


Other Languages