<commit_before>#ifdef USE_SHADOWMAP

	#if NUM_DIR_LIGHTS > 0

		uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHTS ];
		varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];

	#endif

	#if NUM_SPOT_LIGHTS > 0

		uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHTS ];
		varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];

	#endif

	#if NUM_POINT_LIGHTS > 0

		uniform sampler2D pointShadowMap[ NUM_POINT_LIGHTS ];
		varying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];

	#endif

	#if defined( SHADOWMAP_TYPE_PCSS )
		#define LIGHT_WORLD_SIZE 0.005
		#define LIGHT_FRUSTUM_WIDTH 3.75
		#define LIGHT_SIZE_UV (LIGHT_WORLD_SIZE / LIGHT_FRUSTUM_WIDTH) 
		#define NEAR_PLANE 9.5
		#define BLOCKER_SEARCH_NUM_SAMPLES 16
		#define PCF_NUM_SAMPLES 16
		vec2 poissonDisk[BLOCKER_SEARCH_NUM_SAMPLES];
		
		void initPoissonSamples()
		{
			poissonDisk[0] = vec2(-0.94201624, -0.39906216 );
			poissonDisk[1] = vec2( 0.94558609, -0.76890725 );
			poissonDisk[2] =  vec2( -0.094184101, -0.92938870 );
			poissonDisk[3] =  vec2( 0.34495938, 0.29387760 );
	        poissonDisk[4] = vec2( -0.91588581, 0.45771432 );
			poissonDisk[5] = vec2( -0.81544232, -0.87912464 );
			poissonDisk[6] =  vec2( -0.38277543, 0.27676845 );
			poissonDisk[7] =  vec2( 0.97484398, 0.75648379 );
			poissonDisk[8] =  vec2( 0.44323325, -0.97511554 );
			poissonDisk[9] =  vec2( 0.53742981, -0.47373420 );
			poissonDisk[10] =  vec2( -0.26496911, -0.41893023 );
			poissonDisk[11] =  vec2( 0.79197514, 0.19090188 );
			poissonDisk[12] =  vec2( -0.24188840, 0.99706507 );
			poissonDisk[13] =  vec2( -0.81409955, 0.91437590 );
			poissonDisk[14] =  vec2( 0.19984126, 0.78641367 );
			poissonDisk[15] =  vec2( 0.14383161, -0.14100790 ); 
		}
		
		float PenumbraSize(float zReceiver, float zBlocker) //Parallel plane estimation
		{
			return (zReceiver - zBlocker) / zBlocker;
		}

		void FindBlocker(sampler2D shadowMap, out float avgBlockerDepth, out float numBlockers, vec2 uv, float zReceiver )
		{
			//This uses similar triangles to compute what
			//area of the shadow map we should search
			float searchWidth = LIGHT_SIZE_UV * (zReceiver - NEAR_PLANE) / zReceiver;
			float blockerSum = 0.0;
			numBlockers = 0.0;
			for( int i = 0; i < BLOCKER_SEARCH_NUM_SAMPLES; ++i )
			{
				float shadowMapDepth = unpackRGBAToDepth(texture2D(shadowMap, uv + poissonDisk[i] * searchWidth));
				if ( shadowMapDepth < zReceiver ) {
					blockerSum += shadowMapDepth;
					numBlockers = numBlockers + 1.0;
				}
			}
			avgBlockerDepth = blockerSum / numBlockers;
		}

		float PCF_Filter(sampler2D shadowMap, vec2 uv, float zReceiver, float filterRadiusUV )
		{
			float sum = 0.0;
			for ( int i = 0; i < PCF_NUM_SAMPLES; ++i )
			{
				vec2 offset = poissonDisk[i] * filterRadiusUV;
				float depth = unpackRGBAToDepth(texture2D(shadowMap, uv + offset));
				sum += (zReceiver <= depth) ? 1.0 : 0.0;
			}
			return sum / float(PCF_NUM_SAMPLES);
		}

		float PCSS ( sampler2D shadowMap, vec4 coords )
		{
			vec2 uv = coords.xy;
			float zReceiver = coords.z; // Assumed to be eye-space z in this code
			
			initPoissonSamples();
			// STEP 1: blocker search
			float avgBlockerDepth = 0.0;
			float numBlockers = 0.0;
			FindBlocker( shadowMap, avgBlockerDepth, numBlockers, uv, zReceiver );
			if( numBlockers < 1.0 )
			//There are no occluders so early out (this saves filtering)
				return 1.0;
			// STEP 2: penumbra size
			float penumbraRatio = PenumbraSize(zReceiver, avgBlockerDepth);
			float filterRadiusUV = penumbraRatio * LIGHT_SIZE_UV * NEAR_PLANE / coords.z;

			// STEP 3: filtering
			//return avgBlockerDepth;
			return PCF_Filter( shadowMap, uv, zReceiver, filterRadiusUV );
		}

	#endif

	float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {

		return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );

	}

	float texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {

		const vec2 offset = vec2( 0.0, 1.0 );

		vec2 texelSize = vec2( 1.0 ) / size;
		vec2 centroidUV = floor( uv * size + 0.5 ) / size;

		float lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );
		float lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );
		float rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );
		float rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );

		vec2 f = fract( uv * size + 0.5 );

		float a = mix( lb, lt, f.y );
		float b = mix( rb, rt, f.y );
		float c = mix( a, b, f.x );

		return c;

	}<commit_msg>clean up the code.<commit_after>#ifdef USE_SHADOWMAP

	#if NUM_DIR_LIGHTS > 0

		uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHTS ];
		varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];

	#endif

	#if NUM_SPOT_LIGHTS > 0

		uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHTS ];
		varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];

	#endif

	#if NUM_POINT_LIGHTS > 0

		uniform sampler2D pointShadowMap[ NUM_POINT_LIGHTS ];
		varying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];

	#endif

	#if defined( SHADOWMAP_TYPE_PCSS )
		#define LIGHT_WORLD_SIZE 0.005
		#define LIGHT_FRUSTUM_WIDTH 3.75
		#define LIGHT_SIZE_UV (LIGHT_WORLD_SIZE / LIGHT_FRUSTUM_WIDTH)
		#define NEAR_PLANE 9.5
		#define BLOCKER_SEARCH_NUM_SAMPLES 16
		#define PCF_NUM_SAMPLES 16
		vec2 poissonDisk[BLOCKER_SEARCH_NUM_SAMPLES];

		void initPoissonSamples() {
			poissonDisk[0] = vec2(-0.94201624, -0.39906216 );
			poissonDisk[1] = vec2( 0.94558609, -0.76890725 );
			poissonDisk[2] =  vec2( -0.094184101, -0.92938870 );
			poissonDisk[3] =  vec2( 0.34495938, 0.29387760 );
	    poissonDisk[4] = vec2( -0.91588581, 0.45771432 );
			poissonDisk[5] = vec2( -0.81544232, -0.87912464 );
			poissonDisk[6] =  vec2( -0.38277543, 0.27676845 );
			poissonDisk[7] =  vec2( 0.97484398, 0.75648379 );
			poissonDisk[8] =  vec2( 0.44323325, -0.97511554 );
			poissonDisk[9] =  vec2( 0.53742981, -0.47373420 );
			poissonDisk[10] =  vec2( -0.26496911, -0.41893023 );
			poissonDisk[11] =  vec2( 0.79197514, 0.19090188 );
			poissonDisk[12] =  vec2( -0.24188840, 0.99706507 );
			poissonDisk[13] =  vec2( -0.81409955, 0.91437590 );
			poissonDisk[14] =  vec2( 0.19984126, 0.78641367 );
			poissonDisk[15] =  vec2( 0.14383161, -0.14100790 );
		}

		float penumbraSize( const in float zReceiver, const in float zBlocker ) { // Parallel plane estimation
			return (zReceiver - zBlocker) / zBlocker;
		}

		float findBlocker( sampler2D shadowMap, const in vec2 uv, const in float zReceiver ) {
			// This uses similar triangles to compute what
			// area of the shadow map we should search
			float searchRadius = LIGHT_SIZE_UV * ( zReceiver - NEAR_PLANE ) / zReceiver;
			float blockerDepthSum = 0.0;
			int numBlockers = 0;

			for( int i = 0; i < BLOCKER_SEARCH_NUM_SAMPLES; i++ ) {
				float shadowMapDepth = unpackRGBAToDepth(texture2D(shadowMap, uv + poissonDisk[i] * searchRadius));
				if ( shadowMapDepth < zReceiver ) {
					blockerDepthSum += shadowMapDepth;
					numBlockers ++;
				}
			}

			if( numBlockers == 0 ) return -1.0;

			return blockerDepthSum / float( numBlockers );
		}

		float PCF_Filter(sampler2D shadowMap, vec2 uv, float zReceiver, float filterRadius ) {
			float sum = 0.0;
			for( int i = 0; i < PCF_NUM_SAMPLES; i ++ ) {
				float depth =  unpackRGBAToDepth( texture2D( shadowMap, uv + poissonDisk[ i ] * filterRadius ) );
				if( zReceiver <= depth ) sum += 1.0;
			}
			return sum / float( PCF_NUM_SAMPLES );
		}

		float PCSS ( sampler2D shadowMap, vec4 coords ) {
			vec2 uv = coords.xy;
			float zReceiver = coords.z; // Assumed to be eye-space z in this code

			initPoissonSamples();
			// STEP 1: blocker search
			float avgBlockerDepth = findBlocker( shadowMap, uv, zReceiver );

			//There are no occluders so early out (this saves filtering)
			if( avgBlockerDepth == -1.0 ) return 1.0;

			// STEP 2: penumbra size
			float penumbraRatio = penumbraSize( zReceiver, avgBlockerDepth );
			float filterRadius = penumbraRatio * LIGHT_SIZE_UV * NEAR_PLANE / zReceiver;

			// STEP 3: filtering
			//return avgBlockerDepth;
			return PCF_Filter( shadowMap, uv, zReceiver, filterRadius );
		}

	#endif

	float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {

		return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );

	}

	float texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {

		const vec2 offset = vec2( 0.0, 1.0 );

		vec2 texelSize = vec2( 1.0 ) / size;
		vec2 centroidUV = floor( uv * size + 0.5 ) / size;

		float lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );
		float lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );
		float rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );
		float rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );

		vec2 f = fract( uv * size + 0.5 );

		float a = mix( lb, lt, f.y );
		float b = mix( rb, rt, f.y );
		float c = mix( a, b, f.x );

		return c;

	}
{'fraction_non_alphanumeric': 0.11307341997112073, 'fraction_numerical': 0.09096967677440854, 'mean_word_length': 3.5065065065065064, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7248750', 'n_tokens_mistral': 4319, 'n_tokens_neox': 3447, 'n_words': 842}