Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Question Galaxy simulator in unity webgl possible?

Discussion in 'Web' started by dansav, Oct 11, 2023.

  1. dansav

    dansav

    Joined:
    Sep 22, 2005
    Posts:
    510
    I want to duplicate this galaxy simulator in unity webgl.

    Here's the three.js webgl project
    https://github.com/andrewdcampbell/galaxy-sim

    It currently is built in three.js and uses about 28000 particles if I'm reading the init.js file correctly. As a start I was thinking I would just instantiate 20,000 quads with a billboard shader and gpu instancing and control their positions with an equation, but so far my experiments struggle with 1000 particles. Why is three.js able to handle this and unity webgl not able to handle it?

    Also I've seen some webgl demos with 100,000 particles. Unity seems to choke even in the editor if I use their built in particle system with 50K particles gpuinstancing etc, the frame rate drops to a few per second on a 2019 macbook pro.
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    7,263
    You are testing this with URP? If not, do so. Built-in renderer is a massive churn for webgl.
    You should also look into GPU instancing. Not sure if WebGL supports this though.

    The demo might be using a shader to render the particles. It may also be using multithreaded code to speed up the gravity calculations. However Unity currently only supports native (C++) multithreading for WebGL.

    It also appears to use render scale until you hit 'L'.