Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question GPU instance in WebGL

Discussion in 'Web' started by Stormer2020, Mar 31, 2023.

  1. Stormer2020

    Stormer2020

    Joined:
    Sep 14, 2020
    Posts:
    90
    Hi~

    I use GPU instace and ComputeBuffer&Shader made this:

    100,000 cubes
    111.jpg


    It's amazing! But I cant run it on WebGL.

    I wanna create a voxel terrain or voxel house with GPU Instance.
    If WebGL dose not support ComputeShader and ComputeBuffer, what should I do?
    Is here have any method update GUP instance's position in GPU?
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    4,321
    It should work: https://forum.unity.com/threads/gpu-instancing-webgl.899534/

    It may depend on the render pipeline though. GPU instancing works with a custom shader in legacy render pipeline. That custom shader however has to be compatible with WebGL v2. Compute shaders are not supported in WebGL.

    URP and HDRP however have a concept of batching that's supposed to replace (the need for) GPU instancing. For WebGL you should definitely use URP and also be on the latest Unity tech stream version as any incremental improvement can still make a huge difference in WebGL.

    General advice: anything for WebGL needs to be scaled down by a factor of 10 to 100. Roughly speaking. WebGL is NOT a high-performance platform. It is currently single-threaded with severe restrictions on the rendering side.
     
    OceanX000 and Stormer2020 like this.
  3. Stormer2020

    Stormer2020

    Joined:
    Sep 14, 2020
    Posts:
    90
    Thank you so much!