Fix emission not working in the ubershader

(cherry picked from commit ea6ed9658d)
This commit is contained in:
Pedro J. Estébanez 2022-08-07 23:11:44 +02:00 committed by Rémi Verschelde
parent f3adb06938
commit 0af799d2a7
1 changed files with 6 additions and 6 deletions

View File

@ -2376,9 +2376,9 @@ FRAGMENT_SHADER_CODE
float max_ambient = max(ambient_light.r, max(ambient_light.g, ambient_light.b)); float max_ambient = max(ambient_light.r, max(ambient_light.g, ambient_light.b));
float max_diffuse = max(diffuse_light.r, max(diffuse_light.g, diffuse_light.b)); float max_diffuse = max(diffuse_light.r, max(diffuse_light.g, diffuse_light.b));
float total_ambient = max_ambient + max_diffuse; float total_ambient = max_ambient + max_diffuse;
#ifdef USE_FORWARD_LIGHTING #ifdef USE_FORWARD_LIGHTING //ubershader-runtime
total_ambient += max_emission; total_ambient += max_emission;
#endif #endif //ubershader-runtime
float ambient_scale = (total_ambient > 0.0) ? (max_ambient + ambient_occlusion_affect_light * max_diffuse) / total_ambient : 0.0; float ambient_scale = (total_ambient > 0.0) ? (max_ambient + ambient_occlusion_affect_light * max_diffuse) / total_ambient : 0.0;
#if defined(ENABLE_AO) #if defined(ENABLE_AO)
@ -2387,9 +2387,9 @@ FRAGMENT_SHADER_CODE
diffuse_buffer = vec4(diffuse_light + ambient_light, ambient_scale); diffuse_buffer = vec4(diffuse_light + ambient_light, ambient_scale);
specular_buffer = vec4(specular_light, metallic); specular_buffer = vec4(specular_light, metallic);
#ifdef USE_FORWARD_LIGHTING #ifdef USE_FORWARD_LIGHTING //ubershader-runtime
diffuse_buffer.rgb += emission; diffuse_buffer.rgb += emission;
#endif #endif //ubershader-runtime
#endif //SHADELESS //ubershader-runtime #endif //SHADELESS //ubershader-runtime
normal_mr_buffer = vec4(normalize(normal) * 0.5 + 0.5, roughness); normal_mr_buffer = vec4(normalize(normal) * 0.5 + 0.5, roughness);
@ -2404,9 +2404,9 @@ FRAGMENT_SHADER_CODE
frag_color = vec4(albedo, alpha); frag_color = vec4(albedo, alpha);
#else //ubershader-runtime #else //ubershader-runtime
frag_color = vec4(ambient_light + diffuse_light + specular_light, alpha); frag_color = vec4(ambient_light + diffuse_light + specular_light, alpha);
#ifdef USE_FORWARD_LIGHTING #ifdef USE_FORWARD_LIGHTING //ubershader-runtime
frag_color.rgb += emission; frag_color.rgb += emission;
#endif #endif //ubershader-runtime
#endif //SHADELESS //ubershader-runtime #endif //SHADELESS //ubershader-runtime
#endif //USE_MULTIPLE_RENDER_TARGETS //ubershader-runtime #endif //USE_MULTIPLE_RENDER_TARGETS //ubershader-runtime