Ive gota fragment shader.
Ideally Id like to have a function like this:
void draw_normal_pixel() {
vec2 base_uv = UV;
vec4 albedo_tex = texture(texture_albedo,base_uv);
albedo_tex *= COLOR;
ALBEDO = albedo.rgb * albedo_tex.rgb;
SPECULAR = specular;
ALPHA = albedo.a * albedo_tex.a;
ALPHA_SCISSOR_THRESHOLD = .3;
}
because I have a ton of if else statements and they all call the above code.
Without the function I have a lot of code duplication.
But outside of the fragment function UV doesnt mean anything. So if I write that function I get
"unknown identifier in expression: "UV"
Im also worried that the function may add extra overhead and slow the shader down.
What is the most optimal way to eliminate the code duplication?