[SOLVED] Gradient shader getting rotated
Posted: Sat Feb 11, 2017 6:32 pm
Hello,
I build this shader for shadow creation purposes. I would like to get it drawn from top to bottom of the texture.
But during the love.graphics.draw() the strite is getting rotated and so the shader result :/
Could you help me to resolve this problem, please?
I would like with any rotated love.graphics.draw() call, a shadow being driven from top to bottom independent from any angle.
I build this shader for shadow creation purposes. I would like to get it drawn from top to bottom of the texture.
But during the love.graphics.draw() the strite is getting rotated and so the shader result :/
Could you help me to resolve this problem, please?
I would like with any rotated love.graphics.draw() call, a shadow being driven from top to bottom independent from any angle.
Code: Select all
function love.load()
myShader = love.graphics.newShader[[
vec4 effect( vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords ){
vec4 pixel = Texel(texture, texture_coords);//This is the current pixel color
pixel.r = pixel.r * texture_coords.y;
pixel.g = pixel.g * texture_coords.y;
pixel.b = pixel.b * texture_coords.y;
return pixel;
}
]]
img = love.graphics.newImage("asteroid_1.png")
angle = 0
end
function love.update(dt)
angle = angle + 0.1 * dt * 5
end
function love.draw()
local imgW, imgH = img:getDimensions()
love.graphics.setShader(myShader) --draw something here
love.graphics.draw(img, love.graphics.getWidth()/2, love.graphics.getHeight()/2, angle, 1, 1, imgW/2, imgH/2)
love.graphics.setShader()
end