Advertisement
Guest User

Untitled

a guest
Mar 25th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. 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).
  2.  
  3. 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:
  4.  
  5. 1) Like Godot 2.1
  6.  
  7. we have Material, FixedMaterial, CanvasItemMaterial, ParticlesMaterial, SpatialShaderMaterial, and a lot of specific classes that would do basically the same... then SpatialShader, CanvasItemShader, ParticlesShader, etc.
  8.  
  9. 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.
  10.  
  11. Advantages: More contextually friendly, not error prone
  12. Disadvantages: Kind of a mess, impossible to save shaders as text with a single extension
  13.  
  14. 2) Simplified model:
  15.  
  16. Just having:
  17.  
  18. Shader, VisualShader for shaders
  19. then
  20. Material (abstract), ShaderMaterial (put a shader, for any type), SpatialMaterial (for fixed-style 3D), CanvasItemMaterial (for fixed-style 2D), Particles (for fixed-style particles).
  21.  
  22. Then in the shader language, we add some kind of keyword at the top of the shader like:
  23.  
  24. spatial_shader, canvas_item_shader, particles_shader
  25.  
  26. to tell what type the shader is... so there is just a single Shader resource class.
  27.  
  28.  
  29. Advantages: Very simple, can save shaders as a text file (ie, with .shader extension)
  30. 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.
  31.  
  32.  
  33. I'm more inclined towards the second, even if it implies more error checking due to simplicity. What do you guys think?
  34.  
  35. Cheers
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement