I want to create a new ShaderMaterial
in C#. For now I'm trying out something very basic like constant blue. However, it fails. The same shader works fine when I create it over the editor, but I need the assignment to happen in code, of course once I get this toy example running I will extend the shader.
var mesh = new MeshInstance3D() {
Mesh = new BoxMesh(),
Position = new Vector3(x, -z, y)
};
mesh.MaterialOverlay = new ShaderMaterial {
Shader = new Shader {
Code = @"{
shader_type spatial;
void fragment() { ALBEDO = vec3(0., 0., 1.); }
"
}
};
The mesh stays grey. I am missing something? Even when I make the shader syntax wrong I get no compilation error, so I suspect some compilation of linking call is missing somewhere, but I didn't find anything in the docs. So how to approach this?