Shader affecting love.graphics.setColor?
Posted: Sun Jul 03, 2016 1:59 am
Hello all,
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:
What this shader does is it looks for the pixels around the mouse and does NOT draw them (revealing the background color of the game).
And here is the code that I use the shader with:
The shader works as expected EXCEPT it ignores my love.graphics.setColor functions, and always set the color to (255, 255, 255). Is there a way around this? It's important for the color to be changing even while the shader is active.
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