Created
December 29, 2017 14:36
-
-
Save cigumo/4ca2d034e9ee33c528ce0c8ffb65005d to your computer and use it in GitHub Desktop.
glsl shader compiler ignores .length() access and removes the variable
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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