Skip to content

WebGL2.0 Rendering Support ​

Suitable Use Cases ​

WebGL is an API for rendering graphics in web browsers, based on the functionality of the OpenGL ES graphics library. WebGL 1.0 roughly matches OpenGL ES 2.0 functionality, while WebGL 2.0 roughly matches OpenGL ES 3.0 functionality. Based on game project statistics, we find that compared with WebGL1, it is more suitable for the following game needs:

  • Linear color space rendering
  • Using GPU Instancing to improve rendering performance
  • Using SRP Batcher to improve rendering performance
  • Using URP PostProcessing effects to improve quality
  • The presence of many Shaders that depend on OpenGL ES 3.0+ and are hard to downgrade

User Share ​

Many of Unity WebGL's rendering optimization features depend on WebGL2.0, so here we need to further explain the support of this feature in the minigame environment.

  • The minigame Android platform supported WebGL2 in 8.0.24 (the mid-2022 version), with a user share > 85% (2022.12); for the latest share, please refer to the base library version distribution.
  • The minigame iOS High Performance mode requires iOS system version >= 15.0, with a user share > 75% (2022.12)
  • The minigame High Performance+ mode can support WebGL2 for users on iOS system version >= 14.0

Known Compatibility Issues ​

  • Using WebGL2 in iOS High Performance mode has quite a few issues; the platform does not currently guarantee that all capabilities are complete, so developers must verify the support of the features their game uses.
  • For WebGL2, High Performance+ mode has better compatibility.

If you encounter problems, please contact us for detailed investigation.

Model Flickering When GPU Instance Is Enabled in iOS High Performance Mode ​

Cause: iOS WebKit has issues with WebGL2 support; when there are too many uniform variables, phenomena such as incorrect drawing, no drawing, and reduced efficiency occur.

Solution:

  • Reduce the size of Instance Props in the shader;

  • Add the instancing_options option in the shader (refer to the Unity official documentation for details)

  • assumeuniformscaling: When enabled, object scaling defaults to uniform scaling, and uniform can reduce the size by sizeof(mat4x4) * instance count

  • forcemaxcount:batchSize: Limits the number of instances per draw call

  • Grade by device model, and use the GPU instance feature or batch processing (it is known that iPhone7p and below models require the instance count to be further limited)

DrawMeshInstanced Display Corruption in iOS High Performance Mode ​

Cause: iOS WebKit has issues with WebGL2 support; display errors occur when the batch is large

Solution:

On iOS, reduce the matrices and count parameters of DrawMeshInstanced to 32 or a smaller value