Merge pull request #92213 from clayjohn/ambient-disabled
Disable all sources of ambient light when `ambient_light_disabled` render mode is used
This commit is contained in:
commit
824a97120e
|
@ -1609,6 +1609,7 @@ void main() {
|
||||||
#ifdef BASE_PASS
|
#ifdef BASE_PASS
|
||||||
/////////////////////// LIGHTING //////////////////////////////
|
/////////////////////// LIGHTING //////////////////////////////
|
||||||
|
|
||||||
|
#ifndef AMBIENT_LIGHT_DISABLED
|
||||||
// IBL precalculations
|
// IBL precalculations
|
||||||
float ndotv = clamp(dot(normal, view), 0.0, 1.0);
|
float ndotv = clamp(dot(normal, view), 0.0, 1.0);
|
||||||
vec3 F = f0 + (max(vec3(1.0 - roughness), f0) - f0) * pow(1.0 - ndotv, 5.0);
|
vec3 F = f0 + (max(vec3(1.0 - roughness), f0) - f0) * pow(1.0 - ndotv, 5.0);
|
||||||
|
@ -1746,18 +1747,14 @@ void main() {
|
||||||
#endif // USE_LIGHTMAP_CAPTURE
|
#endif // USE_LIGHTMAP_CAPTURE
|
||||||
#endif // !DISABLE_LIGHTMAP
|
#endif // !DISABLE_LIGHTMAP
|
||||||
|
|
||||||
{
|
ambient_light *= albedo.rgb;
|
||||||
#if defined(AMBIENT_LIGHT_DISABLED)
|
ambient_light *= ao;
|
||||||
ambient_light = vec3(0.0, 0.0, 0.0);
|
|
||||||
#else
|
#endif // !AMBIENT_LIGHT_DISABLED
|
||||||
ambient_light *= albedo.rgb;
|
|
||||||
ambient_light *= ao;
|
|
||||||
#endif // AMBIENT_LIGHT_DISABLED
|
|
||||||
}
|
|
||||||
|
|
||||||
// convert ao to direct light ao
|
// convert ao to direct light ao
|
||||||
ao = mix(1.0, ao, ao_light_affect);
|
ao = mix(1.0, ao, ao_light_affect);
|
||||||
|
#ifndef AMBIENT_LIGHT_DISABLED
|
||||||
{
|
{
|
||||||
#if defined(DIFFUSE_TOON)
|
#if defined(DIFFUSE_TOON)
|
||||||
//simplify for toon, as
|
//simplify for toon, as
|
||||||
|
@ -1779,6 +1776,8 @@ void main() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // !AMBIENT_LIGHT_DISABLED
|
||||||
|
|
||||||
#ifndef DISABLE_LIGHT_DIRECTIONAL
|
#ifndef DISABLE_LIGHT_DIRECTIONAL
|
||||||
for (uint i = uint(0); i < scene_data.directional_light_count; i++) {
|
for (uint i = uint(0); i < scene_data.directional_light_count; i++) {
|
||||||
#if defined(USE_LIGHTMAP) && !defined(DISABLE_LIGHTMAP)
|
#if defined(USE_LIGHTMAP) && !defined(DISABLE_LIGHTMAP)
|
||||||
|
|
|
@ -1310,6 +1310,8 @@ void fragment_shader(in SceneData scene_data) {
|
||||||
|
|
||||||
#if !defined(MODE_RENDER_DEPTH) && !defined(MODE_UNSHADED)
|
#if !defined(MODE_RENDER_DEPTH) && !defined(MODE_UNSHADED)
|
||||||
|
|
||||||
|
#ifndef AMBIENT_LIGHT_DISABLED
|
||||||
|
|
||||||
if (scene_data.use_reflection_cubemap) {
|
if (scene_data.use_reflection_cubemap) {
|
||||||
#ifdef LIGHT_ANISOTROPY_USED
|
#ifdef LIGHT_ANISOTROPY_USED
|
||||||
// https://google.github.io/filament/Filament.html#lighting/imagebasedlights/anisotropy
|
// https://google.github.io/filament/Filament.html#lighting/imagebasedlights/anisotropy
|
||||||
|
@ -1397,14 +1399,15 @@ void fragment_shader(in SceneData scene_data) {
|
||||||
#endif //USE_RADIANCE_CUBEMAP_ARRAY
|
#endif //USE_RADIANCE_CUBEMAP_ARRAY
|
||||||
specular_light += clearcoat_light * horizon * horizon * Fc * scene_data.ambient_light_color_energy.a;
|
specular_light += clearcoat_light * horizon * horizon * Fc * scene_data.ambient_light_color_energy.a;
|
||||||
}
|
}
|
||||||
#endif
|
#endif // LIGHT_CLEARCOAT_USED
|
||||||
|
#endif // !AMBIENT_LIGHT_DISABLED
|
||||||
#endif //!defined(MODE_RENDER_DEPTH) && !defined(MODE_UNSHADED)
|
#endif //!defined(MODE_RENDER_DEPTH) && !defined(MODE_UNSHADED)
|
||||||
|
|
||||||
//radiance
|
//radiance
|
||||||
|
|
||||||
/// GI ///
|
/// GI ///
|
||||||
#if !defined(MODE_RENDER_DEPTH) && !defined(MODE_UNSHADED)
|
#if !defined(MODE_RENDER_DEPTH) && !defined(MODE_UNSHADED)
|
||||||
|
#ifndef AMBIENT_LIGHT_DISABLED
|
||||||
#ifdef USE_LIGHTMAP
|
#ifdef USE_LIGHTMAP
|
||||||
|
|
||||||
//lightmap
|
//lightmap
|
||||||
|
@ -1698,9 +1701,6 @@ void fragment_shader(in SceneData scene_data) {
|
||||||
|
|
||||||
//finalize ambient light here
|
//finalize ambient light here
|
||||||
{
|
{
|
||||||
#if defined(AMBIENT_LIGHT_DISABLED)
|
|
||||||
ambient_light = vec3(0.0, 0.0, 0.0);
|
|
||||||
#else
|
|
||||||
ambient_light *= albedo.rgb;
|
ambient_light *= albedo.rgb;
|
||||||
ambient_light *= ao;
|
ambient_light *= ao;
|
||||||
|
|
||||||
|
@ -1713,15 +1713,14 @@ void fragment_shader(in SceneData scene_data) {
|
||||||
ambient_light *= 1.0 - ssil.a;
|
ambient_light *= 1.0 - ssil.a;
|
||||||
ambient_light += ssil.rgb * albedo.rgb;
|
ambient_light += ssil.rgb * albedo.rgb;
|
||||||
}
|
}
|
||||||
#endif // AMBIENT_LIGHT_DISABLED
|
|
||||||
}
|
}
|
||||||
|
#endif // AMBIENT_LIGHT_DISABLED
|
||||||
// convert ao to direct light ao
|
// convert ao to direct light ao
|
||||||
ao = mix(1.0, ao, ao_light_affect);
|
ao = mix(1.0, ao, ao_light_affect);
|
||||||
|
|
||||||
//this saves some VGPRs
|
//this saves some VGPRs
|
||||||
vec3 f0 = F0(metallic, specular, albedo);
|
vec3 f0 = F0(metallic, specular, albedo);
|
||||||
|
#ifndef AMBIENT_LIGHT_DISABLED
|
||||||
{
|
{
|
||||||
#if defined(DIFFUSE_TOON)
|
#if defined(DIFFUSE_TOON)
|
||||||
//simplify for toon, as
|
//simplify for toon, as
|
||||||
|
@ -1743,6 +1742,7 @@ void fragment_shader(in SceneData scene_data) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // !AMBIENT_LIGHT_DISABLED
|
||||||
#endif //GI !defined(MODE_RENDER_DEPTH) && !defined(MODE_UNSHADED)
|
#endif //GI !defined(MODE_RENDER_DEPTH) && !defined(MODE_UNSHADED)
|
||||||
|
|
||||||
#if !defined(MODE_RENDER_DEPTH)
|
#if !defined(MODE_RENDER_DEPTH)
|
||||||
|
|
|
@ -1071,6 +1071,8 @@ void main() {
|
||||||
|
|
||||||
#if !defined(MODE_RENDER_DEPTH) && !defined(MODE_UNSHADED)
|
#if !defined(MODE_RENDER_DEPTH) && !defined(MODE_UNSHADED)
|
||||||
|
|
||||||
|
#ifndef AMBIENT_LIGHT_DISABLED
|
||||||
|
|
||||||
if (scene_data.use_reflection_cubemap) {
|
if (scene_data.use_reflection_cubemap) {
|
||||||
#ifdef LIGHT_ANISOTROPY_USED
|
#ifdef LIGHT_ANISOTROPY_USED
|
||||||
// https://google.github.io/filament/Filament.html#lighting/imagebasedlights/anisotropy
|
// https://google.github.io/filament/Filament.html#lighting/imagebasedlights/anisotropy
|
||||||
|
@ -1158,13 +1160,14 @@ void main() {
|
||||||
#endif //USE_RADIANCE_CUBEMAP_ARRAY
|
#endif //USE_RADIANCE_CUBEMAP_ARRAY
|
||||||
specular_light += clearcoat_light * horizon * horizon * Fc * scene_data.ambient_light_color_energy.a;
|
specular_light += clearcoat_light * horizon * horizon * Fc * scene_data.ambient_light_color_energy.a;
|
||||||
}
|
}
|
||||||
#endif
|
#endif // LIGHT_CLEARCOAT_USED
|
||||||
|
#endif // !AMBIENT_LIGHT_DISABLED
|
||||||
#endif //!defined(MODE_RENDER_DEPTH) && !defined(MODE_UNSHADED)
|
#endif //!defined(MODE_RENDER_DEPTH) && !defined(MODE_UNSHADED)
|
||||||
|
|
||||||
//radiance
|
//radiance
|
||||||
|
|
||||||
#if !defined(MODE_RENDER_DEPTH) && !defined(MODE_UNSHADED)
|
#if !defined(MODE_RENDER_DEPTH) && !defined(MODE_UNSHADED)
|
||||||
|
#ifndef AMBIENT_LIGHT_DISABLED
|
||||||
#ifdef USE_LIGHTMAP
|
#ifdef USE_LIGHTMAP
|
||||||
|
|
||||||
//lightmap
|
//lightmap
|
||||||
|
@ -1274,14 +1277,11 @@ void main() {
|
||||||
} //Reflection probes
|
} //Reflection probes
|
||||||
|
|
||||||
// finalize ambient light here
|
// finalize ambient light here
|
||||||
{
|
|
||||||
#if defined(AMBIENT_LIGHT_DISABLED)
|
ambient_light *= albedo.rgb;
|
||||||
ambient_light = vec3(0.0, 0.0, 0.0);
|
ambient_light *= ao;
|
||||||
#else
|
|
||||||
ambient_light *= albedo.rgb;
|
#endif // !AMBIENT_LIGHT_DISABLED
|
||||||
ambient_light *= ao;
|
|
||||||
#endif // AMBIENT_LIGHT_DISABLED
|
|
||||||
}
|
|
||||||
|
|
||||||
// convert ao to direct light ao
|
// convert ao to direct light ao
|
||||||
ao = mix(1.0, ao, ao_light_affect);
|
ao = mix(1.0, ao, ao_light_affect);
|
||||||
|
@ -1289,6 +1289,7 @@ void main() {
|
||||||
//this saves some VGPRs
|
//this saves some VGPRs
|
||||||
vec3 f0 = F0(metallic, specular, albedo);
|
vec3 f0 = F0(metallic, specular, albedo);
|
||||||
|
|
||||||
|
#ifndef AMBIENT_LIGHT_DISABLED
|
||||||
{
|
{
|
||||||
#if defined(DIFFUSE_TOON)
|
#if defined(DIFFUSE_TOON)
|
||||||
//simplify for toon, as
|
//simplify for toon, as
|
||||||
|
@ -1310,6 +1311,7 @@ void main() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // !AMBIENT_LIGHT_DISABLED
|
||||||
#endif // !defined(MODE_RENDER_DEPTH) && !defined(MODE_UNSHADED)
|
#endif // !defined(MODE_RENDER_DEPTH) && !defined(MODE_UNSHADED)
|
||||||
|
|
||||||
#if !defined(MODE_RENDER_DEPTH)
|
#if !defined(MODE_RENDER_DEPTH)
|
||||||
|
|
Loading…
Reference in New Issue