Particles optimization

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Mateus
Prole
Posts: 42
Joined: Sat Apr 04, 2015 1:02 pm

Particles optimization

Post by Mateus »

Hey, simple question.

How do I optimize my program to be able to draw like 50000 particles without problem ? Is it even possible ?
(50000 love.graphics.circle)

Thanks !
bobbyjones
Party member
Posts: 730
Joined: Sat Apr 26, 2014 7:46 pm

Re: Particles optimization

Post by bobbyjones »

You can use a particle system or mesh or spritebatches. Each has their own advantages and disadvantages. I would try particle system first.
Mateus
Prole
Posts: 42
Joined: Sat Apr 04, 2015 1:02 pm

Re: Particles optimization

Post by Mateus »

Isn't there any kind of canvas so I can use my own pSystem ?
User avatar
ivan
Party member
Posts: 1911
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Particles optimization

Post by ivan »

Apart from the drawing, if Lua code is used to move each individual particle then there are obvious CPU constraints.
Another option is to pre-render the effect and draw an animation using textures.
Mateus
Prole
Posts: 42
Joined: Sat Apr 04, 2015 1:02 pm

Re: Particles optimization

Post by Mateus »

ivan wrote:Apart from the drawing, if Lua code is used to move each individual particle then there are obvious CPU constraints.
Another option is to pre-render the effect and draw an animation using textures.

Everything is fine until I try to draw them.
User avatar
Evine
Citizen
Posts: 72
Joined: Wed May 28, 2014 11:46 pm

Re: Particles optimization

Post by Evine »

You might be able to get away with just using love.graphics.points(). So look if that suits your needs. Otherwise look into spritebatches.

The process of spritebatches would go something like this.
-- Draw the various sizes of love.graphics.circle() you want to a canvas. love.graphics.newCanvas()
-- Split the different images on the canvas with love.graphics.newQuad() , (Not needed if you only do 1 size)
-- Create a Spritebatch with the texture. love.graphics.newSpriteBatch()
-- Position the particles with SpriteBatch:add().
-- Draw all particles with love.graphics.draw(Spritebatch)
Artal, A .PSD loader: https://github.com/EvineDev/Artal
bobbyjones
Party member
Posts: 730
Joined: Sat Apr 26, 2014 7:46 pm

Re: Particles optimization

Post by bobbyjones »

Evine wrote:You might be able to get away with just using love.graphics.points(). So look if that suits your needs. Otherwise look into spritebatches.

The process of spritebatches would go something like this.
-- Draw the various sizes of love.graphics.circle() you want to a canvas. love.graphics.newCanvas()
-- Split the different images on the canvas with love.graphics.newQuad() , (Not needed if you only do 1 size)
-- Create a Spritebatch with the texture. love.graphics.newSpriteBatch()
-- Position the particles with SpriteBatch:add().
-- Draw all particles with love.graphics.draw(Spritebatch)

He could just use one white circle I believe. And just scale and color it.
Mateus
Prole
Posts: 42
Joined: Sat Apr 04, 2015 1:02 pm

Re: Particles optimization

Post by Mateus »

My bad guys. @ivan was right. Lua seems like it can't handle FOR very well.
User avatar
ivan
Party member
Posts: 1911
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Particles optimization

Post by ivan »

Mateus, Lua and LuaJit are quite fast compared to most scripting languages.
Please post your love file and we'll see if it can be optimized.
User avatar
zorg
Party member
Posts: 3444
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Particles optimization

Post by zorg »

Mateus wrote:My bad guys. @ivan was right. Lua seems like it can't handle FOR very well.
Lua thanks you very much, and says it can indeed handle for loops as much as any programming language :3
All sillyness aside, modifying 50 000 objects every tick may be too much work, so if i may be so premature as to suggest that somehow cutting down the number would be the #1 solution to this issue, if that's a route you can take.
That said, if you post your code, then as ivan said, other alternatives may reveal themselves.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Post Reply

Who is online

Users browsing this forum: No registered users and 75 guests