Update leenkx/Shaders/deferred_light/deferred_light.frag.glsl
This commit is contained in:
		@ -56,6 +56,10 @@ uniform vec3 backgroundCol;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#ifdef _SSAO
 | 
					#ifdef _SSAO
 | 
				
			||||||
uniform sampler2D ssaotex;
 | 
					uniform sampler2D ssaotex;
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					#ifdef _SSGI
 | 
				
			||||||
 | 
					uniform sampler2D ssaotex;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef _SSS
 | 
					#ifdef _SSS
 | 
				
			||||||
@ -233,9 +237,12 @@ void main() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#ifdef _Brdf
 | 
					#ifdef _Brdf
 | 
				
			||||||
	vec2 envBRDF = texelFetch(senvmapBrdf, ivec2(vec2(dotNV, 1.0 - roughness) * 256.0), 0).xy;
 | 
						vec2 envBRDF = texelFetch(senvmapBrdf, ivec2(vec2(dotNV, 1.0 - roughness) * 256.0), 0).xy;
 | 
				
			||||||
 | 
					    vec3 F = f0 * envBRDF.x + envBRDF.y;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Envmap
 | 
					#ifndef _VoxelGI
 | 
				
			||||||
 | 
					#ifndef _VoxelAOvar
 | 
				
			||||||
 | 
					// Envmap
 | 
				
			||||||
#ifdef _Irr
 | 
					#ifdef _Irr
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	vec3 envl = shIrradiance(n, shirr);
 | 
						vec3 envl = shIrradiance(n, shirr);
 | 
				
			||||||
@ -271,33 +278,33 @@ void main() {
 | 
				
			|||||||
	envl.rgb *= albedo;
 | 
						envl.rgb *= albedo;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef _Brdf
 | 
					#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
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef _Rad // Indirect specular
 | 
					#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
 | 
					#else
 | 
				
			||||||
	#ifdef _EnvCol
 | 
						#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
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	envl.rgb *= envmapStrength * occspec.x;
 | 
						envl.rgb *= envmapStrength * occspec.x;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						fragColor.rgb = envl;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef _VoxelGI
 | 
					#ifdef _VoxelGI
 | 
				
			||||||
	vec4 indirect_diffuse = textureLod(voxels_diffuse, texCoord, 0.0);
 | 
						fragColor.rgb = textureLod(voxels_diffuse, texCoord, 0.0).rgb * voxelgiDiff;
 | 
				
			||||||
	fragColor.rgb = (indirect_diffuse.rgb + envl.rgb * (1.0 - indirect_diffuse.a)) * albedo * voxelgiDiff;
 | 
					 | 
				
			||||||
	if(roughness < 1.0 && occspec.y > 0.0)
 | 
						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
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef _VoxelAOvar
 | 
					#ifdef _VoxelAOvar
 | 
				
			||||||
	envl.rgb *= textureLod(voxels_ao, texCoord, 0.0).r;
 | 
						fragColor.rgb = textureLod(voxels_ao, texCoord, 0.0).rgb * voxelgiOcc;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef _VoxelGI
 | 
					 | 
				
			||||||
	fragColor.rgb = envl;
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
	// Show voxels
 | 
						// Show voxels
 | 
				
			||||||
	// vec3 origin = vec3(texCoord * 2.0 - 1.0, 0.99);
 | 
						// vec3 origin = vec3(texCoord * 2.0 - 1.0, 0.99);
 | 
				
			||||||
	// vec3 direction = vec3(0.0, 0.0, -1.0);
 | 
						// vec3 direction = vec3(0.0, 0.0, -1.0);
 | 
				
			||||||
@ -317,6 +324,10 @@ void main() {
 | 
				
			|||||||
	// #else
 | 
						// #else
 | 
				
			||||||
	fragColor.rgb *= textureLod(ssaotex, texCoord, 0.0).r;
 | 
						fragColor.rgb *= textureLod(ssaotex, texCoord, 0.0).r;
 | 
				
			||||||
	// #endif
 | 
						// #endif
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					#ifdef _SSGI
 | 
				
			||||||
 | 
						fragColor.rgb += textureLod(ssaotex, texCoord, 0.0).rgb;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef _EmissionShadeless
 | 
					#ifdef _EmissionShadeless
 | 
				
			||||||
@ -445,7 +456,7 @@ void main() {
 | 
				
			|||||||
		, true, spotData.x, spotData.y, spotDir, spotData.zw, spotRight
 | 
							, true, spotData.x, spotData.y, spotDir, spotData.zw, spotRight
 | 
				
			||||||
		#endif
 | 
							#endif
 | 
				
			||||||
		#ifdef _VoxelShadow
 | 
							#ifdef _VoxelShadow
 | 
				
			||||||
			, voxels, voxelsSDF, clipmaps
 | 
								, voxels, voxelsSDF, clipmaps, -g2.rg
 | 
				
			||||||
		#endif
 | 
							#endif
 | 
				
			||||||
		#ifdef _MicroShadowing
 | 
							#ifdef _MicroShadowing
 | 
				
			||||||
		, occspec.x
 | 
							, occspec.x
 | 
				
			||||||
@ -503,7 +514,7 @@ void main() {
 | 
				
			|||||||
			, lightsArraySpot[li * 2 + 1].xyz // right
 | 
								, lightsArraySpot[li * 2 + 1].xyz // right
 | 
				
			||||||
			#endif
 | 
								#endif
 | 
				
			||||||
			#ifdef _VoxelShadow
 | 
								#ifdef _VoxelShadow
 | 
				
			||||||
			, voxels, voxelsSDF, clipmaps
 | 
								, voxels, voxelsSDF, clipmaps, -g2.rg
 | 
				
			||||||
			#endif
 | 
								#endif
 | 
				
			||||||
			#ifdef _MicroShadowing
 | 
								#ifdef _MicroShadowing
 | 
				
			||||||
			, occspec.x
 | 
								, occspec.x
 | 
				
			||||||
@ -515,13 +526,5 @@ void main() {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
#endif // _Clusters
 | 
					#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
 | 
						fragColor.a = 1.0; // Mark as opaque
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user