I'm playing around with shaders... the most basic stuff.
I followed
http://blogs.love2d.org/content/beginners-guide-shaders
but the part where the rectangle should be half blue/red (using texture_coords) never worked out..
(my attached example is with a circle, but it doesn't matter, rectangle didn't work out too).
Code: Select all
function love.load()
local shader_code = [[
vec4 effect( vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords ){
if(texture_coords.x > 0.5) {
return vec4(1.0,0.0,0.0,1.0);//red
}
else
{
return vec4(0.0,0.0,1.0,1.0);//blue
}
}
]]
shader = love.graphics.newShader(shader_code)
end
function love.draw()
love.graphics.setShader(shader)
love.graphics.setColor(0,0.3,0)
love.graphics.circle("fill", 500, 10, 200)
love.graphics.setShader()
end
one half red the other blue.
But the part in the tutorial with the screen_coords worked fine.. it gets another color in the defined screen_coords...
Any idea why? Thanks!!