Multiple Shader and specifically a Moonshine obeservation
Posted: Sat Aug 29, 2020 1:57 pm
Hi,
I was doing some quick and simple performance type testing with Love to see if I wanted to move forward with it. I was playing around with shaders and in particular, the Moonshine lua code.
My test simulates 10,000 objects being drawn on each loop. The performance looks great when I place my drawing code within the moonshine effects shader function, but if I have my loop outside,(which think is more likely for an actual game) it comes to a standstill. I can see that Moonshine is chaining together 1 or more shaders and is using buffers and canvases in the background. My question is...In love2d shader world, is it expected that I draw all of my gameObjects that require a particular shader within their own loop? If so, this would obviously affect the design of the gameObject storage structure. Here's my code. The "outside" loop is commented out for now. Even the 20 iterations brings the program down to 10 FPS. Otherwise, the 10,000 loop stays at 60fps. Thanks for any insight.
I was doing some quick and simple performance type testing with Love to see if I wanted to move forward with it. I was playing around with shaders and in particular, the Moonshine lua code.
My test simulates 10,000 objects being drawn on each loop. The performance looks great when I place my drawing code within the moonshine effects shader function, but if I have my loop outside,(which think is more likely for an actual game) it comes to a standstill. I can see that Moonshine is chaining together 1 or more shaders and is using buffers and canvases in the background. My question is...In love2d shader world, is it expected that I draw all of my gameObjects that require a particular shader within their own loop? If so, this would obviously affect the design of the gameObject storage structure. Here's my code. The "outside" loop is commented out for now. Even the 20 iterations brings the program down to 10 FPS. Otherwise, the 10,000 loop stays at 60fps. Thanks for any insight.
Code: Select all
local moonshine = require 'moonshine'
function love.load()
success = love.window.setFullscreen(true)
effect = moonshine(moonshine.effects.glow)
.chain(moonshine.effects.godsray)
ring = love.graphics.newImage("ring.png")
end
function love.update()
if love.keyboard.isDown("space") then
love.event.push('quit')
end
end
function love.draw()
fps = love.timer.getFPS()
-- for i=1,20 do
effect(function()
for i=1,10000 do
love.graphics.setColor(.2, .2, .7, 1)
number = love.math.random(1,1000);
love.graphics.draw(ring, number,number,math.rad(0), 1,1)
end
end)
-- end
love.graphics.print(fps, 2, 2)
end