Right-click the Create menu in the Assert window and select Shader BluePrint to create a blueprint file.
When the blueprint file is not opened, the Shader file corresponding to the blueprint file is not created; the Shader file is created only when the blueprint file is opened, completing the mapping between the blueprint and Shader.
Picture 1-1
Figure 1-2
- Blueprint file Inspector window
- Blueprint Params window
- Blueprint file Pass window
- Blueprint preview window
Common Shader properties:
- NormalWS
The world normal calculates the lighting results of each vertex in world coordinates.
- alphaTest
After the AlphaTest switch is enabled, Shader uses the value of alphatest to determine whether to discard the pixel.
- AlbedoColor
Surface color (excluding lighting)
- Metallica
Metallicity, a value that describes the metallic properties of an object, actually controls the extent to which a surface is like "metal". For a pure surface, the value of metallicity may be 0 or 1. Most objects in reality are actually somewhere between this. between intervals
- Smoothness
Smoothness describes the smoothness of an object. It can usually be determined based on the blur or clarity of reflection or the breadth or density of specular reflection highlights.
- Occlusion
Ambient Occlusion Parameters, Ambient Occlusion is an effect that approximates the attenuation of light due to occlusion, a subtle representation that makes corners, crevices darker to create a more natural, realistic look
- Emission
Self-illuminating color
- Anisotropy
Anisotropic parameters, increase the number of samples to supplement the details displayed on the model
- Alpha
Transparency, if the TRANSPARENT rendering mode is selected, different transparency levels will be selected based on the Alpha value.
Figure 2-1 shows the fragment shader content where the PBR material type is a Shader Blueprint.
Figure 2-1
NormalWS
The world normal calculates the lighting results of each vertex in world coordinates.
AlphaTest
After the AlphaTest switch is enabled, Shader uses the value of alphatest to determine whether to discard the pixel.
Color
base color
Alpha
Transparency, if TRANSPARENT rendering mode is selected, different transparency levels will be selected based on the Alpha value.
Figure 2-2 shows the fragment shader content where the UnLit material type is a Shader Blueprint.
Figure 2-2
NormalWS
The world normal calculates the lighting results of each vertex in world coordinates.
AlphaTest
After the AlphaTest switch is enabled, Shader uses the value of alphatest to determine whether to discard the pixel.
DiffuseColor
Diffuse color (the color of places where no light is produced)
SpecularColor
Specular color (the color of where the light is generated)
Shininess
surface smoothness
Gloss
Surface roughness
Aplha
Transparency, if TRANSPARENT rendering mode is selected, different transparency levels will be selected based on the Alpha value.
Figure 2-3 shows the fragment shader content where the Blinnphong material type is a Shader Blueprint.
Figure 2-3
-
OPAQUE (opaque)
final color = source color. This means that the material will be drawn in front of the background.
-
CUTOUT (cutout)
If the Alpha value sampled in the map > AlphaTestValue, the final color is the source color, otherwise the pixel is discarded.
-
TRANSPARENT (translucent)
Final color = source color opacity + destination color (1 - opacity).
-
ADDTIVE (additive color mixing)
Final color = source color + target color
-
ALPHABLENDED (transparent blending)
This means that the object is in semi-transparent mode, but the final pixel is shaded in a different blending mode. The AlphaBlended blending mode is SrcAlpha * SrcColor + (1 - SRCAlpha) * DstColor. Generally speaking, SrcAlpha comes from the alpha value of the texture.
ShaderName is entered in the ShaderName text box.
Shadow calculation switch. When this switch is turned on,
DepthNormal switch, when this switch is turned on, DepthNormal Pass will be added to calculate the normal information of the scene (this function may be used in some post-processing)
Alpha test switch. When this switch is turned on, the Value function of the AlphaTest variable of the fragment shader is enabled, transparent clipping is enabled, and pixels that trigger the alphatest Value condition are directly discarded without filling color.
Scene fog effect switch. When this switch is turned on, sceneFog is enabled to calculate the scope of the fog effect through the w value of the screen space.
Figure 3-1
-
Pass in a texture through Params
-
Sampling the incoming texture via UV
-
Use the color sampled from the texture as the Color passed to Unlit
-
Pass the world normal into Unlit’s world normal input
The results of the blueprint are shown below
Figure 3-2
Figure 3-3
- Pass in world normals
- Pass in the surface color through Params
The results of the blueprint are displayed as shown in the figure
Figure 3-4
In a node in the blueprint, the left side is the input data and the right side is the output data.
Input data can come from a source data, Params variable or the output of other nodes
Pic 4-1
Attribute explanation | Property type |
---|---|
GammaToLinear | Convert gamma space to linear space |
LinearToGamma | Convert linear space to gamma space |
Add a Params variable. Select "+" in the Params window and select the corresponding Parmas variable type.
Figure 6-1
Define a float value and try a float type object in the inspection panel first.
Figure 6-2
Define the value of a 2D texture and display a 2D texture type object in the inspection panel
Figure 6-3
Define a vector type, which is divided into Vector2, Vector3, and Vector4 according to the number of components.
Figure 6-4
Define a color value, usually there are four components of RGBA data
Figure 6-5
Macro definition is used to execute different result content for different trigger results of macro conditions, and is more efficient than if-else
Figure 6-6
Right-click the Create menu in the Project window and select Shader BluePrint Function to create a blueprint function.
Figure 7-1
In the blueprint editing window, right-click on the blank space, select the ShaderFunction option, and select the Input In tab.
Figure 7-2
In the final Default Output Result node, the input data type determines the output type of the Shader function. The function blueprint will automatically determine the output type, as shown in the figure below
Figure 7-3
In the blueprint function interface, right-click where you want to place the blueprint function node, and select the function defined when creating the blueprint function (blueprint function file name) in the CustomFun-BlueMap item.
Figure 7-4
simple grass
Figure 8-1
- Use Perlin noise to simulate a Vec4 vector
Figure 8-2
- Perform some special transformations on noise values
Reduce the generated noise value by 0.016, multiply it by the g channel and a channel of the external Color, sum the multiplied results, add the obtained sum to an interference value, and finally multiply it with the world matrix
Figure 8-3
- Take the xz component from the result of multiplying the world matrix and add it to the xz component of positionOS to get the new xz component of positionOS.
Figure 8-4
- Determine whether the SNOW macro is enabled. When the macro is enabled, calculate 1- the result of the square of the vertex color g value in (0,1). When the macro is turned off, the value is 0.
Figure 8-5
- Multiply the UV coordinate offset with a 2x2 matrix composed of a trigonometric function and then offset it back to the original position.
Figure 8-6
- Sample the grass texture map, extract the A channel and convert it into a gamma value as the Alpha value of the grass and pass it into the PBR function. The Albedo value is the incoming color value * texture sampling value + macro judgment value.
Figure 8-7
The results of the blueprint are shown below
Figure 8-7
Node type | Generation method |
---|---|
Quickly generate float nodes | Press and hold the numeric key 1 and left-click where you want to place it |
Quickly generate Vector2 nodes | Press and hold the numeric key 2 and left-click where you want to place it |
Quickly generate Vector3 nodes | Press and hold the numeric key 3 and left-click where you want to place it |
Quickly generate Vector4 nodes | Press and hold the numeric key 4 and left-click where you want to place it |
Quickly generate If nodes | Press and hold the letter key i, and left-click where you want to place it |
Quickly generate bool nodes | Press and hold the letter key b and left-click where you want to place it |
Quickly generate sampler2D nodes | Long press the t key and left-click the location you want to place |