From 0eafd14ae26a81a62ca3d5150fec0a590af57d57 Mon Sep 17 00:00:00 2001 From: Onek8 Date: Wed, 21 May 2025 00:40:56 +0000 Subject: [PATCH] Update leenkx/Shaders/deferred_light/deferred_light.frag.glsl --- .../deferred_light/deferred_light.frag.glsl | 47 ++++++++++--------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/leenkx/Shaders/deferred_light/deferred_light.frag.glsl b/leenkx/Shaders/deferred_light/deferred_light.frag.glsl index a4700dc..b819d0e 100644 --- a/leenkx/Shaders/deferred_light/deferred_light.frag.glsl +++ b/leenkx/Shaders/deferred_light/deferred_light.frag.glsl @@ -56,6 +56,10 @@ uniform vec3 backgroundCol; #ifdef _SSAO uniform sampler2D ssaotex; +#else +#ifdef _SSGI +uniform sampler2D ssaotex; +#endif #endif #ifdef _SSS @@ -233,9 +237,12 @@ void main() { #ifdef _Brdf vec2 envBRDF = texelFetch(senvmapBrdf, ivec2(vec2(dotNV, 1.0 - roughness) * 256.0), 0).xy; + vec3 F = f0 * envBRDF.x + envBRDF.y; #endif - // Envmap +#ifndef _VoxelGI +#ifndef _VoxelAOvar +// Envmap #ifdef _Irr vec3 envl = shIrradiance(n, shirr); @@ -271,33 +278,33 @@ void main() { envl.rgb *= albedo; #ifdef _Brdf - envl.rgb *= 1.0 - (f0 * envBRDF.x + envBRDF.y); //LV: We should take refracted light into account + envl.rgb *= 1.0 - F; #endif #ifdef _Rad // Indirect specular - envl.rgb += prefilteredColor * (f0 * envBRDF.x + envBRDF.y); //LV: Removed "1.5 * occspec.y". Specular should be weighted only by FV LUT + envl.rgb += prefilteredColor * F; #else #ifdef _EnvCol - envl.rgb += backgroundCol * (f0 * envBRDF.x + envBRDF.y); //LV: Eh, what's the point of weighting it only by F0? + envl.rgb += backgroundCol * F; #endif #endif envl.rgb *= envmapStrength * occspec.x; + fragColor.rgb = envl; +#endif +#endif + #ifdef _VoxelGI - vec4 indirect_diffuse = textureLod(voxels_diffuse, texCoord, 0.0); - fragColor.rgb = (indirect_diffuse.rgb + envl.rgb * (1.0 - indirect_diffuse.a)) * albedo * voxelgiDiff; + fragColor.rgb = textureLod(voxels_diffuse, texCoord, 0.0).rgb * voxelgiDiff; if(roughness < 1.0 && occspec.y > 0.0) - fragColor.rgb += textureLod(voxels_specular, texCoord, 0.0).rgb * occspec.y * voxelgiRefl; + fragColor.rgb += textureLod(voxels_specular, texCoord, 0.0).rgb * F * voxelgiRefl; #endif #ifdef _VoxelAOvar - envl.rgb *= textureLod(voxels_ao, texCoord, 0.0).r; + fragColor.rgb = textureLod(voxels_ao, texCoord, 0.0).rgb * voxelgiOcc; #endif -#ifndef _VoxelGI - fragColor.rgb = envl; -#endif // Show voxels // vec3 origin = vec3(texCoord * 2.0 - 1.0, 0.99); // vec3 direction = vec3(0.0, 0.0, -1.0); @@ -317,6 +324,10 @@ void main() { // #else fragColor.rgb *= textureLod(ssaotex, texCoord, 0.0).r; // #endif +#else +#ifdef _SSGI + fragColor.rgb += textureLod(ssaotex, texCoord, 0.0).rgb; +#endif #endif #ifdef _EmissionShadeless @@ -343,7 +354,7 @@ void main() { float sdotVH = max(0.0, dot(v, sh)); float sdotNL = max(0.0, dot(n, sunDir)); vec3 svisibility = vec3(1.0); - vec3 sdirect = lambertDiffuseBRDF(albedo, sdotNL) + + vec3 sdirect = lambertDiffuseBRDF(albedo, sdotNL) + specularBRDF(f0, roughness, sdotNL, sdotNH, dotNV, sdotVH) * occspec.y; #ifdef _ShadowMap @@ -445,7 +456,7 @@ void main() { , true, spotData.x, spotData.y, spotDir, spotData.zw, spotRight #endif #ifdef _VoxelShadow - , voxels, voxelsSDF, clipmaps + , voxels, voxelsSDF, clipmaps, -g2.rg #endif #ifdef _MicroShadowing , occspec.x @@ -503,7 +514,7 @@ void main() { , lightsArraySpot[li * 2 + 1].xyz // right #endif #ifdef _VoxelShadow - , voxels, voxelsSDF, clipmaps + , voxels, voxelsSDF, clipmaps, -g2.rg #endif #ifdef _MicroShadowing , occspec.x @@ -515,13 +526,5 @@ void main() { } #endif // _Clusters -/* -#ifdef _VoxelRefract -if(opac < 1.0) { - vec3 refraction = traceRefraction(p, n, voxels, v, ior, roughness, eye) * voxelgiRefr; - fragColor.rgb = mix(refraction, fragColor.rgb, opac); -} -#endif -*/ fragColor.a = 1.0; // Mark as opaque }