What is more efficient when rendering a checkerboard is it a shader or a love.graphics.rectangle + love.graphics.setColor? (assuming its animated.)
Judging from the way the shader works (performing a function per pixel.) the shader would immediately seem to be the most expensive since we are performing a function per pixel involving a range calculation.
When we render squares (pseudo-code):
Or at least how I think love.graphics.rectangle is rendered internally.
For each frame:
Code: Select all
setShader(default) uploadOrthoViewport() bindRectangleBuffer() for height and width do sendColorToShader(default,color1 or color2) drawBuffer() end bindBuffer() setShader()
We are sending data to the GPU here (shader) which acts like a server with our application as the client, this transmission of data is quite expensive however we are only sending vec4 of color.
I assume this is not instanced so this counts as an OpenGL draw call which is quite expensive once again since we need to tell the GPU to draw a shape.
Does the cost of sending the data to the shaders (color and draw calls) for width x height cost more than switching the shader minus the cost of switching back (uploading viewport)?
I know that this perhaps fits more on a OpenGL forum but I think its necessary to ask here as I am not 100% sure if love2d does or doesn't do a few things... Things like instancing love.graphics.rectangle and such.
Edit: Oh whoops! Forgot to add a love file (Oh and this is a quick mockup, don't run it for too long.):