also, id like to know if the 3 lines in shader local
gl_send = glsl.send
local q = love.graphics.polygon
local setShader = love.graphics.setShader
have any value over typing what they contain directly.
then, id like to know if the whole thing being a module has any advantage or not (i did few modifications such as removing possible settings etc. to prevent unnecessar if processes at least, and now im striving for best optimization possible).
**this is all that remains
Code: Select all
local gl_send = glsl.send
local q = love.graphics.polygon
local setShader = love.graphics.setShader
module(...)
function quad(img,v1,v2,v3,v4,p0,rep,col)
gl_send( glsl,"img",img )
gl_send( glsl,"v1",v2 )
gl_send( glsl,"v2",v3 )
gl_send( glsl,"v3",v4 )
gl_send( glsl,"v4",v1 )
gl_send( glsl,"p0",p0 )
gl_send( glsl,"rep",rep )
gl_send( glsl,"col",col )
q( "fill",v1[1],v1[2],v2[1],v2[2],v3[1],v3[2],v4[1],v4[2] )
end
function on()
setShader( glsl )
end
function off()
setShader()
end
*reason for p0 and rep being included and sent each time is that i will be using mostly partial cuts from textures, so id need to do so anyway. everything else is currently garbage.
also i noticed that "fast" function is not just a bit faster, but if shader is called thousands of times in single batch on stress test, it could decrease cpu usage even by 20% or so.
i also further modified the shader itself after testing. now i also supply "col" in format {0,0,0,0} to {1,1,1,1} and changed last line of shader to:
Code: Select all
return Texel(img,mod(uv*rep+vec2(p0.x-1,p0.y),one))*col;
("color" is completely deleted)
which allows me to manipulate colors and alpha of texture color instead of transparent parts ( if i dont want it transparent i wont make it so, but when i want to do overlay like glowing part with controlled color based on team color i need this function, also things like partially transparent texture darkening based fake global light and wall angle while keeping transparent parts untouched would be otherwise impossible)