📜 ⬆️ ⬇️

Textures and RGB channels in Unreal Engine 4

RGB and Unreal Engine


General concepts of RGB channels


RGB (often RGBA ) is an abbreviation for Red-Green-Blue (Alpha) . That means 3 channels of colors, mixing which leads to the transfer of the desired shade of color (If Alpha is used, then an indication of the degree of transparency of an element).

Each channel consists of values ​​from 0 to 255. These values ​​are the channel level. The higher the level, the stronger the color in the channel. Each pixel of the texture (of any image and of your monitor) is displayed in the RGB format - that is, each pixel simultaneously has 3 color channels - each with its own level.

If we see a red pixel, then the channels are green and blue have a level equal to 0.
If green, then red and blue are 0.
If blue, then red and green are 0.

Below, only the red channel is active in the picture, the others have values ​​equal to zero:
')
image

It is worth noting that in the Unreal Engine 4 engine the color values ​​are not 0-255, but from 0 to 1. In fact, this is done for ease of programming, and in fact the channel levels still have values ​​from 0 to 255, only presented within 0-1, where 0 = 0, and 1 = 255. In this case, if sRGB is turned off, the usual linear matching is used, where the value 0.5 will be equal to 128.

Unreal Engine 4 is able to work with all channels simultaneously (transferring a full-fledged color gamut) and with each channel separately.

The image below shows how the color node looks like in the engine:

image

This node does not contain color. This is a set of 4 values ​​- RGBA-channels, which are recorded as floating-point numbers from 0 to 1 each. And you can set in each channel its value and issue it. Color - only the total amount of these values ​​in one pixel.

The first pin from the node is the sum of three channels - RGB.

The second, third and fourth pins are the outputs of each channel, respectively.

The fifth pin is the fourth channel or Alpha channel . As planned and in general, this channel is used to control transparency - what should be transparent, what should not be transparent, and what should be translucent.

In fact, the alpha channel (as a transparency channel) does not exist. This is all the same set of numbers from 0 to 1, so this channel can be replaced freely by any other channel that provides the necessary levels of transparency (levels of values ​​from 0 to 1 in the right pixels).
But. It is worth remembering that the Alpha channel takes up space equal to all three RGB channels. And the cost of its processing is increased by 2 times compared with the processing of any of the RGB channels separately.

Oftop. In general, this node is a vector - a container containing 4 values.

Use of channels in Unreal Engine 4


Typically, the Unreal Engine 4 uses a TARGA type texture. It allows you to work with each channel separately.

In PBR * there are such cards as AO, Metallic, Roughness, Specullar and Emissive (There are a lot of options, but that's enough for us). All of these cards use only values ​​from 0 to 1 (black and white cards). That is, the 1st channel with values ​​from 0 to 1 is enough for the engine to calculate these cards.

For example, Metallic can be either 0 or 1 (either metal or non-metal). Appropriately, a pixel can have the value 1 ( white color in the visual representation) or 0 ( black color in the visual representation).

For example, there is such a texture. In the RGB channel (all three channels together) the following pattern is displayed:

image

If you look at each channel separately, you can see how the textures change - one channel is responsible for Roughness, the second for Specular, the third for AO, the fourth for alpha.

image
image
image
image

The last picture also displays the color scale in Adobe Photoshop, in which no other color can be specified, except for the white gradient (from 0 to 255) when editing in any one channel (in the picture, editing takes place on the Alpha channel).

Accordingly, the texture can now be used to connect to the material Unreal Engine 4 at once by three (or 4) parameters. The "alpha" channel is not necessary to use for transparency - it can also be used as any other texture where you need to specify values ​​from 0 to 1 within one channel.

* PBR - PHYSICALLY BASED RENDERING . Physically correct render (physics based render). Texture display system according to the physical behavior of real light.

Source: https://habr.com/ru/post/329094/


All Articles