Re: [godot-devel] Implementation of shaders request for feedback |
[ Thread Index | Date Index | More godotengine.org/devel Archives ]
How would 2) work with #include directives? If you need stuff that can be re-used in any kind of shader, but included in different types of shaders?
Also, I kinda feel like an explicit type is a too hard separation, because what defines that is how shaders are used (on which material they are), or how they are written (which input they take), which can even sometimes make them suitable for any use (2D/3D etc).
Not sure how feasible it is, but that feeling probably comes from what I saw in Unity shaders, where there is no need to "type" them, but just use or not use some inputs, and implement one or more functions.---
Le 25/03/2017 à 12:35, Juan Linietsky a écrit :
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
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast.
https://www.avast.com/antivirus
Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |