     
     override func encode(commandBuffer:MTLCommandBuffer, sourceTexture:MTLTexture, destinationTexture: MTLTexture)
     {
+        let sourceWidth:Int = sourceTexture.width
+        let sourceHeight:Int = sourceTexture.height
+        
         generateDilate(sourceTexture:sourceTexture)
-        
-        dilate?.encode(commandBuffer:commandBuffer,
-                      sourceTexture:sourceTexture,
-                      destinationTexture:destinationTexture)
+        generateGaussian(sourceTexture:sourceTexture)
+        
+        dilate?.encode(
+            commandBuffer:commandBuffer,
+            sourceTexture:sourceTexture,
+            destinationTexture:destinationTexture)
+        
+        let textureDescriptor:MTLTextureDescriptor = MTLTextureDescriptor.texture2DDescriptor(
+            pixelFormat:sourceTexture.pixelFormat,
+            width:sourceWidth,
+            height:sourceHeight,
+            mipmapped:false)
+        
+        let bokehTexture:MTLTexture = device.makeTexture(descriptor:textureDescriptor)
+        let origin:MTLOrigin = MTLOriginMake(0, 0, 0)
+        let size:MTLSize = MTLSizeMake(sourceWidth, sourceHeight, sourceTexture.depth)
+        let blitEncoder:MTLBlitCommandEncoder = commandBuffer.makeBlitCommandEncoder()
+        
+        blitEncoder.copy(
+            from:destinationTexture,
+            sourceSlice:0,
+            sourceLevel:0,
+            sourceOrigin:origin,
+            sourceSize:size,
+            to:bokehTexture,
+            destinationSlice:0,
+            destinationLevel:0,
+            destinationOrigin:origin)
+        blitEncoder.endEncoding()
+        
+        gaussian?.encode(
+            commandBuffer:commandBuffer,
+            sourceTexture:bokehTexture,
+            destinationTexture:destinationTexture)
         
         super.encode(
             commandBuffer:commandBuffer,

            kernelHeight:bokehSize,
            values:probe)
    }
}

                let faceFeatureY:Int = sourceHeight - (Int(faceFeature.bounds.origin.y) + faceFeatureH)
                let faceFeatureMaxX:Int = faceFeatureX + faceFeatureW
                let faceFeatureMaxY:Int = faceFeatureY + faceFeatureH
                let faceFeatureW_2:Int = Int(round(Float(faceFeatureW) / 2.0))
                let faceFeatureH_2:Int = Int(round(Float(faceFeatureH) / 2.0))
                let faceFeatureCenterX:Int = faceFeatureX + faceFeatureW_2
                let faceFeatureCenterY:Int = faceFeatureY + faceFeatureH_2
                let faceFeatureRadius:Int = min(faceFeatureW_2, faceFeatureH_2)
                
                var minX:Int = faceFeatureX - faceRadius
                var maxX:Int = faceFeatureMaxX + faceRadius
                var minY:Int = faceFeatureY - faceRadius
                var maxY:Int = faceFeatureMaxY + faceRadius
                
                if minX < 0
                {
                    minX = 0
                }
                
                if maxX > maxWidth
                {
                    maxX = maxWidth
                }
                
                if minY < 0
                {
                    minY = 0
                }
                
                if maxY > maxHeight
                {
                    maxY = maxHeight
                }
                
                for indexVr:Int in minY ..< maxY
                {
                    let deltaY:Int = indexVr - faceFeatureCenterY
                    let deltaY2:Int = deltaY * deltaY
                    let currentRow:Int = sourceWidth * indexVr
                    
                    for indexHr:Int in minX ..< maxX
                    {
                        let pixelIndex:Int = currentRow + indexHr
                        let currentWeight:Float = textureArray[pixelIndex]
                        
                        if currentWeight > 0
                        {
                            let deltaX:Int = indexHr - faceFeatureCenterX
                            let deltaX2:Int = deltaX * deltaX
                            let deltaSum:Int = deltaX2 + deltaY2
                            let hyp:Int = Int(sqrt(Float(deltaSum)))
                            let deltaRadius:Int = hyp - faceFeatureRadius
                            let pixelWeight:Float
                            
                            if deltaRadius > 1
                            {
                                fatalError("didn't know this could happen")
                            }
                            else if deltaRadius > 0
                            {
                                let deltaRaiusFloat:Float = Float(deltaRadius)
                                pixelWeight = deltaRaiusFloat / faceRadiusFloat
                            }
                            else
                            {
                                pixelWeight = 0
                            }
                            
                            if pixelWeight < currentWeight
                            {
                                textureArray[pixelIndex] = pixelWeight
                            }
                        }
                    }
                }
