Skip to content

Instantly share code, notes, and snippets.

@cigumo
Created December 29, 2017 14:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cigumo/4ca2d034e9ee33c528ce0c8ffb65005d to your computer and use it in GitHub Desktop.
Save cigumo/4ca2d034e9ee33c528ce0c8ffb65005d to your computer and use it in GitHub Desktop.
glsl shader compiler ignores .length() access and removes the variable
local shader
local shader_code = [[
extern vec4 col[2];
vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords)
{
//float dummy = col[0][0];
return vec4(1/col.length(),0,1,1);
}
]]
function love.load(arg)
shader = love.graphics.newShader(shader_code)
end
function love.draw()
love.graphics.setShader(shader)
shader:send('col',{1,0,0,1},{1,0,0,1})
love.graphics.rectangle('fill',0,0,400,400)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment