Отличия между GLES2 и GLES3

Эта страница описывает различия между GLES2 и GLES3 по дизайну а не в результате ошибок. Существует и много непреднамеренных различий, но о них нужно сообщить как об ошибках.

Примечание

"GLES2" и "GLES3" это имена используемые в Godot для двух базирующихся на OpenGL движка отрисовки. В терминологии графических API, движок GLES2 представляет OpenGL 2.1 на десктопе, OpenGL ES 2.0 на мобильных платформах и WebGL 1.0 в вэбе. Движок GLES3 - это OpenGL 3.3 на десктопе, OpenGL ES 3.0 на мобильных платформах и WebGL 2.0 в вэбе.

Частицы

В GLES2 нельзя использовать ноды Particles или Particles2D так как им требуется продвинутые возможности GPU. Вместо них, используйте CPUParticles или CPUParticles2D которые предоставляют похожий интерфейс для ParticlesMaterial.

Совет

Particles и Particles2D могут быть сконвертированы в эквивалент на CPU через опцию "Convert to CPUParticles" в редакторе.

SCREEN_TEXTURE mip-maps

В GLES2, SCREEN_TEXTURE (доступно через ShaderMaterial) не содержит вычисленных мип-карт. Так что при доступе к другому LOD, текстура не будет выглядеть сглаженной.

DEPTH_TEXTURE

Хотя GLES2 поддерживает DEPTH_TEXTURE в шейдерах, это может не работать на некоторых старых аппаратных средствах (особенно мобильных).

Цветовое пространство

GLES2 и GLES3 находятся в разных цветовых пространствах. Это означает, что цвета между ними будут немного отличаться, особенно при использовании освещения.

Если ваша игра будет использовать как GLES2, так и GLES3, вы можете использовать оператор if для проверки, является ли вывод sRGB, используя OUTPUT_IS_SRGB. OUTPUT_IS_SRGB имеет значение true в GLES2 и false в GLES3.

HDR

GLES2 не способен использовать функции рендеринга с высоким динамическим диапазоном (HDR). Если HDR установлен для вашего проекта или для данного видового экрана, Godot все равно будет использовать низкий динамический диапазон (LDR), который ограничивает значения видового экрана диапазоном 0-1.

Свойство Viewport Debanding и связанные с ним настройки проекта также не будут иметь эффекта, если HDR отключен. Это означает, что дебандинг не может быть использован в GLES2.

Особенности SpatialMaterial

В GLES2, следующие продвинутые возможности отрисовки отсутствуют в SpatialMaterial:

  • Преломление (рефрацкция)

  • Subsurface scattering (Подповерхностное рассеяние)

  • Анизотропия

  • Прозрачное покрытие

  • Depth mapping (Глубин-маппинг)

При использовании SpatialMaterials они даже не появятся в редакторе.

В пользовательских ShaderMaterials, вы можете установить значения для этих функций, но они будут нефункциональны. Например, вы все еще сможете установить встроенное значение SSS (которое обычно добавляет подповерхностное рассеивание) в вашем шейдере, но ничего не произойдет.

Особенности окружающей среды

В GLES2 отсутствуют следующие возможности в Environment:

  • Автоматическая экспозиция

  • Тонирование

  • Отражения в пространстве экрана

  • Окружающая окклюзия в пространстве экрана

Это означает, что в среде GLES2 вы можете только установить:

  • Небо (включая процедурное небо)

  • Окружающий свет

  • Туман

  • Глубина резкости

  • Сияние (также известное как блюм)

  • Регулировка параметров цвета

GIProbes

GIProbes do not work in GLES2. Instead use Baked Lightmaps. For a description of how baked lightmaps work see the Baked Lightmaps tutorial.

Contact shadows

The shadow_contact property of Lights is not supported in GLES2 and so does nothing.

Light performance

In GLES2, performance scales poorly with several lights, as each light is processed in a separate render pass (in opposition to GLES3 which is all done in a single pass). Try to limit scenes to as few lights as possible in order to achieve greatest performance.

Texture compression

On mobile, GLES2 requires ETC texture compression, while GLES3 requires ETC2. ETC2 is enabled by default, so if exporting to mobile using GLES2 make sure to set the project setting rendering/vram_compression/import_etc and then reimport textures.

Предупреждение

Since ETC doesn't support transparency, you must reimport textures that contain an alpha channel to use the Uncompressed, Lossy or Lossless compression mode (instead of Video RAM). This can be done in the Import dock after selecting them in the FileSystem dock.

Blend shapes

In GLES2, blend shapes are implemented on the CPU instead of the GPU. Accordingly, they may not perform as well as blend shapes in GLES3. To avoid performance issues when using blend shapes in GLES2, try to minimize the number of blend shapes that are updated each frame.

Язык шейдеров

GLES3 provides many built-in functions that GLES2 does not. Below is a list of functions that are not available or are have limited support in GLES2.

For a complete list of built-in GLSL functions see the Shading Language doc.

Функция

vec_type modf ( vec_type x, out vec_type i )

vec_int_type floatBitsToInt ( vec_type x )

vec_uint_type floatBitsToUint ( vec_type x )

vec_type intBitsToFloat ( vec_int_type x )

vec_type uintBitsToFloat ( vec_uint_type x )

ivec2 textureSize ( sampler2D_type s, int lod )

See workaround below

ivec2 textureSize ( samplerCube s, int lod )

See workaround below

vec4_type texture ( sampler_type s, vec_type uv [, float bias] )

bias not available in vertex shader

vec4_type textureProj ( sampler_type s, vec_type uv [, float bias] )

vec4_type textureLod ( sampler_type s, vec_type uv, float lod )

Only available in vertex shader on some hardware

vec4_type textureProjLod ( sampler_type s, vec_type uv, float lod )

vec4_type textureGrad ( sampler_type s, vec_type uv, vec_type dPdx, vec_type dPdy )

vec_type dFdx ( vec_type p )

vec_type dFdy ( vec_type p )

vec_type fwidth ( vec_type p )

Примечание

Functions not in GLES2's GLSL were added with Godots own shader standard library. These functions may perform worse in GLES2 compared to GLES3.

textureSize() workaround

GLES2 does not support textureSize(). You can get the size of a texture the old fashioned way by passing in a uniform with the texture size yourself.

// In the shader:
uniform sampler2D textureName;
uniform vec2 textureName_size;
# In GDScript:
material_name.set_shader_param("textureName", my_texture)
material_name.set_shader_param("textureName_size", my_texture_size)

Built in variables and render modes

Godot also provides many built-in variables and render modes. Some cannot be supported in GLES2. Below is a list of built-in variables and render modes that, when written to, will have no effect or could even cause issues when using the GLES2 backend.

Variable / Render Mode

ensure_correct_normals

INSTANCE_ID

DEPTH

ANISOTROPY

ANISOTROPY_FLOW

SSS_STRENGTH