UE4 Shader common function study notes

Add: shortcut key a

Add two numbers or two textures, as shown below:


append:


Subtract:

The opposite of addition, special case, as follows:


Abs (absolute value):

Commonly used algorithms in mathematics, also applicable to multi-dimensional


Multiply: shortcut key m

Commonly used algorithms in mathematics

covered with a layer of pink

Countermultiplication 

2 multiplies each bit, and the same goes for extending to more dimensions

Two dimensions cannot be multiplied by three dimensions 


Divide (except): shortcut key d

Opposite of multiplication


Clamp (data limit):

The minimum value passed out is Min and the maximum value is Max. If it is smaller than Min, it is Min, and if it is larger than Max, it is Max. As shown in the figure below, each number in three dimensions is neither less than 0.3 nor greater than 0.6.


Time (cycle):

The period of change is also one second, and the value is between 0-1


Lerp (interpolation): shortcut key L

Change within the range of 0.5-1

Interpolation blending of Figures 1 and 2 


Floor (rounded up) 


Ceil (rounded down)


LinearGradient (gradient of gradient effect 0-1):

Equivalent to [ 0, 0.1 ), multiply them by 10, and the final values ​​are all less than 1. Round down, then the values ​​of [ 0, 0.1 ) are all 0 when multiplied by 10, which is also zero, so [ 0, 0.1 ) The range of is all black. When [ 0.1, 0.2 ), multiply them by 10, and the values ​​are greater than or equal to 1 and less than 2. Round down, then the range of [ 0.1, 0.2 ) is all 1, and then divide by 10, so the values ​​in the range [0.1, 0.2) are all 0.1, and the colors in this range are all 0.1, and so on...


DiamondGradient (outward gradient):


Frac (take decimal):


Fmod (remainder)


TextureCoordinate (picture texture adaptation):

U stands for horizontal direction, V stands for vertical direction. U equal to 2 is equivalent to extending the size of two pictures horizontally into one plane, and being n is equivalent to putting the size of n pictures into one plane.


mask:

Checked channels represent channels that need to be displayed, and channels that are not checked will not be displayed.


if (conditional judgment): shortcut key i

If A is greater than B, then the value output is 0.1. If A is equal to B, the value output is 0.2. If A is less than B, the value output is 0.3.

In two dimensions, X, Y, and Z are compared in sequence. As long as AX is greater than BX, Y and Z do not need to be compared, and the value of A>B is directly output. The same is true for Y and Z.

The same applies to multi-dimensional


Fresnel (rim light):

The larger the Exponent (attenuation effect) value: the larger the black radius, the less white 

Base Reflect Fraction In (controlling the specular reflection effect): The overall effect is whiter, but there is no edge whiteness

pink to blue mix 


Different colors appear according to the camera position, as shown below:


In the same way, Object Position changes the color according to the position of the Object, as shown below:

Objects use the same material, but their positions and colors are different.


Camera Vector: According to the different positions of the camera, look at the different cropped parts of the picture, as shown below:

The picture looks like this


Pixel Depth: 

Different colors are displayed according to the distance between each pixel of the Texture and the player. Usually this node is used to make fog. If the distance is close, the fog will be lighter, and if the distance is far away, the weapon will be thicker.


Pixel Normal (calculate color based on normal):

Each corner is a normal. If there is a normal, the color changes.


Pixel Depth Offset:

Colors are not blended, if you add pixel depth offset:

An offset operation on pixels

 

Guess you like

Origin blog.csdn.net/qqQQqsadfj/article/details/128469419