Version: 2023.1
언어: 한국어
WebGL 브라우저 호환성
WebGL의 오디오

WebGL graphics

WebGL은 웹 브라우저에서 그래픽스를 렌더링하는 API로, OpenGL ES 그래픽스 라이브러리의 기능에 기반을 두고 있습니다. WebGL 1.0은 OpenGL ES 2.0과 기능이 유사하고, WebGL 2.0은 OpenGL ES 3.0과 기능이 유사합니다.

Camera clear

By default, Unity WebGL clears the drawing buffer after each frame, which means the content of the frame buffer clears regardless of the Camera.clearFlags setting. However, you can change this behavior at instantiation time. To do this, set webglContextAttributes.preserveDrawingBuffer to true in your WebGL template:

script.onload = () => {
       config['webglContextAttributes'] = {"preserveDrawingBuffer": true}; // Add this line to the index.html file in a WebGL Template
       createUnityInstance(canvas, config, (progress) => }

Deferred rendering

Unity WebGL only supports Deferred Rendering Path if WebGL2.0 is available. On WebGL 1.0, Unity WebGL runtime falls back to Forward Rendering.

전역 조명

Unity WebGL only supports baked GI. Realtime Global Illumination isn’t currently supported in WebGL. In addition, Unity WebGL supports Non-Directional lightmaps only.

Linear rendering

Unity WebGL은 WebGL 2.0에서만 리니어 색 공간 렌더링을 지원합니다. 리니어 색 공간 렌더링은 WebGL 1.0에 대한 폴백 지원을 제공하지 않습니다. 리니어 색 공간 렌더링을 사용하여 WebGL 플레이어를 빌드하려면 Player 설정에서 WebGL 1.0 API를 제거하고, Other Settings 패널을 열고, Automatic Graphics API 설정을 비활성화하십시오.

일부 웹 브라우저에서는 sRGB DXT 텍스처 압축이 지원되지 않습니다. 따라서 리니어 렌더링을 사용하는 경우 런타임 시점에 모든 DXT 텍스처의 압축을 풀어야 하므로 렌더링 성능이 저하될 수 있습니다.

Video clip importer

You can’t use VideoClipImporter to import video clips to your Unity project, because it might increase the initial asset data download size and prevent network streaming. For video playback, use the URL option in the VideoPlayer component and place the asset in the StreamingAssets/ directory to use the built-in network streaming of your browser.

WebGL shader code restrictions

The WebGL 1.0 specification imposes some limitations on GLSLS shader code, which are more restrictive than most OpenGL ES 2.0 implementations. This is mostly relevant when you write your own shaders.

WebGL has specific restrictions on which values to use to index arrays or matrices. For example, WebGL only allows dynamic indexing with constant expressions, loop indices or a combination, except for uniform access in vertex shaders, which you can index using any expression.

Note for WebGL 1.0: Additional restrictions apply on control structures in WebGL 1.0, where it doesn’t allow while loops and most type of for loops. However, it allows counting for loops, where the field initializer sets a variable to a constant, the update adds a constant to or subtracts a constant from the variable, and the continuation test compares the variable to a constant.

Note: Due to limited available memory in WebGL, you should avoid including unneeded shader variants which can lead to unnecessary memory usage. Therefore, Unity recommends familiarizing yourself with shader variants and shader stripping, and take extra care to ensure that you don’t add shaders with too many variants (for example, Unity’s Standard Shader) to the [Always-included Shaders] section(class-GraphicsSettings#Always) in Graphics Settings.

폰트 렌더링

Unity WebGL supports dynamic font rendering similar to other Unity platforms. However, as it doesn’t have access to the fonts installed on the user’s machine, if you want to use any fonts, make sure to include them in the project folder (including any fallback fonts for international characters, or bold/italic versions of fonts), and set as fallback font names.

안티앨리어싱

WebGL은 거의 대부분의 브라우저 및 GPU 조합에서 안티앨리어싱을 지원합니다. 안티앨리어싱을 사용하려면 WebGL 플랫폼의 기본 품질 설정에서 안티앨리어싱을 활성화해야 합니다.

Reflection probes

Unity WebGL supports all reflection probes. Note: WebGL 1.0 doesn’t support Smooth realtime reflection probes.

WebGL 2.0 지원

Unity에는 WebGL 2.0 API 지원이 포함되어 있어 OpenGL ES 3.0 수준의 렌더링 성능을 웹에서 사용할 수 있습니다.

By default, Unity WebGL builds support the WebGL 2.0 API. You can configure this in the WebGL Player settings > Other Settings panel by disabling the Automatic Graphics API property and adding the WebGL 1.0 API to your project.

Browsers with WebGL 2.0 support have the following advantages:

  • The content in the Standard Shader is of high quality.
  • Support for GPU Instancing and directional lightmap.
  • There’s no restrictions on indexing and loops in shader code
  • Better performance.

런타임 시점에 SystemInfo.graphicsDeviceType을 사용하여 Unity 인스턴스가 OpenGLES3 (WebGL2.0) 또는 OpenGLES2 (WebGL1.0)로 렌더링되는지 확인할 수 있습니다.

Additional resources:


  • Unity 2017.2에서 WebGL 2.0용 리니어 렌더링 추가됨 NewIn20172
WebGL 브라우저 호환성
WebGL의 오디오
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961