From 2ce1118faa453d622383c4bbb2bf797477317ad7 Mon Sep 17 00:00:00 2001 From: Alex Roman Date: Tue, 17 Jul 2018 21:30:43 +0200 Subject: Add disable ambient light flag to shaders and materials --- drivers/gles3/shader_compiler_gles3.cpp | 1 + drivers/gles3/shaders/scene.glsl | 56 +++++++++++++++------------------ 2 files changed, 27 insertions(+), 30 deletions(-) (limited to 'drivers') diff --git a/drivers/gles3/shader_compiler_gles3.cpp b/drivers/gles3/shader_compiler_gles3.cpp index 9ad16ac2a2..3f6fe3ec61 100644 --- a/drivers/gles3/shader_compiler_gles3.cpp +++ b/drivers/gles3/shader_compiler_gles3.cpp @@ -913,6 +913,7 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() { actions[VS::SHADER_SPATIAL].render_mode_defines["specular_toon"] = "#define SPECULAR_TOON\n"; actions[VS::SHADER_SPATIAL].render_mode_defines["specular_disabled"] = "#define SPECULAR_DISABLED\n"; actions[VS::SHADER_SPATIAL].render_mode_defines["shadows_disabled"] = "#define SHADOWS_DISABLED\n"; + actions[VS::SHADER_SPATIAL].render_mode_defines["ambient_light_disabled"] = "#define AMBIENT_LIGHT_DISABLED\n"; /* PARTICLES SHADER */ diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl index ed8df04377..abb236138f 100644 --- a/drivers/gles3/shaders/scene.glsl +++ b/drivers/gles3/shaders/scene.glsl @@ -571,11 +571,6 @@ in vec3 normal_interp; /* PBR CHANNELS */ -//used on forward mainly -uniform bool no_ambient_light; - - - #ifdef USE_RADIANCE_MAP @@ -1752,42 +1747,43 @@ FRAGMENT_SHADER_CODE #ifdef USE_RADIANCE_MAP - if (no_ambient_light) { - ambient_light=vec3(0.0,0.0,0.0); - } else { - { - - { //read radiance from dual paraboloid +#ifdef AMBIENT_LIGHT_DISABLED + ambient_light=vec3(0.0,0.0,0.0); +#else + { - vec3 ref_vec = reflect(-eye_vec,normal); //2.0 * ndotv * normal - view; // reflect(v, n); - ref_vec=normalize((radiance_inverse_xform * vec4(ref_vec,0.0)).xyz); - vec3 radiance = textureDualParaboloid(radiance_map,ref_vec,roughness) * bg_energy; - env_reflection_light = radiance; + { //read radiance from dual paraboloid - } - //no longer a cubemap - //vec3 radiance = textureLod(radiance_cube, r, lod).xyz * ( brdf.x + brdf.y); + vec3 ref_vec = reflect(-eye_vec,normal); //2.0 * ndotv * normal - view; // reflect(v, n); + ref_vec=normalize((radiance_inverse_xform * vec4(ref_vec,0.0)).xyz); + vec3 radiance = textureDualParaboloid(radiance_map,ref_vec,roughness) * bg_energy; + env_reflection_light = radiance; } + //no longer a cubemap + //vec3 radiance = textureLod(radiance_cube, r, lod).xyz * ( brdf.x + brdf.y); + + } #ifndef USE_LIGHTMAP - { + { - vec3 ambient_dir=normalize((radiance_inverse_xform * vec4(normal,0.0)).xyz); - vec3 env_ambient=textureDualParaboloid(radiance_map,ambient_dir,1.0) * bg_energy; + vec3 ambient_dir=normalize((radiance_inverse_xform * vec4(normal,0.0)).xyz); + vec3 env_ambient=textureDualParaboloid(radiance_map,ambient_dir,1.0) * bg_energy; - ambient_light=mix(ambient_light_color.rgb,env_ambient,radiance_ambient_contribution); - //ambient_light=vec3(0.0,0.0,0.0); - } -#endif + ambient_light=mix(ambient_light_color.rgb,env_ambient,radiance_ambient_contribution); + //ambient_light=vec3(0.0,0.0,0.0); } +#endif +#endif //AMBIENT_LIGHT_DISABLED #else - if (no_ambient_light){ - ambient_light=vec3(0.0,0.0,0.0); - } else { - ambient_light=ambient_light_color.rgb; - } +#ifdef AMBIENT_LIGHT_DISABLED + ambient_light=vec3(0.0,0.0,0.0); +#else + ambient_light=ambient_light_color.rgb; +#endif //AMBIENT_LIGHT_DISABLED + #endif ambient_light*=ambient_energy; -- cgit v1.2.3