Shader Artifact For Cell Shader

Godot Version

Godot Engine v4.2.1.stable.mono.official.b09f793f5


So I was working on my project trying to make a cell shader using this code:

shader_type spatial;
render_mode ambient_light_disabled, diffuse_toon;

uniform vec4 color : source_color = vec4(1.0);
uniform sampler2D tex : source_color, hint_default_white;
uniform sampler2D texDark : source_color, hint_default_white;

uniform float shadow : hint_range(0.0, 1.0) = 0.5;
uniform float shadow_width : hint_range(0.001, 0.5) = 0.0;

void fragment() {
    ALBEDO = pow(texture(tex, UV).rgb, vec3(1)) * color.rgb;

void light() {
    float NdotL = dot(NORMAL, LIGHT) * ATTENUATION;
    NdotL = smoothstep(shadow - shadow_width, shadow + shadow_width, NdotL);
    DIFFUSE_LIGHT = mix(texture(texDark, UV).rgb, (ALBEDO) * LIGHT_COLOR.rgb * 0.33, NdotL);

I now have this artifacts of lines between my boxes and darkening of my them in weird ways. I have tried changing a lot of the render settings in project settings but the only setting that worked slightly was anti alliancing. Is there any way to fix it that will help me find the root cause?

can always try other’s made of cel shader, i found Complete Cel Shader for Godot 4 - Godot Shaders

check if issue persist

I have tried that one and went through the steps I needed to get it working in the read me doc but it never worked.