I made this post because I want to learn the new shader language used in Godot 3.0 and help others to learn or fixing possible issues. Don't misunderstand me, I don't pretend to complain about it, just learn and help improving the engine ;) With hat said, let's start.
I know it's mostly GLSL, which I like and I'm familiar with it, but I'm having a lot of trouble to make the simplest shaders. Is there any documentation available? I've been looking in every place I could, but I found almost no documentation about it, so with a few posts from Juan, my knowledge about GLSL and digging in the source code, I managed to more or less understand the language.
- You have to first specify the
shader_type (spatial, canvas_item or particles).
- Write the uniforms or any other variable.
- Define the shaders functions
void vertex() and
I'm mostly doing spatial shaders, which I assume are for 3D. So my questions are for that type.
I did the simplest shader for make a sphere in red color (the uniform vector equals to (1, 0, 0) ):
I have few questions:
- How can I make the uniform variable to be a color picker? With that code I simply get a window to introduce vector values. In Godot 2.x you introduce
uniform color pick_color; and you get a color picker. I've seen Juan doing this: but that doesn't work for me. Is it a feature still in development or can I do it in some way?
- How can I get the light information ( director vector, specular, diffusse light, etc.) in a spatial shader type? I digged in the source code and the only thing I could find was, for example, a variable called
LIGHT_VEC like in Godot 2.x, but is only defined for canvas_shader type!
Finally, I would like to point out some issue. If you try to use
COLOR instead of
ALBEDO, this is what happens:
I know it's in alpha development, and there are still missing features and lot of work to do, but I just wanted to make sure if it's my poor knowledge about it or not ;).
Thank you very much for your time!