I wondered how the texture from Texts are created because I tried to apply a really basic shader on a text and it's a total mess.
It applies as intended on an image
https://prnt.sc/lfoddt
The same shader is applied to the text and image
I'm using love 11.1
Code: Select all
function love.load()
img = love.graphics.newImage("img.png")
myShader = love.graphics.newShader[[
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,Texel(texture, texture_coords).a);//red
}
else
{
return vec4(0.0,0.0,1.0,Texel(texture, texture_coords).a);//blue
}
}
]]
f = love.graphics.newFont("font.ttf" )
t = love.graphics.newText(f, "It will probably not working")
end
function love.draw()
love.graphics.setShader(myShader)
love.graphics.draw(img, 300, 200, 0, 5, 5)
love.graphics.draw(t, 300, 400)
love.graphics.setShader()
end