Materials and Shader Graph
VisualShader, surface outputs and post-processing materials.
Material, shader and graph
A material defines surface parameters. ShaderMaterial uses a text Shader or visual VisualShader. Shader Graph builds shaders, not gameplay logic; use SharpGraph or C# for object behavior.
Choose the purpose before building the graph: a 3D surface, Canvas or a custom post-processing effect. Outputs and available data differ. Post-processing profiles affect camera images, while an ordinary material affects an object.
Assign a surface graph
- Select a
MeshInstance3Dwith visible geometry. - Create a
ShaderMaterialin the intended material slot and assign aVisualShader. - Open the shader resource. Use the Fragment stage for surface color, rather than Vertex.
- Connect a color constant to the output block's
Albedo. Supply roughness separately. - Check that the material is assigned to the surface visible to the camera.
- Save the shader and material inside the project, then inspect the object in the game.
An unconnected block does not affect the final material. Port-type or compilation errors can prevent the intended shader variant from building; begin with one valid output.
Surface parameters
| Input | Meaning |
|---|---|
| Albedo | Base surface color |
| Metallic | Metallic material response |
| Roughness | Specular highlight width and character |
| Normal | Direction used for lighting |
| Emission | Surface emission |
Albedo textures contain color. Normal maps contain directions and need the corresponding import settings. Roughness/metallic masks should not automatically be interpreted as color photographs. Check UVs and model scale before trying to fix stretched textures inside the shader.
Emission can produce bright pixels and bloom when enabled, but does not guarantee illumination of nearby objects: light transport depends on GI.
Compare a text shader
A minimal text material with the same main parameters:
shader_type spatial;
void fragment() {
ALBEDO = vec3(0.18, 0.32, 0.40);
METALLIC = 0.2;
ROUGHNESS = 0.65;
}Save it as .rshader and assign it to a ShaderMaterial. This is an alternative resource, not a promise of arbitrary text-to-graph conversion.
Custom post-processing
A fullscreen effect needs camera context and an appropriate insertion stage. Before tone mapping, data may be HDR; afterward the range and interpretation differ. Depth or surface-data effects need a stage that actually supplies those inputs.
Canvas cannot assume that 3D normals, object velocities and depth always exist. Read capability warnings. For multi-pass effects, use named intermediate textures and explicit dependencies; do not read an output that has not yet been produced.
| Problem | First check |
|---|---|
| Object is unchanged | Material assigned to the correct surface and resource |
| Graph exists without a result | Fragment stage, connection to Output and compilation errors |
| Incorrect highlights | Normal/roughness import, UVs and lighting |
| Different result in game | Camera, renderer, profile and insertion stage |
API: VisualShader, ShaderMaterial.