A material is a resource that controls how the engine draws or shades a surface, whether it's a 3D model or a 2D sprite.Materials use shader programs and allow you to edit shader parameters to control the visual appearance of surfaces.
The difference between a material and a shader
A shader is code that runs on the graphics card to calculate the color of each pixel on the screen. A material, on the other hand, is a configuration of a shader. In other words, a material is a set of parameters you can tweak to change the appearance of a surface.You can think of shaders as being to materials what scripts are to nodes in Godot.We often reuse a shader with multiple materials, just like you can reuse the same script on multiple nodes and scene instances.
Types of materials
Godot comes with several types of materials out of the box:
SpatialMaterial: A material for 3D objects. It supports PBR (Physically Based Rendering) and offers many parameters to control the appearance of 3D models.
ShaderMaterial: A material that uses a custom shader program. You can write the shader code yourself or use the engine's visual shader editor. This material is available for both 2D and 3D objects.
ParticlesMaterial: A material for GPU-based particle systems. It offers many options to control the motion and appearance of particles, including velocity, acceleration, scale over time, color over time, and more.
CanvasItemMaterial: A material for 2D objects. It allows you to change the blending mode of 2D sprites and offers an option to animate 2D particles using a sprite sheet.
There are also several contextual materials, like the built-in 3D sky materials that generate a sky background and ambient lighting in 3D scenes.