I'm using shaders in my game (very fun by the way!) but I noticed something unexpected... whenever I use love.graphics.setShader(shader_1), whatever is drawn replaces the love.graphics.setColor to basic white. Here is the code for my shader:
Code: Select all
shader_1 = love.graphics.newShader[[
extern number mouse_x = 0;
extern number mouse_y = 0;
vec4 effect( vec4 color, Image texture, vec2 tex_coordinates, vec2 scrn_coordinates ){
if(pow((scrn_coordinates.x - mouse_x), 2) + pow((scrn_coordinates.y - mouse_y), 2) < pow(200, 2)){
return vec4(0.0, 0.0, 0.0, 0.0);
}
else{
return Texel(texture, tex_coordinates);
}
}
]]
And here is the code that I use the shader with:
Code: Select all
local function draw_world()
love.graphics.setShader(shader_1)
love.graphics.setColor(0, 0, 255)
love.graphics.draw(graphics.background, 0, 0) -- Expecting a BLUE colored background
love.graphics.setColor(0, 255, 0)
love.graphics.draw(graphics.enemy, 0, 0) -- Expecting a GREEN colored enemy
love.graphics.setShader()
love.graphics.setColor(255, 0, 0)
love.graphics.draw(graphics.player, 100, 0) -- Got a RED colored player
end