forked from LeenkxTeam/LNXSDK
		
	Update leenkx/Shaders/std/light.glsl
This commit is contained in:
		| @ -31,40 +31,54 @@ | ||||
| 		#ifdef _Spot | ||||
| 			#ifndef _LTC | ||||
| 				uniform sampler2DShadow shadowMapSpot[1]; | ||||
| 				#ifdef _ShadowMapTransparent | ||||
| 				uniform sampler2D shadowMapSpotTransparent[1]; | ||||
| 				uniform mat4 LWVPSpot[1]; | ||||
| 				#endif | ||||
| 				uniform mat4 LWVPSpotArray[1]; | ||||
| 			#endif | ||||
| 		#else | ||||
| 			uniform samplerCubeShadow shadowMapPoint[1]; | ||||
| 			#ifdef _ShadowMapTransparent | ||||
| 			uniform samplerCube shadowMapPointTransparent[1]; | ||||
| 			#endif | ||||
| 			uniform vec2 lightProj; | ||||
| 		#endif | ||||
| 	#endif | ||||
| 	#ifdef _Clusters | ||||
| 		#ifdef _SingleAtlas | ||||
| 		//!uniform sampler2DShadow shadowMapAtlas; | ||||
| 		#ifdef _ShadowMapTransparent | ||||
| 		//!uniform sampler2D shadowMapAtlasTransparent; | ||||
| 		#endif | ||||
| 		#endif | ||||
| 		uniform vec2 lightProj; | ||||
| 		#ifdef _ShadowMapAtlas | ||||
| 		#ifndef _SingleAtlas | ||||
| 		uniform sampler2DShadow shadowMapAtlasPoint; | ||||
| 		#ifdef _ShadowMapTransparent | ||||
| 		uniform sampler2D shadowMapAtlasPointTransparent; | ||||
| 		#endif | ||||
| 		#endif | ||||
| 		#else | ||||
| 		uniform samplerCubeShadow shadowMapPoint[4]; | ||||
| 		#ifdef _ShadowMapTransparent | ||||
| 		uniform samplerCube shadowMapPointTransparent[4]; | ||||
| 		#endif | ||||
| 		#endif | ||||
| 		#ifdef _Spot | ||||
| 			#ifdef _ShadowMapAtlas | ||||
| 			#ifndef _SingleAtlas | ||||
| 			uniform sampler2DShadow shadowMapAtlasSpot; | ||||
| 			#ifdef _ShadowMapTransparent | ||||
| 			uniform sampler2D shadowMapAtlasSpotTransparent; | ||||
| 			#endif | ||||
| 			#endif | ||||
| 			#else | ||||
| 			uniform sampler2DShadow shadowMapSpot[4]; | ||||
| 			#ifdef _ShadowMapTransparent | ||||
| 			uniform sampler2D shadowMapSpotTransparent[4]; | ||||
| 			#endif | ||||
| 			#endif | ||||
| 			uniform mat4 LWVPSpotArray[maxLightsCluster]; | ||||
| 		#endif | ||||
| 	#endif | ||||
| @ -81,12 +95,16 @@ uniform sampler2D sltcMag; | ||||
| #ifndef _Spot | ||||
| 	#ifdef _SinglePoint | ||||
| 		uniform sampler2DShadow shadowMapSpot[1]; | ||||
| 		#ifdef _ShadowMapTransparent | ||||
| 		uniform sampler2D shadowMapSpotTransparent[1]; | ||||
| 		uniform mat4 LWVPSpot[1]; | ||||
| 		#endif | ||||
| 		uniform mat4 LWVPSpotArray[1]; | ||||
| 	#endif | ||||
| 	#ifdef _Clusters | ||||
| 		uniform sampler2DShadow shadowMapSpot[maxLightsCluster]; | ||||
| 		#ifdef _ShadowMapTransparent | ||||
| 		uniform sampler2D shadowMapSpotTransparent[maxLightsCluster]; | ||||
| 		#endif | ||||
| 		uniform mat4 LWVPSpotArray[maxLightsCluster]; | ||||
| 	#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, | ||||
| 	const vec3 albedo, const float rough, const float spec, const vec3 f0 | ||||
| 	#ifdef _ShadowMap | ||||
| 		, int index, float bias, bool receiveShadow, bool transparent | ||||
| 		, int index, float bias, bool receiveShadow | ||||
| 	#ifdef _ShadowMapTransparent | ||||
| 		, bool transparent | ||||
| 	#endif | ||||
| 	#endif | ||||
| 	#ifdef _Spot | ||||
| 		, 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 | ||||
| 	vec3 lightDir = l; | ||||
| 	#ifdef _Spot | ||||
| 	if(isSpot) | ||||
| 	if (isSpot) | ||||
| 		lightDir = spotDir; | ||||
| 	#endif | ||||
| 	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 | ||||
| 		if (receiveShadow) { | ||||
| 			#ifdef _SinglePoint | ||||
| 			vec4 lPos = LWVPSpotArray[0] * vec4(p + n * bias * 10, 1.0); | ||||
| 			direct *= shadowTest(shadowMapSpot[0], shadowMapSpotTransparent[0], lPos.xyz / lPos.w, bias, transparent); | ||||
| 			vec4 lPos = LWVPSpot[0] * vec4(p + n * bias * 10, 1.0); | ||||
| 			direct *= shadowTest(shadowMapSpot[0], | ||||
| 								#ifdef _ShadowMapTransparent | ||||
| 								shadowMapSpotTransparent[0], | ||||
| 								#endif | ||||
| 								lPos.xyz / lPos.w, bias | ||||
| 								#ifdef _ShadowMapTransparent | ||||
| 								, transparent | ||||
| 								#endif | ||||
| 								); | ||||
| 			#endif | ||||
| 			#ifdef _Clusters | ||||
| 			vec4 lPos = LWVPSpotArray[index] * vec4(p + n * bias * 10, 1.0); | ||||
| 			if (index == 0) direct *= shadowTest(shadowMapSpot[0], shadowMapSpotTransparent[0], lPos.xyz / lPos.w, bias, transparent); | ||||
| 			else if (index == 1) direct *= shadowTest(shadowMapSpot[1], shadowMapSpotTransparent[1], lPos.xyz / lPos.w, bias, transparent); | ||||
| 			else if (index == 2) direct *= shadowTest(shadowMapSpot[2], shadowMapSpotTransparent[2], lPos.xyz / lPos.w, bias, transparent); | ||||
| 			else if (index == 3) direct *= shadowTest(shadowMapSpot[3], shadowMapSpotTransparent[3], lPos.xyz / lPos.w, bias, transparent); | ||||
| 			vec4 lPos = LWVPSpot[index] * vec4(p + n * bias * 10, 1.0); | ||||
| 			if (index == 0) direct *= shadowTest(shadowMapSpot[0], | ||||
| 												#ifdef _ShadowMapTransparent | ||||
| 												shadowMapSpotTransparent[0], | ||||
| 												#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 | ||||
| @ -182,25 +243,76 @@ vec3 sampleLight(const vec3 p, const vec3 n, const vec3 v, const float dotNV, co | ||||
| 		#ifdef _ShadowMap | ||||
| 			if (receiveShadow) { | ||||
| 				#ifdef _SinglePoint | ||||
| 				vec4 lPos = LWVPSpot[0] * vec4(p + n * bias * 10, 1.0); | ||||
| 				direct *= shadowTest(shadowMapSpot[0], shadowMapSpotTransparent[0], lPos.xyz / lPos.w, bias, transparent); | ||||
| 				vec4 lPos = LWVPSpotArray[0] * vec4(p + n * bias * 10, 1.0); | ||||
| 				direct *= shadowTest(shadowMapSpot[0], | ||||
| 									#ifdef _ShadowMapTransparent | ||||
| 									shadowMapSpotTransparent[0], | ||||
| 									#endif | ||||
| 									lPos.xyz / lPos.w, bias | ||||
| 									#ifdef _ShadowMapTransparent | ||||
| 									, transparent | ||||
| 									#endif | ||||
| 									); | ||||
| 				#endif | ||||
| 				#ifdef _Clusters | ||||
| 					vec4 lPos = LWVPSpotArray[index] * vec4(p + n * bias * 10, 1.0); | ||||
| 					#ifdef _ShadowMapAtlas | ||||
| 						direct *= shadowTest( | ||||
| 							#ifndef _SingleAtlas | ||||
| 							shadowMapAtlasSpot, shadowMapAtlasSpotTransparent | ||||
| 							#else | ||||
| 							shadowMapAtlas, shadowMapAtlasTransparent | ||||
| 							#endif | ||||
| 							, lPos.xyz / lPos.w, bias, transparent | ||||
| 						); | ||||
| 											#ifdef _ShadowMapTransparent | ||||
| 											#ifndef _SingleAtlas | ||||
| 											shadowMapAtlasSpot, shadowMapAtlasSpotTransparent | ||||
| 											#else | ||||
| 											shadowMapAtlas, shadowMapAtlasTransparent | ||||
| 											#endif | ||||
| 											#else | ||||
| 											#ifndef _SingleAtlas | ||||
| 											shadowMapAtlasSpot | ||||
| 											#else | ||||
| 											shadowMapAtlas | ||||
| 											#endif | ||||
| 											#endif | ||||
| 											, lPos.xyz / lPos.w, bias | ||||
| 											#ifdef _ShadowMapTransparent | ||||
| 											, transparent | ||||
| 											#endif | ||||
| 											); | ||||
| 					#else | ||||
| 							 if (index == 0) direct *= shadowTest(shadowMapSpot[0], shadowMapSpotTransparent[0], lPos.xyz / lPos.w, bias, transparent); | ||||
| 						else if (index == 1) direct *= shadowTest(shadowMapSpot[1], shadowMapSpotTransparent[1], lPos.xyz / lPos.w, bias, transparent); | ||||
| 						else if (index == 2) direct *= shadowTest(shadowMapSpot[2], shadowMapSpotTransparent[2], lPos.xyz / lPos.w, bias, transparent); | ||||
| 						else if (index == 3) direct *= shadowTest(shadowMapSpot[3], shadowMapSpotTransparent[3], lPos.xyz / lPos.w, bias, transparent); | ||||
| 							 if (index == 0) direct *= shadowTest(shadowMapSpot[0], | ||||
| 																#ifdef _ShadowMapTransparent | ||||
| 																shadowMapSpotTransparent[0], | ||||
| 																#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 | ||||
| 			} | ||||
| @ -217,24 +329,75 @@ vec3 sampleLight(const vec3 p, const vec3 n, const vec3 v, const float dotNV, co | ||||
| 		if (receiveShadow) { | ||||
| 			#ifdef _SinglePoint | ||||
| 			#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 | ||||
| 			#ifdef _Clusters | ||||
| 				#ifdef _ShadowMapAtlas | ||||
| 				direct *= PCFFakeCube( | ||||
| 					#ifndef _SingleAtlas | ||||
| 					shadowMapAtlasPoint, shadowMapAtlasPointTransparent | ||||
| 					#else | ||||
| 					shadowMapAtlas, shadowMapAtlasTransparent | ||||
| 					#endif | ||||
| 					, ld, -l, bias, lightProj, n, index, transparent | ||||
| 				); | ||||
| 									#ifdef _ShadowMapTransparent | ||||
| 									#ifndef _SingleAtlas | ||||
| 									shadowMapAtlasPoint, shadowMapAtlasPointTransparent | ||||
| 									#else | ||||
| 									shadowMapAtlas, shadowMapAtlasTransparent | ||||
| 									#endif | ||||
| 									#else | ||||
| 									#ifndef _SingleAtlas | ||||
| 									shadowMapAtlasPoint | ||||
| 									#else | ||||
| 									shadowMapAtlas | ||||
| 									#endif | ||||
| 									#endif | ||||
| 									, ld, -l, bias, lightProj, n, index | ||||
| 									#ifdef _ShadowMapTransparent | ||||
| 									, transparent | ||||
| 									#endif | ||||
| 									); | ||||
| 				#else | ||||
| 					 if (index == 0) direct *= PCFCube(shadowMapPoint[0], shadowMapPointTransparent[0], ld, -l, bias, lightProj, n, transparent); | ||||
| 				else if (index == 1) direct *= PCFCube(shadowMapPoint[1], shadowMapPointTransparent[1], ld, -l, bias, lightProj, n, transparent); | ||||
| 				else if (index == 2) direct *= PCFCube(shadowMapPoint[2], shadowMapPointTransparent[2], ld, -l, bias, lightProj, n, transparent); | ||||
| 				else if (index == 3) direct *= PCFCube(shadowMapPoint[3], shadowMapPointTransparent[3], ld, -l, bias, lightProj, n, transparent); | ||||
| 					 if (index == 0) direct *= PCFCube(shadowMapPoint[0], | ||||
| 													#ifdef _ShadowMapTransparent | ||||
| 													shadowMapPointTransparent[0], | ||||
| 													#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 | ||||
| 		} | ||||
| @ -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, | ||||
| 	const vec3 albedo, const float rough, const float spec, const vec3 f0 | ||||
| 	#ifdef _ShadowMap | ||||
| 		, int index, float bias, bool receiveShadow, bool transparent | ||||
| 		, int index, float bias, bool receiveShadow | ||||
| 	#ifdef _ShadowMapTransparent | ||||
| 		, bool transparent | ||||
| 	#endif | ||||
| 	#endif | ||||
| 	#ifdef _Spot | ||||
| 		, 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 | ||||
| 		if (receiveShadow) { | ||||
| 			#ifdef _SinglePoint | ||||
| 			vec4 lPos = LWVPSpotArray[0] * vec4(p + n * bias * 10, 1.0); | ||||
| 			direct *= shadowTest(shadowMapSpot[0], shadowMapSpotTransparent[0], lPos.xyz / lPos.w, bias, transparent); | ||||
| 			vec4 lPos = LWVPSpot[0] * vec4(p + n * bias * 10, 1.0); | ||||
| 			direct *= shadowTest(shadowMapSpot[0], | ||||
| 								#ifdef _ShadowMapTransparent | ||||
| 								shadowMapSpotTransparent[0], | ||||
| 								#endif | ||||
| 								lPos.xyz / lPos.w, bias | ||||
| 								#ifdef _ShadowMapTransparent | ||||
| 								, transparent | ||||
| 								#endif | ||||
| 								); | ||||
| 			#endif | ||||
| 			#ifdef _Clusters | ||||
| 			vec4 lPos = LWVPSpotArray[index] * vec4(p + n * bias * 10, 1.0); | ||||
| 			if (index == 0) direct *= shadowTest(shadowMapSpot[0], shadowMapSpotTransparent[0], lPos.xyz / lPos.w, bias, transparent); | ||||
| 			else if (index == 1) direct *= shadowTest(shadowMapSpot[1], shadowMapSpotTransparent[1], lPos.xyz / lPos.w, bias, transparent); | ||||
| 			else if (index == 2) direct *= shadowTest(shadowMapSpot[2], shadowMapSpotTransparent[2], lPos.xyz / lPos.w, bias, transparent); | ||||
| 			else if (index == 3) direct *= shadowTest(shadowMapSpot[3], shadowMapSpotTransparent[3], lPos.xyz / lPos.w, bias, transparent); | ||||
| 			vec4 lPos = LWVPSpot[index] * vec4(p + n * bias * 10, 1.0); | ||||
| 			if (index == 0) direct *= shadowTest(shadowMapSpot[0], | ||||
| 												#ifdef _ShadowMapTransparent | ||||
| 												shadowMapSpotTransparent[0], | ||||
| 												#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 | ||||
| @ -307,25 +513,76 @@ vec3 sampleLightVoxels(const vec3 p, const vec3 n, const vec3 v, const float dot | ||||
| 		#ifdef _ShadowMap | ||||
| 			if (receiveShadow) { | ||||
| 				#ifdef _SinglePoint | ||||
| 				vec4 lPos = LWVPSpot[0] * vec4(p + n * bias * 10, 1.0); | ||||
| 				direct *= shadowTest(shadowMapSpot[0], shadowMapSpotTransparent[0], lPos.xyz / lPos.w, bias, transparent); | ||||
| 				vec4 lPos = LWVPSpotArray[0] * vec4(p + n * bias * 10, 1.0); | ||||
| 				direct *= shadowTest(shadowMapSpot[0], | ||||
| 									#ifdef _ShadowMapTransparent | ||||
| 									shadowMapSpotTransparent[0], | ||||
| 									#endif | ||||
| 									lPos.xyz / lPos.w, bias | ||||
| 									#ifdef _ShadowMapTransparent | ||||
| 									, transparent | ||||
| 									#endif | ||||
| 									); | ||||
| 				#endif | ||||
| 				#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 | ||||
| 						direct *= shadowTest( | ||||
| 							#ifndef _SingleAtlas | ||||
| 							shadowMapAtlasSpot, shadowMapAtlasSpotTransparent | ||||
| 							#else | ||||
| 							shadowMapAtlas, shadowMapAtlasTransparent | ||||
| 							#endif | ||||
| 							, lPos.xyz / lPos.w, bias, transparent | ||||
| 						); | ||||
| 											#ifdef _ShadowMapTransparent | ||||
| 											#ifndef _SingleAtlas | ||||
| 											shadowMapAtlasSpot, shadowMapAtlasSpotTransparent | ||||
| 											#else | ||||
| 											shadowMapAtlas, shadowMapAtlasTransparent | ||||
| 											#endif | ||||
| 											#else | ||||
| 											#ifndef _SingleAtlas | ||||
| 											shadowMapAtlasSpot | ||||
| 											#else | ||||
| 											shadowMapAtlas | ||||
| 											#endif | ||||
| 											#endif | ||||
| 											, lPos.xyz / lPos.w, bias | ||||
| 											#ifdef _ShadowMapTransparent | ||||
| 											, transparent | ||||
| 											#endif | ||||
| 											); | ||||
| 					#else | ||||
| 							 if (index == 0) direct *= shadowTest(shadowMapSpot[0], shadowMapSpotTransparent[0], lPos.xyz / lPos.w, bias, transparent); | ||||
| 						else if (index == 1) direct *= shadowTest(shadowMapSpot[1], shadowMapSpotTransparent[1], lPos.xyz / lPos.w, bias, transparent); | ||||
| 						else if (index == 2) direct *= shadowTest(shadowMapSpot[2], shadowMapSpotTransparent[2], lPos.xyz / lPos.w, bias, transparent); | ||||
| 						else if (index == 3) direct *= shadowTest(shadowMapSpot[3], shadowMapSpotTransparent[3], lPos.xyz / lPos.w, bias, transparent); | ||||
| 							 if (index == 0) direct *= shadowTest(shadowMapSpot[0], | ||||
| 																#ifdef _ShadowMapTransparent | ||||
| 																shadowMapSpotTransparent[0], | ||||
| 																#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 | ||||
| 			} | ||||
| @ -342,24 +599,75 @@ vec3 sampleLightVoxels(const vec3 p, const vec3 n, const vec3 v, const float dot | ||||
| 		if (receiveShadow) { | ||||
| 			#ifdef _SinglePoint | ||||
| 			#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 | ||||
| 			#ifdef _Clusters | ||||
| 				#ifdef _ShadowMapAtlas | ||||
| 				direct *= PCFFakeCube( | ||||
| 					#ifndef _SingleAtlas | ||||
| 					shadowMapAtlasPoint, shadowMapAtlasPointTransparent | ||||
| 					#else | ||||
| 					shadowMapAtlas, shadowMapAtlasTransparent | ||||
| 					#endif | ||||
| 					, ld, -l, bias, lightProj, n, index, transparent | ||||
| 				); | ||||
| 									#ifdef _ShadowMapTransparent | ||||
| 									#ifndef _SingleAtlas | ||||
| 									shadowMapAtlasPoint, shadowMapAtlasPointTransparent | ||||
| 									#else | ||||
| 									shadowMapAtlas, shadowMapAtlasTransparent | ||||
| 									#endif | ||||
| 									#else | ||||
| 									#ifndef _SingleAtlas | ||||
| 									shadowMapAtlasPoint | ||||
| 									#else | ||||
| 									shadowMapAtlas | ||||
| 									#endif | ||||
| 									#endif | ||||
| 									, ld, -l, bias, lightProj, n, index | ||||
| 									#ifdef _ShadowMapTransparent | ||||
| 									, transparent | ||||
| 									#endif | ||||
| 									); | ||||
| 				#else | ||||
| 					 if (index == 0) direct *= PCFCube(shadowMapPoint[0], shadowMapPointTransparent[0], ld, -l, bias, lightProj, n, transparent); | ||||
| 				else if (index == 1) direct *= PCFCube(shadowMapPoint[1], shadowMapPointTransparent[1], ld, -l, bias, lightProj, n, transparent); | ||||
| 				else if (index == 2) direct *= PCFCube(shadowMapPoint[2], shadowMapPointTransparent[2], ld, -l, bias, lightProj, n, transparent); | ||||
| 				else if (index == 3) direct *= PCFCube(shadowMapPoint[3], shadowMapPointTransparent[3], ld, -l, bias, lightProj, n, transparent); | ||||
| 					 if (index == 0) direct *= PCFCube(shadowMapPoint[0], | ||||
| 													#ifdef _ShadowMapTransparent | ||||
| 													shadowMapPointTransparent[0], | ||||
| 													#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 | ||||
| 		} | ||||
|  | ||||
		Reference in New Issue
	
	Block a user