From 8b4791605caddfca2efa68d64f04663473b7c6b7 Mon Sep 17 00:00:00 2001 From: Try Date: Mon, 4 Mar 2024 01:35:48 +0100 Subject: [PATCH] ambinet lighting in progress #510 --- game/graphics/sky/sky.cpp | 2 +- game/world/world.cpp | 2 +- shader/common.glsl | 2 +- shader/lighting/ambient_light.frag | 1 + shader/lighting/rt/probe_lighting.comp | 5 ++--- shader/lighting/sky_exposure.comp | 10 +++++----- shader/lighting/tonemapping.frag | 3 ++- shader/lighting/tonemapping.glsl | 4 +++- 8 files changed, 16 insertions(+), 13 deletions(-) diff --git a/game/graphics/sky/sky.cpp b/game/graphics/sky/sky.cpp index fec4c7e58..84738492c 100644 --- a/game/graphics/sky/sky.cpp +++ b/game/graphics/sky/sky.cpp @@ -246,7 +246,7 @@ void Sky::updateLight(const int64_t now) { Vec3 direct; direct = Vec3(1.0f) * DirectSunLux; - ambient = groundAlbedo * DirectSunLux * aDirect * sunOcclude * 0.03f;// * scale; + ambient = groundAlbedo * DirectSunLux * aDirect * sunOcclude * 0.02f; sun.setColor(direct*sunMul); ambient = ambient*ambMul; diff --git a/game/world/world.cpp b/game/world/world.cpp index fbdb3d5fc..04b387490 100644 --- a/game/world/world.cpp +++ b/game/world/world.cpp @@ -494,7 +494,7 @@ void World::execTriggerEvent(const TriggerEvent& e) { if(e.target=="EVT_LEFT_ROOM_01_TRAP_MOVER_FOR_DMG_MASTER" || e.target=="EVT_LEFT_UP_01_TOGGLE_TRIGGER_01" || e.target=="EVT_RIGHT_ROOM_01_SPAWN_ROT_02_SOUND") - return; // known problem on dragonisland.zen, skop for now + return; // known problem on dragonisland.zen, skip for now Tempest::Log::d("unable to process trigger: \"",e.target,"\""); } } diff --git a/shader/common.glsl b/shader/common.glsl index c3b14ec22..8967ad831 100644 --- a/shader/common.glsl +++ b/shader/common.glsl @@ -20,7 +20,7 @@ const float Fd_LambertInv = (M_PI); /* Color value is multiplied to achive adequate albedo and correctness in GI. * Need to scale it back, when material receives direct light. */ -const float GColorScaleInv = (6); +const float GColorScaleInv = 8;//(6); const float GColorScale = (1.0/GColorScaleInv); float linearDepth(float d, vec3 clipInfo) { diff --git a/shader/lighting/ambient_light.frag b/shader/lighting/ambient_light.frag index d206363e4..fc194687f 100644 --- a/shader/lighting/ambient_light.frag +++ b/shader/lighting/ambient_light.frag @@ -84,4 +84,5 @@ void main() { outColor = vec4(color, 1); // outColor = vec4(vec3(1-ao), 0); // outColor = vec4(linear, 0); + // outColor = vec4(srgbEncode(linear), 0); } diff --git a/shader/lighting/rt/probe_lighting.comp b/shader/lighting/rt/probe_lighting.comp index fac1756b6..ca24b4422 100644 --- a/shader/lighting/rt/probe_lighting.comp +++ b/shader/lighting/rt/probe_lighting.comp @@ -92,7 +92,7 @@ vec3 resolveMiss(const vec3 rayOrigin, const vec3 rayDirection) { } vec3 resolveSecondBounce(vec3 pos, vec3 norm, uint selfProbeId) { - return scene.ambient; + return scene.ambient;// * 2.0; // doesn't look coherent yet - need to keep offscreen data for long term const ivec3 gridPos = ivec3(round(pos/(probeGridStep*1))); @@ -115,8 +115,7 @@ vec3 resolveSecondBounce(vec3 pos, vec3 norm, uint selfProbeId) { // probeId = selfProbeId; // return vec3(0.01,0,0)*scene.GSunIntensity; - const vec3 ambient = scene.ambient; - return ambient * 4.0 * Fd_LambertInv; + return scene.ambient; // return resolveMiss(pos, -norm); // return vec3(0); } diff --git a/shader/lighting/sky_exposure.comp b/shader/lighting/sky_exposure.comp index 019cacbf3..6027a6edd 100644 --- a/shader/lighting/sky_exposure.comp +++ b/shader/lighting/sky_exposure.comp @@ -108,17 +108,17 @@ void main() { const float cldVal = textureLod(cloudsLUT, vec2(scene.isNight,0), 0).a; const float clouds = (1.0 - pow(cldVal, 4)); - const vec3 sunColor = scene.sunColor * tr * clouds; - const vec3 ambient = scene.ambient * tr;// * clouds; + const vec3 sunColor = scene.sunColor * tr;// * clouds; + const vec3 ambient = scene.ambient * tr;// * clouds; - vec3 light = sunColor*Fd_Lambert*1.5 + ambient + skyIrradiance(); + vec3 light = sunColor*Fd_Lambert*1.25 + ambient + skyIrradiance(); float lum = (vmax+vmin) * 0.5 * scene.GSunIntensity; //lum = dot(light, vec3(1.0/3.0)); lum = dot(light, vec3(0.2125, 0.7154, 0.0721))*0.6 + lum*0.4; // float lum = tr.b; - scene.sunColor = sunColor * push.sunOcclusion; - scene.ambient = ambient; + scene.sunColor = sunColor * clouds * push.sunOcclusion; + scene.ambient = ambient * clouds; scene.exposure = 1.0 / max(lum+push.baseL, 0.0000005); scene.luminanceMed = lum; } diff --git a/shader/lighting/tonemapping.frag b/shader/lighting/tonemapping.frag index 46a07f6bd..64e5afa41 100644 --- a/shader/lighting/tonemapping.frag +++ b/shader/lighting/tonemapping.frag @@ -114,6 +114,7 @@ void main() { vec3 color = textureLod(textureD, uv, 0).rgb; { // outColor = vec4(srgbEncode(color), 1); + // outColor = vec4(color, 1); // return; } @@ -134,7 +135,7 @@ void main() { color = color * vec3(contrast); // Tonemapping - color = acesTonemap(color); + color = acesTonemap(color)*1.28; // Gamma //color = srgbEncode(color); diff --git a/shader/lighting/tonemapping.glsl b/shader/lighting/tonemapping.glsl index 8c6644d89..95c1c52b0 100644 --- a/shader/lighting/tonemapping.glsl +++ b/shader/lighting/tonemapping.glsl @@ -42,10 +42,12 @@ vec3 textureLinear(vec3 rgb) { // emissive objects, spells return acesTonemapInv(linear); #else + // return vec3(0.58, 0.49, 0.46); // brick // return vec3(0.52, 0.41, 0.36); // wood - // return vec3(0.33, 0.34, 0.18); // leaves + // return vec3(0.48, 0.53, 0.30); // grass // return vec3(0.9); // return acesTonemapInv(linear*0.8); + // return acesTonemapInv(linear*0.78+0.001); return acesTonemapInv(linear*0.78+0.001)*GColorScaleInv; // adjusted to have 'realistic' albedo values #endif }