Source

love-glsl /

Filename Size Date modified Message
extra
platform
src
1.0 KB
282 B
100 B
15.2 KB
2.5 KB
873 B
6.2 KB
WHAT IS THIS I DONT EVEN
------------------------

love-glsl is a fork of LÖVE that adds Pixel Effects (fragment shaders).
Pixel effects alter how everything is colored. You can desaturize, blur,
distort, light (bump-map, ...) and whatever else you might think of.
Using framebuffers you can add powerful post processing to the whole scene.


.--------------------------------------------------------------------------.
| INTERMISSION - INTERMISSION - INTERMISSION - INTERMISSION - INTERMISSION |
'--------------------------------------------------------------------------'
|                                                                          |
| This is - in a different form - part of LÖVE since Version 0.8.0. This   |
| readme contains OUTDATED information.                                    |
|                                                                          |
| If you are in search of documentation, go here:                          |
|                                                                          |
| * http://www.love2d.org/wiki/love.graphics.newPixelEffect                |
| * http://www.love2d.org/wiki/PixelEffect                                 |
|                                                                          |
| If you are looking for usage examples, read this forum thread:           |
|                                                                          |
| * http://www.love2d.org/forums/viewtopic.php?f=4&t=3733                  |
|                                                                          |
| Thanks!                                                                  |
|                                                                          |
'--------------------------------------------------------------------------'
| INTERMISSION - INTERMISSION - INTERMISSION - INTERMISSION - INTERMISSION |
'--------------------------------------------------------------------------'

A QUICK EXAMPLE
---------------
function love.load()
    effect = love.graphics.newPixelEffect [[
        extern number time;
        vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords)
        {
            return vec4((1.0+sin(time))/2.0, abs(cos(time)), abs(sin(time)), 1.0);
        }
    ]]
end

function love.draw()
    -- boring white
    love.graphics.setPixelEffect()
    love.graphics.rectangle('fill', 10,10,790,285)

    -- LOOK AT THE PRETTY COLORS!
    love.graphics.setPixelEffect(effect)
    love.graphics.rectangle('fill', 10,305,790,285)
end

local t = 0
function love.update(dt)
    t = t + dt
    effect:send("time", t)
end


ADDED FUNCTIONS
---------------

supported = love.graphics.hasPixelEffects()
  * returns true if pixel effects are supported

effect = love.graphics.newPixelEffect(filename or code)
  * create a new effect from code or a file

love.graphics.setPixelEffect(effect)
  * apply pixel effect to all images and framebuffers drawn beyond this point

love.graphics.setPixelEffect()
  * turn effects off

effect:send(shader_variable_name, value, ...)
  * send values ("uniforms") to the shader. the following is supported:

    effect:send(var, number)
    effect:send(var, x,y), ..., effect:send(name, x,y,z,w) -- send a vector
    effect:send(var, {x,y,z,w}) -- also sends a vector
    effect:send(var, {{a,b}, {c,d}}), ... -- sends a matrix (up to 4x4 matrices)
    effect:send(var, image) -- sends an Image object ("sampler")
    effect:send(var, framebuffer) -- sends a Framebuffer object (also a "sampler")


EFFECT LANGUAGE
---------------

Essentially GLSL 1.2 (specified here: http://www.opengl.org/registry/doc/GLSLangSpec.Full.1.20.8.pdf)

BUT:
Instead of writing your own main() function, you define a special function
that returns the pixel color. The prototype of that function is

  vec4 effect(vec4 global_color, Image texture, vec2 texture_coords, vec2 pixel_coords);

`global_color'    is the color set with love.graphics.setColor().
`texture'         is contains pixel colors if the effect is applied to an image
                  or framebuffer.
`texture_coords'  are the texture coordinates of the current pixel (0 <= x,y <= 1)
`pixel_coords'    are the coordinates of the pixel (0 <= x,y <= WIDTH,HEIGHT)

There are a few keyword mappings to make things less scary:

GLSL              | Effect language     | Comment
------------------+---------------------+--------------------------------------
float             | number              |
sampler2D         | Image               | LÖVE only supports 2D textures anyway
uniform           | extern              | less technical term
texture2D(tex,st) | Texel(tex,st)       | `tex' is an image, `st' is a vec2


.oO Things not to do:
 * Define a function called `main()' (because it's already there).
 * Use any of the keywords, function names and special variable names defined
   in the GLSL document from above as variable names. Especially anything that
   begins with `gl_'.
 * Expecting meaningful error messages if shader compilation fails.
 * Forget to put a semicolon (;) at the end of every statement.



now back to the original readme:

LÖVE is an *awesome* framework you can use to make 2D games in Lua. It's free, open-source, and works on Windows, Mac OS X and Linux.

RUNNING GAMES
-------------

In Windows or other graphical enviroments, just open the .love file you want to 
run with the love binary, such as love.exe. (~^-^)~

In a console, type "love" followed by the relative or absolute path to a directory 
(or archive).

Examples: 

* love mygame.love
* love /home/hax/ultragame

Remember that what you are trying to run at least should contain the file "main.lua". 

Compilation
-----------

Windows:
	Use the project files for Visual C++ 2008 or 2010 (2010 preferred) located in the platform dir.
*nix:
	Run platform/unix/automagic, then run ./configure and make.
OSX:
	Use the XCode project in platform/macosx.


! WARNING ! 
-----------

This software is not complete. This is just a preview. Don't expect to find any 
interface consistencies between releases at all. With each release, everything 
you once knew and loved may be brutally murdered. By which I mean removed and/or 
changed.