Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

Texture blit shaders

Texture blit shaders are used to define the behavior of blit calls on a DrawableTexture2D.

Texture blit shaders only have one processing function, the blit() function, which runs for every pixel of the source texture inside the rect given to blit_rect().

См. также

See Using DrawableTextures for more information on how to use texture blit shaders as part of a DrawableTexture.

Режимы визуализации

Режим рендеринга

Описание

blend_disabled

Disable blending, values (including alpha) are written as-is. Default.

blеnd_mix

Mix blend mode (alpha is transparency).

blеnd_add

Аддитивный режим наложения.

blеnd_sub

Режим наложения с вычитанием.

blеnd_mul

Режим наложения с умножением.

Примечание

There is no premultiplied alpha blend mode for Texture blit shaders.

Встроенные функции

Значения, отмеченные как in, доступны только для чтения. Значения, отмеченные как out, могут быть записаны и не обязательно содержат осмысленные значения. Значения, отмеченные как inout, предоставляют осмысленное значение по умолчанию и могут быть записаны. Сэмплеры не могут быть записаны, поэтому они не отмечены.

Глобальные встроенные функции

Глобальные встроенные функции доступны везде, в том числе и в пользовательских функциях.

Встроенный

Описание

в плавающем TIME

Глобальное время с момента запуска движка в секундах. Повторяется каждые 3,600 секунд (это можно изменить с помощью параметра rollover). На него влияет time_scale, но не пауза. Если вам нужна переменная TIME, не зависящая от масштаба времени, добавьте свою собственную глобальную униформу шейдера и обновляйте её каждый кадр.

в float PI

Константа PI (3.141592). Отношение длины окружности к её диаметру и количество радиан в полуобороте.

в float TAU

A TAU constant (6.283185). An equivalent of PI * 2 and amount of radians in full turn.

В float E

An E constant (2.718281). Euler's number and a base of the natural logarithm.

Blit built-ins

Source textures

Texture blit shaders have up to 4 source textures bound as inputs. These can be accessed with a sampler2D using hint_blit_source0, hint_blit_source1, hint_blit_source2, and hint_blit_source3.

Встроенный

Описание

vec4 FRAGCOORD

Coordinate of pixel center. In screen space. xy specifies position in viewport. Upper-left of the viewport is the origin, (0.0, 0.0).

vec2 UV

UV from the vertex() function. This is set to sample all of a source texture.

in vec4 MODULATE

MODULATE color passed in by RenderingServer API.

out vec4 COLOR0

Output color to blended with the DrawableTexture target. Initialized to (0.0, 0.0, 0.0, 0.0).

out vec4 COLOR1

Output color to blended with an extra DrawableTexture target. Initialized to (0.0, 0.0, 0.0, 0.0).

out vec4 COLOR2

Output color to blended with an extra DrawableTexture target. Initialized to (0.0, 0.0, 0.0, 0.0).

out vec4 COLOR3

Output color to blended with an extra DrawableTexture target. Initialized to (0.0, 0.0, 0.0, 0.0).