Issue #99 resolved

GLSL shaders

created an issue

I would like to be able to program shaders with love to make things like blur, gloom and normal mapping possible. A starting point is here:

Comments (3)

  1. vrld reporter

    Interface proposal:

    Query capabilities:

    status  =
    version =


    shader =  -- create new shader object
    shader:addCode(type, glsl_code)     -- add and compile code. type is "fragment" or "vertex"
    shader:compile()                    -- link shader. may throw an error.

    To combine these steps, deploy a helper:

    -- in scripts/graphics.lua
    local __newShader =
        assert( type(sources) == "table", "Invalid argument" )
        local shader = __newShader()
        for i,s in pairs(sources) do
        return shader
    -- usage: shader ={
    --                        {'fragment', lib_code},
    --                        {'fragment', main_code},
    --                        {'vertex', more_code} }

    Get compiler/linker warnings:

    log = shader:infolog()

    Attach/detach shader: -- use shader on the following commands       -- don't use any shader

    Uniform and sampler access:

    shader:setUniform(varname, [type], u1, u2, u3, u4) -- type is optional, defaults to float.
                                                       -- if u2 to u4 are omitted, the uniform
                                                       -- is a float/int, else a vec2, vec3 or vec4
    shader:setMatrix(varname, rows, cols, m1, ..., mk) -- k = rows * cols
    shader:setSampler(varname, image, [texture-unit])  -- texture-unit defaults to 1 to not
                                                       -- overwrite the currently active texture
    u1, ..., u16 = shader:getUniform(varname, [type])  -- type defaults to float

    In addition to that, some shaders could be bundled with love, e.g.:

    • blur
    • bloom
    • desaturate/hsv color shift
    • colorize
    • edge detection
  2. Log in to comment