There are generally 3 ways to create materials:
Refer to the Model Import and Usage tutorial. We can first import the model into the editor. Generally, the model is automatically bound with materials, and users don't need to do anything.
If you want to modify model materials, we can click the duplicate and remap
button to generate a copy of that material. Note that Remap will modify the model preset, and all model instances will be affected as shown below:
If you only want to modify the material of a specific model, you can use the incremental modification feature:
We can directly drag materials into the scene to bind them.
You can select materials in the editor and switch shaders to observe real-time rendering effect changes.
Each shader has different rendering effects and application scenarios. For more details, refer to Built-in Shader Tutorial and Custom Shader Tutorial.
If built-in shaders cannot meet your needs, we can create a custom shader. In the editor asset panel, create a new Shader and choose PBR template or Unlit template:
The editor will automatically help us create the Shader file and UIScript file.
For specific shader content writing, you can quickly get started with Custom Shader Tutorial.
Like other programming languages, we also use many variables when writing shaders. First, the engine has many built-in variables, which we don't need to set manually and can be used directly in shaders. Next, let's see how to set and use custom data.
...
Pass "Forward" {
// Declare custom variables
vec4 u_color;
// Declare engine built-in variables
mat4 renderer_MVPMat;
// Through including code fragments
#include "Transform.glsl"
}
...