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 !
Particles optimization
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Party member
- Posts: 730
- Joined: Sat Apr 26, 2014 7:46 pm
Re: Particles optimization
You can use a particle system or mesh or spritebatches. Each has their own advantages and disadvantages. I would try particle system first.
Re: Particles optimization
Isn't there any kind of canvas so I can use my own pSystem ?
Re: Particles optimization
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.
Another option is to pre-render the effect and draw an animation using textures.
Re: Particles optimization
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.
Re: Particles optimization
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)
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
-
- Party member
- Posts: 730
- Joined: Sat Apr 26, 2014 7:46 pm
Re: Particles optimization
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.
Re: Particles optimization
My bad guys. @ivan was right. Lua seems like it can't handle FOR very well.
Re: Particles optimization
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.
Please post your love file and we'll see if it can be optimized.
- zorg
- Party member
- Posts: 3470
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Particles optimization
Lua thanks you very much, and says it can indeed handle for loops as much as any programming languageMateus wrote:My bad guys. @ivan was right. Lua seems like it can't handle FOR very well.
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 True 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.
Who is online
Users browsing this forum: No registered users and 3 guests