Here is 2 formats for pixel shader: 1) with arguments and with return value and 2) without arguments and with love_Canvases assignments. I was developing some shader and switching between those two formats back and forward with commenting some lines. And noticed some strange behavior. Here is simplified situation:
Code: Select all
function love.load()
shader = love.graphics.newShader([[
uniform Image MainTex;
//vec4 effect(vec4 vcolor, Image tex, vec2 texcoord, vec2 pixcoord)
void effect()
{
vec4 texturecolor = Texel(MainTex, vec2(VaryingTexCoord));
love_Canvases[0] = texturecolor * VaryingColor;
love_Canvases[1] = texturecolor * VaryingColor;
}
]])
end
Code: Select all
Error: Error validating pixel shader code:
Line 1: ERROR: 'MainTex' : redefinition
Also, maybe it's not important, but maybe it can be helpful: If I remove MainTex declaration from above script, I will get another error:
That one for love 11.3:
Code: Select all
Error: Error validating pixel shader code:
Line 5: ERROR: 'love_Canvases' : undeclared identifier
Line 5: ERROR: 'love_Canvases' : left of '[' is not of type array, matrix, or vector
Line 5: ERROR: '' : compilation terminated
ERROR: 3 compilation errors. No code generated.
Code: Select all
Error: Cannot compile shader:
ERROR: Linking fragment stage: No function definition (body) found:
effect(vf4;s21;vf2;vf2;
ERROR: Linking fragment stage: Cannot use both gl_FragColor and gl_FragData