In the low level API in Godot (servers) there is just one material,
and one shader type. It's used for everything (2D, 3D and particles so
far).
I'm still unsure on how to implement Shaders in the higher level scene
system in Godot. There are two approaches I can think of:
1) Like Godot 2.1
we have Material, FixedMaterial, CanvasItemMaterial,
ParticlesMaterial, SpatialShaderMaterial, and a lot of specific
classes that would do basically the same... then SpatialShader,
CanvasItemShader, ParticlesShader, etc.
Also in the shader code, it does not matter in the shader itself what
the code is, as it's the class what makes it matter. Ie. you know a
shader is for 2D because you created a CanvasItemShader.
Advantages: More contextually friendly, not error prone
Disadvantages: Kind of a mess, impossible to save shaders as text with
a single extension
2) Simplified model:
Just having:
Shader, VisualShader for shaders
then
Material (abstract), ShaderMaterial (put a shader, for any type),
SpatialMaterial (for fixed-style 3D), CanvasItemMaterial (for
fixed-style 2D), Particles (for fixed-style particles).
Then in the shader language, we add some kind of keyword at the top of
the shader like:
spatial_shader, canvas_item_shader, particles_shader
to tell what type the shader is... so there is just a single Shader
resource class.
Advantages: Very simple, can save shaders as a text file (ie, with
.shader extension)
Disadvantages: Can lead to confusion, users might put a 2D shader in a
3D object.. will have to rely on us adding error checking and
displaying it to the user.
I'm more inclined towards the second, even if it implies more error
checking due to simplicity. What do you guys think?
Cheers
Juan