I want to pass a variable as a secondary color to GUI box shader, i’m trying to use set_shadow or set_outline but the shadow or outline variable is not passed to the vertex shader.
Is there anyway to make the GUI box pass the shadow color variable? just like the GUI Font
Yup, The box node does not have properties for shadows or an outline. Only the text node does. You can create a shader for it yourself or a more straight forward approach would be to layer your nodes into a single node then you can edit colors , move it around together etc. in runtime. Here’s an example.
hhm I think I might understand what you are asking for now. So you want to pass a vec4 to the vertex or fragment program and use it in the shader? These are called vertex and fragment constants and also you can use vertex attributes. You can read about them here: Defold materials manual .
To use them in gui you first need to add your material to the gui outline and then assign it to a node in its properties. You must use the constant in the shader or you may get warnings. Then to change the constant you can use for example: gui.set(node, "myconst", vmath.vec4(1,1,0,1))API reference (GUI)
Here I have copied the gui material in my project, named it mygui and customized it by adding a vertex constant named “myconst” its type user and is a vec4.
I then need to use the constant in the shader or it will throw errors/warnings.
#version 140
in mediump vec3 position;
in mediump vec2 texcoord0;
in mediump vec4 color;
out mediump vec2 var_texcoord0;
out mediump vec4 var_color;
uniform vs_uniforms
{
mediump mat4 view_proj;
mediump vec4 myconst;
};
void main()
{
//Use my constant or it will be removed and cause a warning. Note this is just an example
var_dosomething = myconst;
////////////////////////////
var_texcoord0 = texcoord0;
var_color = vec4(color.rgb * color.a, color.a);
gl_Position = view_proj * vec4(position.xyz, 1.0);
}