I've got a confusing situation - after duplicating my shaders don't work. How can i properly duplicate shader that will work separately for each mesh instance?
Shader:
shader_type spatial;
render_mode cull_disabled;
varying float hole_radius;
varying vec3 frag_pos;
uniform vec4 my_color : source_color;
const int MAX_HOLES = 10;
uniform vec3 holes[MAX_HOLES];
uniform float hole_radii[MAX_HOLES];
uniform int num_holes;
uniform sampler2D my_texture;
varying vec2 uv;
void vertex() {
uv = UV;
frag_pos = VERTEX;
}
void fragment() {
vec3 color = vec3(0.1f, 0.1f, 0.1f);
vec4 tex_color = texture(my_texture, uv);
ALBEDO = mix(tex_color.rgb, color, 0.5) * float(FRONT_FACING);
for (int i = 0; i < num_holes; ++i) {
ALBEDO = mix(tex_color.rgb, color, 0.5) * float(FRONT_FACING);
float dist = distance(frag_pos, holes[i]);
if (dist < hole_radii[i]){
discard;
} else {
EMISSION = my_color.rgb * (1.0f - clamp((dist / hole_radii[i] * 1.5f), 0.0f, 1.0f)) + (1.0f - float(FRONT_FACING)) * my_color.rgb;
}
}
}