However, I have a bit of an issue. I can't seem to figure out how to apply shaders to non-image objects, such as circles and rectangles. If I want to make a blurry rectangle, I shouldn't have to make a rectangle image and draw it to the screen using a blurring shader, I should just be able to use a shader on the rectangle drawing function. Am I wrong?
I noticed that the input for the effect() function is an Image. Is there a way to input a rectangle as an image? Here's my code:
Code: Select all
function love.load()
shader2 = love.graphics.newShader[[
vec4 effect(vec4 color, Image texture, vec2 tc, vec2 screen_coords){
vec4 pix = Texel(texture, tc);//This is the current pixel color
pix.a = tc.x+tc.y;
return pix;
}
]]
test = love.graphics.newImage("test.png");
end
function love.draw()
love.graphics.setShader(shader2);
love.graphics.setColor(0, 1, 0, 1);
love.graphics.draw(test, 20, 20);
love.graphics.rectangle("line", 300, 300, 100, 30);
love.graphics.setShader();
end