Update leenkx/Shaders/std/light.glsl
This commit is contained in:
		@ -31,40 +31,54 @@
 | 
				
			|||||||
		#ifdef _Spot
 | 
							#ifdef _Spot
 | 
				
			||||||
			#ifndef _LTC
 | 
								#ifndef _LTC
 | 
				
			||||||
				uniform sampler2DShadow shadowMapSpot[1];
 | 
									uniform sampler2DShadow shadowMapSpot[1];
 | 
				
			||||||
 | 
									#ifdef _ShadowMapTransparent
 | 
				
			||||||
				uniform sampler2D shadowMapSpotTransparent[1];
 | 
									uniform sampler2D shadowMapSpotTransparent[1];
 | 
				
			||||||
				uniform mat4 LWVPSpot[1];
 | 
									#endif
 | 
				
			||||||
 | 
									uniform mat4 LWVPSpotArray[1];
 | 
				
			||||||
			#endif
 | 
								#endif
 | 
				
			||||||
		#else
 | 
							#else
 | 
				
			||||||
			uniform samplerCubeShadow shadowMapPoint[1];
 | 
								uniform samplerCubeShadow shadowMapPoint[1];
 | 
				
			||||||
 | 
								#ifdef _ShadowMapTransparent
 | 
				
			||||||
			uniform samplerCube shadowMapPointTransparent[1];
 | 
								uniform samplerCube shadowMapPointTransparent[1];
 | 
				
			||||||
 | 
								#endif
 | 
				
			||||||
			uniform vec2 lightProj;
 | 
								uniform vec2 lightProj;
 | 
				
			||||||
		#endif
 | 
							#endif
 | 
				
			||||||
	#endif
 | 
						#endif
 | 
				
			||||||
	#ifdef _Clusters
 | 
						#ifdef _Clusters
 | 
				
			||||||
		#ifdef _SingleAtlas
 | 
							#ifdef _SingleAtlas
 | 
				
			||||||
		//!uniform sampler2DShadow shadowMapAtlas;
 | 
							//!uniform sampler2DShadow shadowMapAtlas;
 | 
				
			||||||
 | 
							#ifdef _ShadowMapTransparent
 | 
				
			||||||
		//!uniform sampler2D shadowMapAtlasTransparent;
 | 
							//!uniform sampler2D shadowMapAtlasTransparent;
 | 
				
			||||||
		#endif
 | 
							#endif
 | 
				
			||||||
 | 
							#endif
 | 
				
			||||||
		uniform vec2 lightProj;
 | 
							uniform vec2 lightProj;
 | 
				
			||||||
		#ifdef _ShadowMapAtlas
 | 
							#ifdef _ShadowMapAtlas
 | 
				
			||||||
		#ifndef _SingleAtlas
 | 
							#ifndef _SingleAtlas
 | 
				
			||||||
		uniform sampler2DShadow shadowMapAtlasPoint;
 | 
							uniform sampler2DShadow shadowMapAtlasPoint;
 | 
				
			||||||
 | 
							#ifdef _ShadowMapTransparent
 | 
				
			||||||
		uniform sampler2D shadowMapAtlasPointTransparent;
 | 
							uniform sampler2D shadowMapAtlasPointTransparent;
 | 
				
			||||||
		#endif
 | 
							#endif
 | 
				
			||||||
 | 
							#endif
 | 
				
			||||||
		#else
 | 
							#else
 | 
				
			||||||
		uniform samplerCubeShadow shadowMapPoint[4];
 | 
							uniform samplerCubeShadow shadowMapPoint[4];
 | 
				
			||||||
 | 
							#ifdef _ShadowMapTransparent
 | 
				
			||||||
		uniform samplerCube shadowMapPointTransparent[4];
 | 
							uniform samplerCube shadowMapPointTransparent[4];
 | 
				
			||||||
		#endif
 | 
							#endif
 | 
				
			||||||
 | 
							#endif
 | 
				
			||||||
		#ifdef _Spot
 | 
							#ifdef _Spot
 | 
				
			||||||
			#ifdef _ShadowMapAtlas
 | 
								#ifdef _ShadowMapAtlas
 | 
				
			||||||
			#ifndef _SingleAtlas
 | 
								#ifndef _SingleAtlas
 | 
				
			||||||
			uniform sampler2DShadow shadowMapAtlasSpot;
 | 
								uniform sampler2DShadow shadowMapAtlasSpot;
 | 
				
			||||||
 | 
								#ifdef _ShadowMapTransparent
 | 
				
			||||||
			uniform sampler2D shadowMapAtlasSpotTransparent;
 | 
								uniform sampler2D shadowMapAtlasSpotTransparent;
 | 
				
			||||||
			#endif
 | 
								#endif
 | 
				
			||||||
 | 
								#endif
 | 
				
			||||||
			#else
 | 
								#else
 | 
				
			||||||
			uniform sampler2DShadow shadowMapSpot[4];
 | 
								uniform sampler2DShadow shadowMapSpot[4];
 | 
				
			||||||
 | 
								#ifdef _ShadowMapTransparent
 | 
				
			||||||
			uniform sampler2D shadowMapSpotTransparent[4];
 | 
								uniform sampler2D shadowMapSpotTransparent[4];
 | 
				
			||||||
			#endif
 | 
								#endif
 | 
				
			||||||
 | 
								#endif
 | 
				
			||||||
			uniform mat4 LWVPSpotArray[maxLightsCluster];
 | 
								uniform mat4 LWVPSpotArray[maxLightsCluster];
 | 
				
			||||||
		#endif
 | 
							#endif
 | 
				
			||||||
	#endif
 | 
						#endif
 | 
				
			||||||
@ -81,12 +95,16 @@ uniform sampler2D sltcMag;
 | 
				
			|||||||
#ifndef _Spot
 | 
					#ifndef _Spot
 | 
				
			||||||
	#ifdef _SinglePoint
 | 
						#ifdef _SinglePoint
 | 
				
			||||||
		uniform sampler2DShadow shadowMapSpot[1];
 | 
							uniform sampler2DShadow shadowMapSpot[1];
 | 
				
			||||||
 | 
							#ifdef _ShadowMapTransparent
 | 
				
			||||||
		uniform sampler2D shadowMapSpotTransparent[1];
 | 
							uniform sampler2D shadowMapSpotTransparent[1];
 | 
				
			||||||
		uniform mat4 LWVPSpot[1];
 | 
							#endif
 | 
				
			||||||
 | 
							uniform mat4 LWVPSpotArray[1];
 | 
				
			||||||
	#endif
 | 
						#endif
 | 
				
			||||||
	#ifdef _Clusters
 | 
						#ifdef _Clusters
 | 
				
			||||||
		uniform sampler2DShadow shadowMapSpot[maxLightsCluster];
 | 
							uniform sampler2DShadow shadowMapSpot[maxLightsCluster];
 | 
				
			||||||
 | 
							#ifdef _ShadowMapTransparent
 | 
				
			||||||
		uniform sampler2D shadowMapSpotTransparent[maxLightsCluster];
 | 
							uniform sampler2D shadowMapSpotTransparent[maxLightsCluster];
 | 
				
			||||||
 | 
							#endif
 | 
				
			||||||
		uniform mat4 LWVPSpotArray[maxLightsCluster];
 | 
							uniform mat4 LWVPSpotArray[maxLightsCluster];
 | 
				
			||||||
	#endif
 | 
						#endif
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
@ -96,7 +114,10 @@ uniform sampler2D sltcMag;
 | 
				
			|||||||
vec3 sampleLight(const vec3 p, const vec3 n, const vec3 v, const float dotNV, const vec3 lp, const vec3 lightCol,
 | 
					vec3 sampleLight(const vec3 p, const vec3 n, const vec3 v, const float dotNV, const vec3 lp, const vec3 lightCol,
 | 
				
			||||||
	const vec3 albedo, const float rough, const float spec, const vec3 f0
 | 
						const vec3 albedo, const float rough, const float spec, const vec3 f0
 | 
				
			||||||
	#ifdef _ShadowMap
 | 
						#ifdef _ShadowMap
 | 
				
			||||||
		, int index, float bias, bool receiveShadow, bool transparent
 | 
							, int index, float bias, bool receiveShadow
 | 
				
			||||||
 | 
						#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
							, bool transparent
 | 
				
			||||||
 | 
						#endif
 | 
				
			||||||
	#endif
 | 
						#endif
 | 
				
			||||||
	#ifdef _Spot
 | 
						#ifdef _Spot
 | 
				
			||||||
		, const bool isSpot, const float spotSize, float spotBlend, vec3 spotDir, vec2 scale, vec3 right
 | 
							, const bool isSpot, const float spotSize, float spotBlend, vec3 spotDir, vec2 scale, vec3 right
 | 
				
			||||||
@ -150,7 +171,7 @@ vec3 sampleLight(const vec3 p, const vec3 n, const vec3 v, const float dotNV, co
 | 
				
			|||||||
	#ifdef _VoxelShadow
 | 
						#ifdef _VoxelShadow
 | 
				
			||||||
	vec3 lightDir = l;
 | 
						vec3 lightDir = l;
 | 
				
			||||||
	#ifdef _Spot
 | 
						#ifdef _Spot
 | 
				
			||||||
	if(isSpot)
 | 
						if (isSpot)
 | 
				
			||||||
		lightDir = spotDir;
 | 
							lightDir = spotDir;
 | 
				
			||||||
	#endif
 | 
						#endif
 | 
				
			||||||
	direct *= (1.0 - traceShadow(p, n, voxels, voxelsSDF, lightDir, clipmaps, gl_FragCoord.xy, velocity).r) * voxelgiShad;
 | 
						direct *= (1.0 - traceShadow(p, n, voxels, voxelsSDF, lightDir, clipmaps, gl_FragCoord.xy, velocity).r) * voxelgiShad;
 | 
				
			||||||
@ -160,15 +181,55 @@ vec3 sampleLight(const vec3 p, const vec3 n, const vec3 v, const float dotNV, co
 | 
				
			|||||||
	#ifdef _ShadowMap
 | 
						#ifdef _ShadowMap
 | 
				
			||||||
		if (receiveShadow) {
 | 
							if (receiveShadow) {
 | 
				
			||||||
			#ifdef _SinglePoint
 | 
								#ifdef _SinglePoint
 | 
				
			||||||
			vec4 lPos = LWVPSpotArray[0] * vec4(p + n * bias * 10, 1.0);
 | 
								vec4 lPos = LWVPSpot[0] * vec4(p + n * bias * 10, 1.0);
 | 
				
			||||||
			direct *= shadowTest(shadowMapSpot[0], shadowMapSpotTransparent[0], lPos.xyz / lPos.w, bias, transparent);
 | 
								direct *= shadowTest(shadowMapSpot[0],
 | 
				
			||||||
 | 
													#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
													shadowMapSpotTransparent[0],
 | 
				
			||||||
 | 
													#endif
 | 
				
			||||||
 | 
													lPos.xyz / lPos.w, bias
 | 
				
			||||||
 | 
													#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
													, transparent
 | 
				
			||||||
 | 
													#endif
 | 
				
			||||||
 | 
													);
 | 
				
			||||||
			#endif
 | 
								#endif
 | 
				
			||||||
			#ifdef _Clusters
 | 
								#ifdef _Clusters
 | 
				
			||||||
			vec4 lPos = LWVPSpotArray[index] * vec4(p + n * bias * 10, 1.0);
 | 
								vec4 lPos = LWVPSpot[index] * vec4(p + n * bias * 10, 1.0);
 | 
				
			||||||
			if (index == 0) direct *= shadowTest(shadowMapSpot[0], shadowMapSpotTransparent[0], lPos.xyz / lPos.w, bias, transparent);
 | 
								if (index == 0) direct *= shadowTest(shadowMapSpot[0],
 | 
				
			||||||
			else if (index == 1) direct *= shadowTest(shadowMapSpot[1], shadowMapSpotTransparent[1], lPos.xyz / lPos.w, bias, transparent);
 | 
																	#ifdef _ShadowMapTransparent
 | 
				
			||||||
			else if (index == 2) direct *= shadowTest(shadowMapSpot[2], shadowMapSpotTransparent[2], lPos.xyz / lPos.w, bias, transparent);
 | 
																	shadowMapSpotTransparent[0],
 | 
				
			||||||
			else if (index == 3) direct *= shadowTest(shadowMapSpot[3], shadowMapSpotTransparent[3], lPos.xyz / lPos.w, bias, transparent);
 | 
																	#endif
 | 
				
			||||||
 | 
																	lPos.xyz / lPos.w, bias
 | 
				
			||||||
 | 
																	#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
																	, transparent
 | 
				
			||||||
 | 
																	#endif
 | 
				
			||||||
 | 
																	);
 | 
				
			||||||
 | 
								else if (index == 1) direct *= shadowTest(shadowMapSpot[1],
 | 
				
			||||||
 | 
																		#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
																		shadowMapSpotTransparent[1],
 | 
				
			||||||
 | 
																		#endif
 | 
				
			||||||
 | 
																		lPos.xyz / lPos.w, bias
 | 
				
			||||||
 | 
																		#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
																		, transparent
 | 
				
			||||||
 | 
																		#endif
 | 
				
			||||||
 | 
																		);
 | 
				
			||||||
 | 
								else if (index == 2) direct *= shadowTest(shadowMapSpot[2],
 | 
				
			||||||
 | 
																		#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
																		shadowMapSpotTransparent[2],
 | 
				
			||||||
 | 
																		#endif
 | 
				
			||||||
 | 
																		lPos.xyz / lPos.w, bias
 | 
				
			||||||
 | 
																		#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
																		, transparent
 | 
				
			||||||
 | 
																		#endif
 | 
				
			||||||
 | 
																		);
 | 
				
			||||||
 | 
								else if (index == 3) direct *= shadowTest(shadowMapSpot[3],
 | 
				
			||||||
 | 
																		#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
																		shadowMapSpotTransparent[3],
 | 
				
			||||||
 | 
																		#endif
 | 
				
			||||||
 | 
																		lPos.xyz / lPos.w, bias
 | 
				
			||||||
 | 
																		#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
																		, transparent
 | 
				
			||||||
 | 
																		#endif
 | 
				
			||||||
 | 
																		);
 | 
				
			||||||
			#endif
 | 
								#endif
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	#endif
 | 
						#endif
 | 
				
			||||||
@ -182,25 +243,76 @@ vec3 sampleLight(const vec3 p, const vec3 n, const vec3 v, const float dotNV, co
 | 
				
			|||||||
		#ifdef _ShadowMap
 | 
							#ifdef _ShadowMap
 | 
				
			||||||
			if (receiveShadow) {
 | 
								if (receiveShadow) {
 | 
				
			||||||
				#ifdef _SinglePoint
 | 
									#ifdef _SinglePoint
 | 
				
			||||||
				vec4 lPos = LWVPSpot[0] * vec4(p + n * bias * 10, 1.0);
 | 
									vec4 lPos = LWVPSpotArray[0] * vec4(p + n * bias * 10, 1.0);
 | 
				
			||||||
				direct *= shadowTest(shadowMapSpot[0], shadowMapSpotTransparent[0], lPos.xyz / lPos.w, bias, transparent);
 | 
									direct *= shadowTest(shadowMapSpot[0],
 | 
				
			||||||
 | 
														#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
														shadowMapSpotTransparent[0],
 | 
				
			||||||
 | 
														#endif
 | 
				
			||||||
 | 
														lPos.xyz / lPos.w, bias
 | 
				
			||||||
 | 
														#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
														, transparent
 | 
				
			||||||
 | 
														#endif
 | 
				
			||||||
 | 
														);
 | 
				
			||||||
				#endif
 | 
									#endif
 | 
				
			||||||
				#ifdef _Clusters
 | 
									#ifdef _Clusters
 | 
				
			||||||
					vec4 lPos = LWVPSpotArray[index] * vec4(p + n * bias * 10, 1.0);
 | 
										vec4 lPos = LWVPSpotArray[index] * vec4(p + n * bias * 10, 1.0);
 | 
				
			||||||
					#ifdef _ShadowMapAtlas
 | 
										#ifdef _ShadowMapAtlas
 | 
				
			||||||
						direct *= shadowTest(
 | 
											direct *= shadowTest(
 | 
				
			||||||
							#ifndef _SingleAtlas
 | 
																#ifdef _ShadowMapTransparent
 | 
				
			||||||
							shadowMapAtlasSpot, shadowMapAtlasSpotTransparent
 | 
																#ifndef _SingleAtlas
 | 
				
			||||||
							#else
 | 
																shadowMapAtlasSpot, shadowMapAtlasSpotTransparent
 | 
				
			||||||
							shadowMapAtlas, shadowMapAtlasTransparent
 | 
																#else
 | 
				
			||||||
							#endif
 | 
																shadowMapAtlas, shadowMapAtlasTransparent
 | 
				
			||||||
							, lPos.xyz / lPos.w, bias, transparent
 | 
																#endif
 | 
				
			||||||
						);
 | 
																#else
 | 
				
			||||||
 | 
																#ifndef _SingleAtlas
 | 
				
			||||||
 | 
																shadowMapAtlasSpot
 | 
				
			||||||
 | 
																#else
 | 
				
			||||||
 | 
																shadowMapAtlas
 | 
				
			||||||
 | 
																#endif
 | 
				
			||||||
 | 
																#endif
 | 
				
			||||||
 | 
																, lPos.xyz / lPos.w, bias
 | 
				
			||||||
 | 
																#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
																, transparent
 | 
				
			||||||
 | 
																#endif
 | 
				
			||||||
 | 
																);
 | 
				
			||||||
					#else
 | 
										#else
 | 
				
			||||||
							 if (index == 0) direct *= shadowTest(shadowMapSpot[0], shadowMapSpotTransparent[0], lPos.xyz / lPos.w, bias, transparent);
 | 
												 if (index == 0) direct *= shadowTest(shadowMapSpot[0],
 | 
				
			||||||
						else if (index == 1) direct *= shadowTest(shadowMapSpot[1], shadowMapSpotTransparent[1], lPos.xyz / lPos.w, bias, transparent);
 | 
																					#ifdef _ShadowMapTransparent
 | 
				
			||||||
						else if (index == 2) direct *= shadowTest(shadowMapSpot[2], shadowMapSpotTransparent[2], lPos.xyz / lPos.w, bias, transparent);
 | 
																					shadowMapSpotTransparent[0],
 | 
				
			||||||
						else if (index == 3) direct *= shadowTest(shadowMapSpot[3], shadowMapSpotTransparent[3], lPos.xyz / lPos.w, bias, transparent);
 | 
																					#endif
 | 
				
			||||||
 | 
																					lPos.xyz / lPos.w, bias
 | 
				
			||||||
 | 
																					#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
																					, transparent
 | 
				
			||||||
 | 
																					#endif
 | 
				
			||||||
 | 
																					);
 | 
				
			||||||
 | 
											else if (index == 1) direct *= shadowTest(shadowMapSpot[1],
 | 
				
			||||||
 | 
																					#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
																					shadowMapSpotTransparent[1],
 | 
				
			||||||
 | 
																					#endif
 | 
				
			||||||
 | 
																					lPos.xyz / lPos.w, bias
 | 
				
			||||||
 | 
																					#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
																					, transparent
 | 
				
			||||||
 | 
																					#endif
 | 
				
			||||||
 | 
																					);
 | 
				
			||||||
 | 
											else if (index == 2) direct *= shadowTest(shadowMapSpot[2],
 | 
				
			||||||
 | 
																					#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
																					shadowMapSpotTransparent[2],
 | 
				
			||||||
 | 
																					#endif
 | 
				
			||||||
 | 
																					lPos.xyz / lPos.w, bias
 | 
				
			||||||
 | 
																					#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
																					, transparent
 | 
				
			||||||
 | 
																					#endif
 | 
				
			||||||
 | 
																					);
 | 
				
			||||||
 | 
											else if (index == 3) direct *= shadowTest(shadowMapSpot[3],
 | 
				
			||||||
 | 
																					#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
																					shadowMapSpotTransparent[3],
 | 
				
			||||||
 | 
																					#endif
 | 
				
			||||||
 | 
																					lPos.xyz / lPos.w, bias
 | 
				
			||||||
 | 
																					#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
																					, transparent
 | 
				
			||||||
 | 
																					#endif
 | 
				
			||||||
 | 
																					);
 | 
				
			||||||
					#endif
 | 
										#endif
 | 
				
			||||||
				#endif
 | 
									#endif
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
@ -217,24 +329,75 @@ vec3 sampleLight(const vec3 p, const vec3 n, const vec3 v, const float dotNV, co
 | 
				
			|||||||
		if (receiveShadow) {
 | 
							if (receiveShadow) {
 | 
				
			||||||
			#ifdef _SinglePoint
 | 
								#ifdef _SinglePoint
 | 
				
			||||||
			#ifndef _Spot
 | 
								#ifndef _Spot
 | 
				
			||||||
			direct *= PCFCube(shadowMapPoint[0], shadowMapPointTransparent[0], ld, -l, bias, lightProj, n, transparent);
 | 
								direct *= PCFCube(shadowMapPoint[0],
 | 
				
			||||||
 | 
												#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
												shadowMapPointTransparent[0],
 | 
				
			||||||
 | 
												#endif
 | 
				
			||||||
 | 
												ld, -l, bias, lightProj, n
 | 
				
			||||||
 | 
												#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
												, transparent
 | 
				
			||||||
 | 
												#endif
 | 
				
			||||||
 | 
												);
 | 
				
			||||||
			#endif
 | 
								#endif
 | 
				
			||||||
			#endif
 | 
								#endif
 | 
				
			||||||
			#ifdef _Clusters
 | 
								#ifdef _Clusters
 | 
				
			||||||
				#ifdef _ShadowMapAtlas
 | 
									#ifdef _ShadowMapAtlas
 | 
				
			||||||
				direct *= PCFFakeCube(
 | 
									direct *= PCFFakeCube(
 | 
				
			||||||
					#ifndef _SingleAtlas
 | 
														#ifdef _ShadowMapTransparent
 | 
				
			||||||
					shadowMapAtlasPoint, shadowMapAtlasPointTransparent
 | 
														#ifndef _SingleAtlas
 | 
				
			||||||
					#else
 | 
														shadowMapAtlasPoint, shadowMapAtlasPointTransparent
 | 
				
			||||||
					shadowMapAtlas, shadowMapAtlasTransparent
 | 
														#else
 | 
				
			||||||
					#endif
 | 
														shadowMapAtlas, shadowMapAtlasTransparent
 | 
				
			||||||
					, ld, -l, bias, lightProj, n, index, transparent
 | 
														#endif
 | 
				
			||||||
				);
 | 
														#else
 | 
				
			||||||
 | 
														#ifndef _SingleAtlas
 | 
				
			||||||
 | 
														shadowMapAtlasPoint
 | 
				
			||||||
 | 
														#else
 | 
				
			||||||
 | 
														shadowMapAtlas
 | 
				
			||||||
 | 
														#endif
 | 
				
			||||||
 | 
														#endif
 | 
				
			||||||
 | 
														, ld, -l, bias, lightProj, n, index
 | 
				
			||||||
 | 
														#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
														, transparent
 | 
				
			||||||
 | 
														#endif
 | 
				
			||||||
 | 
														);
 | 
				
			||||||
				#else
 | 
									#else
 | 
				
			||||||
					 if (index == 0) direct *= PCFCube(shadowMapPoint[0], shadowMapPointTransparent[0], ld, -l, bias, lightProj, n, transparent);
 | 
										 if (index == 0) direct *= PCFCube(shadowMapPoint[0],
 | 
				
			||||||
				else if (index == 1) direct *= PCFCube(shadowMapPoint[1], shadowMapPointTransparent[1], ld, -l, bias, lightProj, n, transparent);
 | 
																		#ifdef _ShadowMapTransparent
 | 
				
			||||||
				else if (index == 2) direct *= PCFCube(shadowMapPoint[2], shadowMapPointTransparent[2], ld, -l, bias, lightProj, n, transparent);
 | 
																		shadowMapPointTransparent[0],
 | 
				
			||||||
				else if (index == 3) direct *= PCFCube(shadowMapPoint[3], shadowMapPointTransparent[3], ld, -l, bias, lightProj, n, transparent);
 | 
																		#endif
 | 
				
			||||||
 | 
																		ld, -l, bias, lightProj, n
 | 
				
			||||||
 | 
																		#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
																		, transparent
 | 
				
			||||||
 | 
																		#endif
 | 
				
			||||||
 | 
																		);
 | 
				
			||||||
 | 
									else if (index == 1) direct *= PCFCube(shadowMapPoint[1],
 | 
				
			||||||
 | 
																		#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
																		shadowMapPointTransparent[1],
 | 
				
			||||||
 | 
																		#endif
 | 
				
			||||||
 | 
																		ld, -l, bias, lightProj, n
 | 
				
			||||||
 | 
																		#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
																		, transparent
 | 
				
			||||||
 | 
																		#endif
 | 
				
			||||||
 | 
																		);
 | 
				
			||||||
 | 
									else if (index == 2) direct *= PCFCube(shadowMapPoint[2],
 | 
				
			||||||
 | 
																		#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
																		shadowMapPointTransparent[2],
 | 
				
			||||||
 | 
																		#endif
 | 
				
			||||||
 | 
																		ld, -l, bias, lightProj, n
 | 
				
			||||||
 | 
																		#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
																		, transparent
 | 
				
			||||||
 | 
																		#endif
 | 
				
			||||||
 | 
																		);
 | 
				
			||||||
 | 
									else if (index == 3) direct *= PCFCube(shadowMapPoint[3],
 | 
				
			||||||
 | 
																		#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
																		shadowMapPointTransparent[3],
 | 
				
			||||||
 | 
																		#endif
 | 
				
			||||||
 | 
																		ld, -l, bias, lightProj, n
 | 
				
			||||||
 | 
																		#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
																		, transparent
 | 
				
			||||||
 | 
																		#endif
 | 
				
			||||||
 | 
																		);
 | 
				
			||||||
				#endif
 | 
									#endif
 | 
				
			||||||
			#endif
 | 
								#endif
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@ -247,7 +410,10 @@ vec3 sampleLight(const vec3 p, const vec3 n, const vec3 v, const float dotNV, co
 | 
				
			|||||||
vec3 sampleLightVoxels(const vec3 p, const vec3 n, const vec3 v, const float dotNV, const vec3 lp, const vec3 lightCol,
 | 
					vec3 sampleLightVoxels(const vec3 p, const vec3 n, const vec3 v, const float dotNV, const vec3 lp, const vec3 lightCol,
 | 
				
			||||||
	const vec3 albedo, const float rough, const float spec, const vec3 f0
 | 
						const vec3 albedo, const float rough, const float spec, const vec3 f0
 | 
				
			||||||
	#ifdef _ShadowMap
 | 
						#ifdef _ShadowMap
 | 
				
			||||||
		, int index, float bias, bool receiveShadow, bool transparent
 | 
							, int index, float bias, bool receiveShadow
 | 
				
			||||||
 | 
						#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
							, bool transparent
 | 
				
			||||||
 | 
						#endif
 | 
				
			||||||
	#endif
 | 
						#endif
 | 
				
			||||||
	#ifdef _Spot
 | 
						#ifdef _Spot
 | 
				
			||||||
		, const bool isSpot, const float spotSize, float spotBlend, vec3 spotDir, vec2 scale, vec3 right
 | 
							, const bool isSpot, const float spotSize, float spotBlend, vec3 spotDir, vec2 scale, vec3 right
 | 
				
			||||||
@ -285,15 +451,55 @@ vec3 sampleLightVoxels(const vec3 p, const vec3 n, const vec3 v, const float dot
 | 
				
			|||||||
	#ifdef _ShadowMap
 | 
						#ifdef _ShadowMap
 | 
				
			||||||
		if (receiveShadow) {
 | 
							if (receiveShadow) {
 | 
				
			||||||
			#ifdef _SinglePoint
 | 
								#ifdef _SinglePoint
 | 
				
			||||||
			vec4 lPos = LWVPSpotArray[0] * vec4(p + n * bias * 10, 1.0);
 | 
								vec4 lPos = LWVPSpot[0] * vec4(p + n * bias * 10, 1.0);
 | 
				
			||||||
			direct *= shadowTest(shadowMapSpot[0], shadowMapSpotTransparent[0], lPos.xyz / lPos.w, bias, transparent);
 | 
								direct *= shadowTest(shadowMapSpot[0],
 | 
				
			||||||
 | 
													#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
													shadowMapSpotTransparent[0],
 | 
				
			||||||
 | 
													#endif
 | 
				
			||||||
 | 
													lPos.xyz / lPos.w, bias
 | 
				
			||||||
 | 
													#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
													, transparent
 | 
				
			||||||
 | 
													#endif
 | 
				
			||||||
 | 
													);
 | 
				
			||||||
			#endif
 | 
								#endif
 | 
				
			||||||
			#ifdef _Clusters
 | 
								#ifdef _Clusters
 | 
				
			||||||
			vec4 lPos = LWVPSpotArray[index] * vec4(p + n * bias * 10, 1.0);
 | 
								vec4 lPos = LWVPSpot[index] * vec4(p + n * bias * 10, 1.0);
 | 
				
			||||||
			if (index == 0) direct *= shadowTest(shadowMapSpot[0], shadowMapSpotTransparent[0], lPos.xyz / lPos.w, bias, transparent);
 | 
								if (index == 0) direct *= shadowTest(shadowMapSpot[0],
 | 
				
			||||||
			else if (index == 1) direct *= shadowTest(shadowMapSpot[1], shadowMapSpotTransparent[1], lPos.xyz / lPos.w, bias, transparent);
 | 
																	#ifdef _ShadowMapTransparent
 | 
				
			||||||
			else if (index == 2) direct *= shadowTest(shadowMapSpot[2], shadowMapSpotTransparent[2], lPos.xyz / lPos.w, bias, transparent);
 | 
																	shadowMapSpotTransparent[0],
 | 
				
			||||||
			else if (index == 3) direct *= shadowTest(shadowMapSpot[3], shadowMapSpotTransparent[3], lPos.xyz / lPos.w, bias, transparent);
 | 
																	#endif
 | 
				
			||||||
 | 
																	lPos.xyz / lPos.w, bias
 | 
				
			||||||
 | 
																	#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
																	, transparent
 | 
				
			||||||
 | 
																	#endif
 | 
				
			||||||
 | 
																	);
 | 
				
			||||||
 | 
								else if (index == 1) direct *= shadowTest(shadowMapSpot[1],
 | 
				
			||||||
 | 
																		#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
																		shadowMapSpotTransparent[1],
 | 
				
			||||||
 | 
																		#endif
 | 
				
			||||||
 | 
																		lPos.xyz / lPos.w, bias
 | 
				
			||||||
 | 
																		#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
																		, transparent
 | 
				
			||||||
 | 
																		#endif
 | 
				
			||||||
 | 
																		);
 | 
				
			||||||
 | 
								else if (index == 2) direct *= shadowTest(shadowMapSpot[2],
 | 
				
			||||||
 | 
																		#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
																		shadowMapSpotTransparent[2],
 | 
				
			||||||
 | 
																		#endif
 | 
				
			||||||
 | 
																		lPos.xyz / lPos.w, bias
 | 
				
			||||||
 | 
																		#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
																		, transparent
 | 
				
			||||||
 | 
																		#endif
 | 
				
			||||||
 | 
																		);
 | 
				
			||||||
 | 
								else if (index == 3) direct *= shadowTest(shadowMapSpot[3],
 | 
				
			||||||
 | 
																		#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
																		shadowMapSpotTransparent[3],
 | 
				
			||||||
 | 
																		#endif
 | 
				
			||||||
 | 
																		lPos.xyz / lPos.w, bias
 | 
				
			||||||
 | 
																		#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
																		, transparent
 | 
				
			||||||
 | 
																		#endif
 | 
				
			||||||
 | 
																		);
 | 
				
			||||||
			#endif
 | 
								#endif
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	#endif
 | 
						#endif
 | 
				
			||||||
@ -307,25 +513,76 @@ vec3 sampleLightVoxels(const vec3 p, const vec3 n, const vec3 v, const float dot
 | 
				
			|||||||
		#ifdef _ShadowMap
 | 
							#ifdef _ShadowMap
 | 
				
			||||||
			if (receiveShadow) {
 | 
								if (receiveShadow) {
 | 
				
			||||||
				#ifdef _SinglePoint
 | 
									#ifdef _SinglePoint
 | 
				
			||||||
				vec4 lPos = LWVPSpot[0] * vec4(p + n * bias * 10, 1.0);
 | 
									vec4 lPos = LWVPSpotArray[0] * vec4(p + n * bias * 10, 1.0);
 | 
				
			||||||
				direct *= shadowTest(shadowMapSpot[0], shadowMapSpotTransparent[0], lPos.xyz / lPos.w, bias, transparent);
 | 
									direct *= shadowTest(shadowMapSpot[0],
 | 
				
			||||||
 | 
														#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
														shadowMapSpotTransparent[0],
 | 
				
			||||||
 | 
														#endif
 | 
				
			||||||
 | 
														lPos.xyz / lPos.w, bias
 | 
				
			||||||
 | 
														#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
														, transparent
 | 
				
			||||||
 | 
														#endif
 | 
				
			||||||
 | 
														);
 | 
				
			||||||
				#endif
 | 
									#endif
 | 
				
			||||||
				#ifdef _Clusters
 | 
									#ifdef _Clusters
 | 
				
			||||||
					vec4 lPos = LWVPSpot[index] * vec4(p + n * bias * 10, 1.0);
 | 
										vec4 lPos = LWVPSpotArray[index] * vec4(p + n * bias * 10, 1.0);
 | 
				
			||||||
					#ifdef _ShadowMapAtlas
 | 
										#ifdef _ShadowMapAtlas
 | 
				
			||||||
						direct *= shadowTest(
 | 
											direct *= shadowTest(
 | 
				
			||||||
							#ifndef _SingleAtlas
 | 
																#ifdef _ShadowMapTransparent
 | 
				
			||||||
							shadowMapAtlasSpot, shadowMapAtlasSpotTransparent
 | 
																#ifndef _SingleAtlas
 | 
				
			||||||
							#else
 | 
																shadowMapAtlasSpot, shadowMapAtlasSpotTransparent
 | 
				
			||||||
							shadowMapAtlas, shadowMapAtlasTransparent
 | 
																#else
 | 
				
			||||||
							#endif
 | 
																shadowMapAtlas, shadowMapAtlasTransparent
 | 
				
			||||||
							, lPos.xyz / lPos.w, bias, transparent
 | 
																#endif
 | 
				
			||||||
						);
 | 
																#else
 | 
				
			||||||
 | 
																#ifndef _SingleAtlas
 | 
				
			||||||
 | 
																shadowMapAtlasSpot
 | 
				
			||||||
 | 
																#else
 | 
				
			||||||
 | 
																shadowMapAtlas
 | 
				
			||||||
 | 
																#endif
 | 
				
			||||||
 | 
																#endif
 | 
				
			||||||
 | 
																, lPos.xyz / lPos.w, bias
 | 
				
			||||||
 | 
																#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
																, transparent
 | 
				
			||||||
 | 
																#endif
 | 
				
			||||||
 | 
																);
 | 
				
			||||||
					#else
 | 
										#else
 | 
				
			||||||
							 if (index == 0) direct *= shadowTest(shadowMapSpot[0], shadowMapSpotTransparent[0], lPos.xyz / lPos.w, bias, transparent);
 | 
												 if (index == 0) direct *= shadowTest(shadowMapSpot[0],
 | 
				
			||||||
						else if (index == 1) direct *= shadowTest(shadowMapSpot[1], shadowMapSpotTransparent[1], lPos.xyz / lPos.w, bias, transparent);
 | 
																					#ifdef _ShadowMapTransparent
 | 
				
			||||||
						else if (index == 2) direct *= shadowTest(shadowMapSpot[2], shadowMapSpotTransparent[2], lPos.xyz / lPos.w, bias, transparent);
 | 
																					shadowMapSpotTransparent[0],
 | 
				
			||||||
						else if (index == 3) direct *= shadowTest(shadowMapSpot[3], shadowMapSpotTransparent[3], lPos.xyz / lPos.w, bias, transparent);
 | 
																					#endif
 | 
				
			||||||
 | 
																					lPos.xyz / lPos.w, bias
 | 
				
			||||||
 | 
																					#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
																					, transparent
 | 
				
			||||||
 | 
																					#endif
 | 
				
			||||||
 | 
																					);
 | 
				
			||||||
 | 
											else if (index == 1) direct *= shadowTest(shadowMapSpot[1],
 | 
				
			||||||
 | 
																					#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
																					shadowMapSpotTransparent[1],
 | 
				
			||||||
 | 
																					#endif
 | 
				
			||||||
 | 
																					lPos.xyz / lPos.w, bias
 | 
				
			||||||
 | 
																					#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
																					, transparent
 | 
				
			||||||
 | 
																					#endif
 | 
				
			||||||
 | 
																					);
 | 
				
			||||||
 | 
											else if (index == 2) direct *= shadowTest(shadowMapSpot[2],
 | 
				
			||||||
 | 
																					#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
																					shadowMapSpotTransparent[2],
 | 
				
			||||||
 | 
																					#endif
 | 
				
			||||||
 | 
																					lPos.xyz / lPos.w, bias
 | 
				
			||||||
 | 
																					#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
																					, transparent
 | 
				
			||||||
 | 
																					#endif
 | 
				
			||||||
 | 
																					);
 | 
				
			||||||
 | 
											else if (index == 3) direct *= shadowTest(shadowMapSpot[3],
 | 
				
			||||||
 | 
																					#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
																					shadowMapSpotTransparent[3],
 | 
				
			||||||
 | 
																					#endif
 | 
				
			||||||
 | 
																					lPos.xyz / lPos.w, bias
 | 
				
			||||||
 | 
																					#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
																					, transparent
 | 
				
			||||||
 | 
																					#endif
 | 
				
			||||||
 | 
																					);
 | 
				
			||||||
					#endif
 | 
										#endif
 | 
				
			||||||
				#endif
 | 
									#endif
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
@ -342,24 +599,75 @@ vec3 sampleLightVoxels(const vec3 p, const vec3 n, const vec3 v, const float dot
 | 
				
			|||||||
		if (receiveShadow) {
 | 
							if (receiveShadow) {
 | 
				
			||||||
			#ifdef _SinglePoint
 | 
								#ifdef _SinglePoint
 | 
				
			||||||
			#ifndef _Spot
 | 
								#ifndef _Spot
 | 
				
			||||||
			direct *= PCFCube(shadowMapPoint[0], shadowMapPointTransparent[0], ld, -l, bias, lightProj, n, transparent);
 | 
								direct *= PCFCube(shadowMapPoint[0],
 | 
				
			||||||
 | 
												#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
												shadowMapPointTransparent[0],
 | 
				
			||||||
 | 
												#endif
 | 
				
			||||||
 | 
												ld, -l, bias, lightProj, n
 | 
				
			||||||
 | 
												#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
												, transparent
 | 
				
			||||||
 | 
												#endif
 | 
				
			||||||
 | 
												);
 | 
				
			||||||
			#endif
 | 
								#endif
 | 
				
			||||||
			#endif
 | 
								#endif
 | 
				
			||||||
			#ifdef _Clusters
 | 
								#ifdef _Clusters
 | 
				
			||||||
				#ifdef _ShadowMapAtlas
 | 
									#ifdef _ShadowMapAtlas
 | 
				
			||||||
				direct *= PCFFakeCube(
 | 
									direct *= PCFFakeCube(
 | 
				
			||||||
					#ifndef _SingleAtlas
 | 
														#ifdef _ShadowMapTransparent
 | 
				
			||||||
					shadowMapAtlasPoint, shadowMapAtlasPointTransparent
 | 
														#ifndef _SingleAtlas
 | 
				
			||||||
					#else
 | 
														shadowMapAtlasPoint, shadowMapAtlasPointTransparent
 | 
				
			||||||
					shadowMapAtlas, shadowMapAtlasTransparent
 | 
														#else
 | 
				
			||||||
					#endif
 | 
														shadowMapAtlas, shadowMapAtlasTransparent
 | 
				
			||||||
					, ld, -l, bias, lightProj, n, index, transparent
 | 
														#endif
 | 
				
			||||||
				);
 | 
														#else
 | 
				
			||||||
 | 
														#ifndef _SingleAtlas
 | 
				
			||||||
 | 
														shadowMapAtlasPoint
 | 
				
			||||||
 | 
														#else
 | 
				
			||||||
 | 
														shadowMapAtlas
 | 
				
			||||||
 | 
														#endif
 | 
				
			||||||
 | 
														#endif
 | 
				
			||||||
 | 
														, ld, -l, bias, lightProj, n, index
 | 
				
			||||||
 | 
														#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
														, transparent
 | 
				
			||||||
 | 
														#endif
 | 
				
			||||||
 | 
														);
 | 
				
			||||||
				#else
 | 
									#else
 | 
				
			||||||
					 if (index == 0) direct *= PCFCube(shadowMapPoint[0], shadowMapPointTransparent[0], ld, -l, bias, lightProj, n, transparent);
 | 
										 if (index == 0) direct *= PCFCube(shadowMapPoint[0],
 | 
				
			||||||
				else if (index == 1) direct *= PCFCube(shadowMapPoint[1], shadowMapPointTransparent[1], ld, -l, bias, lightProj, n, transparent);
 | 
																		#ifdef _ShadowMapTransparent
 | 
				
			||||||
				else if (index == 2) direct *= PCFCube(shadowMapPoint[2], shadowMapPointTransparent[2], ld, -l, bias, lightProj, n, transparent);
 | 
																		shadowMapPointTransparent[0],
 | 
				
			||||||
				else if (index == 3) direct *= PCFCube(shadowMapPoint[3], shadowMapPointTransparent[3], ld, -l, bias, lightProj, n, transparent);
 | 
																		#endif
 | 
				
			||||||
 | 
																		ld, -l, bias, lightProj, n
 | 
				
			||||||
 | 
																		#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
																		, transparent
 | 
				
			||||||
 | 
																		#endif
 | 
				
			||||||
 | 
																		);
 | 
				
			||||||
 | 
									else if (index == 1) direct *= PCFCube(shadowMapPoint[1],
 | 
				
			||||||
 | 
																		#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
																		shadowMapPointTransparent[1],
 | 
				
			||||||
 | 
																		#endif
 | 
				
			||||||
 | 
																		ld, -l, bias, lightProj, n
 | 
				
			||||||
 | 
																		#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
																		, transparent
 | 
				
			||||||
 | 
																		#endif
 | 
				
			||||||
 | 
																		);
 | 
				
			||||||
 | 
									else if (index == 2) direct *= PCFCube(shadowMapPoint[2],
 | 
				
			||||||
 | 
																		#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
																		shadowMapPointTransparent[2],
 | 
				
			||||||
 | 
																		#endif
 | 
				
			||||||
 | 
																		ld, -l, bias, lightProj, n
 | 
				
			||||||
 | 
																		#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
																		, transparent
 | 
				
			||||||
 | 
																		#endif
 | 
				
			||||||
 | 
																		);
 | 
				
			||||||
 | 
									else if (index == 3) direct *= PCFCube(shadowMapPoint[3],
 | 
				
			||||||
 | 
																		#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
																		shadowMapPointTransparent[3],
 | 
				
			||||||
 | 
																		#endif
 | 
				
			||||||
 | 
																		ld, -l, bias, lightProj, n
 | 
				
			||||||
 | 
																		#ifdef _ShadowMapTransparent
 | 
				
			||||||
 | 
																		, transparent
 | 
				
			||||||
 | 
																		#endif
 | 
				
			||||||
 | 
																		);
 | 
				
			||||||
				#endif
 | 
									#endif
 | 
				
			||||||
			#endif
 | 
								#endif
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user