Godot Version
4.3 - stable
Question
I’m using this nice shader (Flexible Toon Shader (Godot 4) - Godot Shaders) and it’s got most of what I need, but I’m getting awful square artifact on the fringes of the light here, and I would really appreciate any pointers on how to remediate this.
Whatever the shader is doing, it seems like it’s not correctly respecting the attenuation of the light: the light has its own range nd anything outside that range won’t be affected by the light.
I’m assuming this is the problematic part
// Simple rim lighting.
if (use_rim) {
float NdotV = dot(NORMAL, VIEW);
float rim_light = pow(1.0 - NdotV, rim_width);
SPECULAR_LIGHT += rim_light * rim_color.rgb * rim_color.a * LIGHT_COLOR / PI; //Changed DIFFUSE_LIGHT to SPECULAR_LIGHT while migrating for similar result
}
Because rim light will be shown everywhere on the model, but since it’s calculated in light() it won’t work on the entire model. Rim light should probably be calculated only for the directional light (ilght index 1 or 0, i don’t remember)
Note that rim behaves really badly on large flat surfaces.
1 Like
Thanks for the reply! I’ll see if I can change it to look a bit better, if not I’ll just turn off rimlights on this particular variant.
Most toon shaders are made to work mostly with a single directional light