Jump to content

Most effective use of many Graphics objects?


allnamesrtaken
 Share

Recommended Posts

Hi,

I have created a nice little top down snow and rain simulator which goes fast in code pen on PIXI v6 but a bit slower on my real project using V5 (for now).

Naturally the project has alot more going on, layers and large images etc. I draw the rain and snow using simple Graphics objects and .drawLine.

For the code pen I seem to be able to scale it to thousands of drops without issue but in my real project it is smooth with like 50 drops but at 500, the snow is smooth but the rest of the interaction events begin to stutter.

I currently just create a Graphics object per drop/flake and add those to the background and set their layers.

Is there a faster way of doing it, such as drawing all the flakes as one large Graphics object with 500 lines, use sprites, shaders  or some other magic chop I can do to relieve the stress?

I use layers to have drops fall on top and splash below among things.

 

Many thanks. 

image.png.2bd069065957064308158097b3dba839.png

Link to comment
Share on other sites

we have new package for graphics with lines: https://github.com/pixijs/graphics-smooth

as for general issue of "there are 500 of them!!!" , that's a big topic. 

Did you by change found any of my explanations regarding "high-level vs low-level algorithms? ? I'm not feeling well enough to post all that again.

Is there a faster way of doing it, such as drawing all the flakes as one large Graphics object with 500 lines, use sprites, shaders  or some other magic chop I can do to relieve the stress?

The best way is if you know how to make mesh geometry that you modify every frame, and shader that does good work on AA and stuff for your elements. If you dont know how to do that - well, you have to use whatever you can :)

500 is not big amount, just put them in our new graphics, clear&refill each frame.

Edited by ivan.popelyshev
Link to comment
Share on other sites

People usually use sprites inside a particleContainer, it has limitations, you need single texture (or texture atlas) for everything, and you have to smooth the texture in image editor, dont rely on webgl AA on edges.

Threre are many ways to solve your case, i dont even know which one to suggest first :)

Edited by ivan.popelyshev
Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...