diff --git a/ThreeEngine/lights/EnvironmentMap.cpp b/ThreeEngine/lights/EnvironmentMap.cpp index b9cdbfc..41d8370 100644 --- a/ThreeEngine/lights/EnvironmentMap.cpp +++ b/ThreeEngine/lights/EnvironmentMap.cpp @@ -4,12 +4,14 @@ struct EnvironmentMapConst { glm::vec4 shCoefficients[9]; + float intensity; float diffuseThresh; float diffuseHigh; float diffuseLow; float specularThresh; float specularHigh; float specularLow; + float padding; }; EnvironmentMap::EnvironmentMap(): m_constant(sizeof(EnvironmentMapConst), GL_UNIFORM_BUFFER) @@ -27,6 +29,7 @@ void EnvironmentMap::updateConstant() { EnvironmentMapConst c; memcpy(c.shCoefficients, shCoefficients, sizeof(glm::vec4) * 9); + c.intensity = intensity; c.diffuseThresh = diffuse_thresh; c.diffuseHigh = diffuse_high; c.diffuseLow = diffuse_low; diff --git a/ThreeEngine/lights/EnvironmentMap.h b/ThreeEngine/lights/EnvironmentMap.h index 4c27be3..e0757c9 100644 --- a/ThreeEngine/lights/EnvironmentMap.h +++ b/ThreeEngine/lights/EnvironmentMap.h @@ -11,6 +11,7 @@ class EnvironmentMap : public IndirectLight ~EnvironmentMap(); glm::vec4 shCoefficients[9]; + float intensity = 1.0f; GLBuffer m_constant; void updateConstant(); diff --git a/ThreeEngine/renderers/bvh_routines/BVHRoutine.cpp b/ThreeEngine/renderers/bvh_routines/BVHRoutine.cpp index ca455a9..f428b89 100644 --- a/ThreeEngine/renderers/bvh_routines/BVHRoutine.cpp +++ b/ThreeEngine/renderers/bvh_routines/BVHRoutine.cpp @@ -571,7 +571,7 @@ R"( layout (location = LOCATION_TEX_LIGHTMAP) uniform sampler2D uTexLightmap; #endif -vec3 shGetIrradianceAt( in vec3 normal, in vec4 shCoefficients[ 9 ] ) +vec3 shGetIrradianceAt( in vec3 normal, in vec4 shCoefficients[ 9 ]) { // normal is assumed to have unit length @@ -599,6 +599,7 @@ vec3 shGetIrradianceAt( in vec3 normal, in vec4 shCoefficients[ 9 ] ) layout (std140, binding = BINDING_ENVIRONMEN_MAP) uniform EnvironmentMap { vec4 uSHCoefficients[9]; + float uIntensity; float uDiffuseThresh; float uDiffuseHigh; float uDiffuseLow; @@ -609,7 +610,7 @@ layout (std140, binding = BINDING_ENVIRONMEN_MAP) uniform EnvironmentMap vec3 getIrradiance(in vec3 normal) { - return shGetIrradianceAt(normal, uSHCoefficients); + return shGetIrradianceAt(normal, uSHCoefficients) * uIntensity; } #endif diff --git a/ThreeEngine/renderers/bvh_routines/CompDrawFog.cpp b/ThreeEngine/renderers/bvh_routines/CompDrawFog.cpp index 1afccfa..9a72cf2 100644 --- a/ThreeEngine/renderers/bvh_routines/CompDrawFog.cpp +++ b/ThreeEngine/renderers/bvh_routines/CompDrawFog.cpp @@ -23,11 +23,12 @@ layout (location = 0) uniform sampler2D uDepthTex; layout (std140, binding = 1) uniform EnvironmentMap { vec4 uSHCoefficients[9]; + float uIntensity; }; vec3 GetIrradiance() { - return uSHCoefficients[0].xyz * 0.886227; + return uSHCoefficients[0].xyz * 0.886227 * uIntensity; } #elif HAS_AMBIENT_LIGHT layout (std140, binding = 1) uniform AmbientLight diff --git a/ThreeEngine/renderers/routines/DrawFog.cpp b/ThreeEngine/renderers/routines/DrawFog.cpp index 37ebb1a..08f0a7b 100644 --- a/ThreeEngine/renderers/routines/DrawFog.cpp +++ b/ThreeEngine/renderers/routines/DrawFog.cpp @@ -59,11 +59,12 @@ layout (location = 0) uniform sampler2D uDepthTex; layout (std140, binding = 3) uniform EnvironmentMap { vec4 uSHCoefficients[9]; + float uIntensity; }; vec3 GetIrradiance() { - return uSHCoefficients[0].xyz * 0.886227; + return uSHCoefficients[0].xyz * 0.886227 * uIntensity; } #elif HAS_AMBIENT_LIGHT layout (std140, binding = 3) uniform AmbientLight diff --git a/ThreeEngine/renderers/routines/SimpleRoutine.cpp b/ThreeEngine/renderers/routines/SimpleRoutine.cpp index 2a2e179..bd72718 100644 --- a/ThreeEngine/renderers/routines/SimpleRoutine.cpp +++ b/ThreeEngine/renderers/routines/SimpleRoutine.cpp @@ -311,7 +311,7 @@ R"( layout (location = LOCATION_TEX_LIGHTMAP) uniform sampler2D uTexLightmap; #endif -vec3 shGetIrradianceAt( in vec3 normal, in vec4 shCoefficients[ 9 ] ) +vec3 shGetIrradianceAt( in vec3 normal, in vec4 shCoefficients[ 9 ]) { // normal is assumed to have unit length @@ -339,6 +339,7 @@ vec3 shGetIrradianceAt( in vec3 normal, in vec4 shCoefficients[ 9 ] ) layout (std140, binding = BINDING_ENVIRONMEN_MAP) uniform EnvironmentMap { vec4 uSHCoefficients[9]; + float uIntensity; float uDiffuseThresh; float uDiffuseHigh; float uDiffuseLow; @@ -349,7 +350,7 @@ layout (std140, binding = BINDING_ENVIRONMEN_MAP) uniform EnvironmentMap vec3 getIrradiance(in vec3 normal) { - return shGetIrradianceAt(normal, uSHCoefficients); + return shGetIrradianceAt(normal, uSHCoefficients) * uIntensity; } #endif diff --git a/ThreeEngine/renderers/routines/StandardRoutine.cpp b/ThreeEngine/renderers/routines/StandardRoutine.cpp index 4084a50..d6fec3e 100644 --- a/ThreeEngine/renderers/routines/StandardRoutine.cpp +++ b/ThreeEngine/renderers/routines/StandardRoutine.cpp @@ -682,7 +682,7 @@ vec3 getRadiance(in vec3 worldPos, in vec3 viewDir, in vec3 norm, const in vec3 } #endif -vec3 shGetIrradianceAt( in vec3 normal, in vec4 shCoefficients[ 9 ] ) +vec3 shGetIrradianceAt( in vec3 normal, in vec4 shCoefficients[ 9 ]) { // normal is assumed to have unit length @@ -783,6 +783,7 @@ vec3 getReflectionDir(in vec3 dir, in vec3 norm) layout (std140, binding = BINDING_ENVIRONMEN_MAP) uniform EnvironmentMap { vec4 uSHCoefficients[9]; + float uIntensity; float uDiffuseThresh; float uDiffuseHigh; float uDiffuseLow; @@ -793,7 +794,7 @@ layout (std140, binding = BINDING_ENVIRONMEN_MAP) uniform EnvironmentMap vec3 getIrradiance(in vec3 normal) { - return shGetIrradianceAt(normal, uSHCoefficients); + return shGetIrradianceAt(normal, uSHCoefficients) * uIntensity; } #endif diff --git a/ThreeEngine/volume/routines/DrawIsosurface.cpp b/ThreeEngine/volume/routines/DrawIsosurface.cpp index 6b37b74..9bd2cdc 100644 --- a/ThreeEngine/volume/routines/DrawIsosurface.cpp +++ b/ThreeEngine/volume/routines/DrawIsosurface.cpp @@ -277,6 +277,7 @@ vec3 getReflRadiance(in vec3 reflectVec, float roughness) layout (std140, binding = BINDING_ENVIRONMEN_MAP) uniform EnvironmentMap { vec4 uSHCoefficients[9]; + float uIntensity; float uDiffuseThresh; float uDiffuseHigh; float uDiffuseLow; @@ -287,7 +288,7 @@ layout (std140, binding = BINDING_ENVIRONMEN_MAP) uniform EnvironmentMap vec3 getIrradiance(in vec3 world_pos, in vec3 normal) { - return shGetIrradianceAt(normal, uSHCoefficients); + return shGetIrradianceAt(normal, uSHCoefficients) * uIntensity; } #endif