mirror of
https://github.com/godotengine/godot
synced 2024-09-05 04:28:29 +00:00
Fix "Light Only" mode of CanvasItemMaterial
This commit is contained in:
parent
c64afeb017
commit
43b0702a02
|
@ -175,7 +175,7 @@ void RasterizerCanvasGLES3::canvas_render_items(RID p_to_render_target, Item *p_
|
|||
state.light_uniforms[index].color[i] = l->color[i];
|
||||
}
|
||||
|
||||
state.light_uniforms[index].color[3] = l->energy; //use alpha for energy, so base color can go separate
|
||||
state.light_uniforms[index].color[3] *= l->energy; //use alpha for energy, so base color can go separate
|
||||
|
||||
if (state.shadow_fb != 0) {
|
||||
state.light_uniforms[index].shadow_pixel_size = (1.0 / state.shadow_texture_size) * (1.0 + l->shadow_smooth);
|
||||
|
@ -238,7 +238,7 @@ void RasterizerCanvasGLES3::canvas_render_items(RID p_to_render_target, Item *p_
|
|||
state.light_uniforms[index].color[i] = l->color[i];
|
||||
}
|
||||
|
||||
state.light_uniforms[index].color[3] = l->energy; //use alpha for energy, so base color can go separate
|
||||
state.light_uniforms[index].color[3] *= l->energy; //use alpha for energy, so base color can go separate
|
||||
|
||||
if (state.shadow_fb != 0) {
|
||||
state.light_uniforms[index].shadow_pixel_size = (1.0 / state.shadow_texture_size) * (1.0 + l->shadow_smooth);
|
||||
|
|
|
@ -648,7 +648,7 @@ void main() {
|
|||
vec4 base_color = color;
|
||||
|
||||
#ifdef MODE_LIGHT_ONLY
|
||||
color = vec4(0.0);
|
||||
float light_only_alpha = 0.0;
|
||||
#elif !defined(MODE_UNSHADED)
|
||||
color *= canvas_modulation;
|
||||
#endif
|
||||
|
@ -691,6 +691,9 @@ void main() {
|
|||
}
|
||||
|
||||
light_blend_compute(light_base, light_color, color.rgb);
|
||||
#ifdef MODE_LIGHT_ONLY
|
||||
light_only_alpha += light_color.a;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Positional Lights
|
||||
|
@ -788,8 +791,15 @@ void main() {
|
|||
}
|
||||
|
||||
light_blend_compute(light_base, light_color, color.rgb);
|
||||
#ifdef MODE_LIGHT_ONLY
|
||||
light_only_alpha += light_color.a;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MODE_LIGHT_ONLY
|
||||
color.a *= light_only_alpha;
|
||||
#endif
|
||||
|
||||
frag_color = color;
|
||||
}
|
||||
|
|
|
@ -1202,7 +1202,7 @@ void RendererCanvasRenderRD::canvas_render_items(RID p_to_render_target, Item *p
|
|||
state.light_uniforms[index].color[i] = l->color[i];
|
||||
}
|
||||
|
||||
state.light_uniforms[index].color[3] = l->energy; //use alpha for energy, so base color can go separate
|
||||
state.light_uniforms[index].color[3] *= l->energy; //use alpha for energy, so base color can go separate
|
||||
|
||||
if (state.shadow_fb.is_valid()) {
|
||||
state.light_uniforms[index].shadow_pixel_size = (1.0 / state.shadow_texture_size) * (1.0 + l->shadow_smooth);
|
||||
|
@ -1264,7 +1264,7 @@ void RendererCanvasRenderRD::canvas_render_items(RID p_to_render_target, Item *p
|
|||
state.light_uniforms[index].color[i] = l->color[i];
|
||||
}
|
||||
|
||||
state.light_uniforms[index].color[3] = l->energy; //use alpha for energy, so base color can go separate
|
||||
state.light_uniforms[index].color[3] *= l->energy; //use alpha for energy, so base color can go separate
|
||||
|
||||
if (state.shadow_fb.is_valid()) {
|
||||
state.light_uniforms[index].shadow_pixel_size = (1.0 / state.shadow_texture_size) * (1.0 + l->shadow_smooth);
|
||||
|
|
|
@ -568,7 +568,7 @@ void main() {
|
|||
}
|
||||
|
||||
#ifdef MODE_LIGHT_ONLY
|
||||
color = vec4(0.0);
|
||||
float light_only_alpha = 0.0;
|
||||
#elif !defined(MODE_UNSHADED)
|
||||
color *= canvas_data.canvas_modulation;
|
||||
#endif
|
||||
|
@ -611,6 +611,9 @@ void main() {
|
|||
}
|
||||
|
||||
light_blend_compute(light_base, light_color, color.rgb);
|
||||
#ifdef MODE_LIGHT_ONLY
|
||||
light_only_alpha += light_color.a;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Positional Lights
|
||||
|
@ -695,8 +698,15 @@ void main() {
|
|||
}
|
||||
|
||||
light_blend_compute(light_base, light_color, color.rgb);
|
||||
#ifdef MODE_LIGHT_ONLY
|
||||
light_only_alpha += light_color.a;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MODE_LIGHT_ONLY
|
||||
color.a *= light_only_alpha;
|
||||
#endif
|
||||
|
||||
frag_color = color;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue