Update leenkx/Shaders/deferred_light/deferred_light.frag.glsl

This commit is contained in:
2025-05-21 00:40:56 +00:00
parent 08614512d7
commit 0eafd14ae2

View File

@ -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
}