-﻿//  Copyright (c) 2015, Ben Hopkins (kode80)
+//  Copyright (c) 2015, Ben Hopkins (kode80)
 //  All rights reserved.
 //  
 //  Redistribution and use in source and binary forms, with or without modification, 

			{
				half4 specularSmoothPixel = tex2D( _CameraGBufferTexture1, i.uv);
			    float3 sourceNormal = tex2D( _CameraGBufferTexture2, i.uv).rgb * 2.0 - 1.0;
			    float sourceDepth = Linear01Depth( tex2D( _CameraDepthTexture, i.uv).r) * _ProjectionParams.z;
			    
			    float2 stepSize = _TexelOffsetScale.xy * (1.0 - specularSmoothPixel.a);
			    half4 accumulator = tex2D( _MainTex, i.uv) * 0.214607;
			    half denominator = 0.214607;
			   
			    processSample( i.uv, sourceNormal, sourceDepth, 1, 3, stepSize, accumulator, denominator);
			    processSample( i.uv, sourceNormal, sourceDepth, 2, 3, stepSize, accumulator, denominator);
			    processSample( i.uv, sourceNormal, sourceDepth, 3, 3, stepSize, accumulator, denominator);
			    
			    processSample( i.uv, sourceNormal, sourceDepth, -1, 3, stepSize, accumulator, denominator);
			    processSample( i.uv, sourceNormal, sourceDepth, -2, 3, stepSize, accumulator, denominator);
			    processSample( i.uv, sourceNormal, sourceDepth, -3, 3, stepSize, accumulator, denominator);
			    
			    return accumulator / denominator;
			}

			sampler2D _CameraDepthTexture;
			sampler2D _CameraGBufferTexture1;	// Specular color (RGB), roughness (A)
			sampler2D _CameraGBufferTexture2;	// World space normal (RGB), unused (A)
			
			float3 _TexelOffsetScale;

			float _DepthBias;
			float _NormalBias;
			float _BlurQuality;
			
			const float weights[8] = { 0.071303, 0.131514, 0.189879, 0.321392, 0.452906,  0.584419, 0.715932, 0.847445 };
	
			inline half compareNormalAndDepth( float3 sourceNormal, float sourceDepth, float2 uv)
			{
