Shaders and materials: choose a task
Practical routes to 2D effects, 3D surfaces and material control.
Find the task
| Task | Guide |
|---|---|
| Understand C# versus GPU work | Shader introduction |
| Modify Sprite2D color, transparency and reveal | First 2D shader |
| Create heightmap relief | First 3D shader |
| Control PBR and independent object parameters | Material and parameters |
| Configure a regular surface without a custom program | StandardMaterial3D |
| Project tracks and markings | Decals |
| Configure background, ambient light and effects | Environment |
Choose the program type
canvas_item processes 2D surfaces; spatial handles 3D materials. Fog, sky, particles and compute are different tasks: their programs cannot simply be pasted into an ordinary Sprite2D fragment().
Shader is the program. ShaderMaterial stores its reference and regular-uniform values. Material assignment and parameter control depend on the receiver. Two materials can share a Shader while keeping different values; two objects sharing a ShaderMaterial share those values.
Start with a complete example for the intended dimension. Keep a baseline frame and change one parameter at a time. Check resource assignment, uniform name and value type before inspecting the formula and lighting. A material-cache entry does not establish that the shader uses that name.
Open the API
Shader: program and metadata. ShaderMaterial: resource parameters. CanvasItem: 2D assignment, modulation and inheritance. GeometryInstance3D: individual 3D geometry parameters.