I am currently experimenting and my goal is to create a “Blurriness” pass for Cycles (in Python for now). It is supposed to be like the depth (Z) pass, but each pixel should have a number which indicates how blurry it is. A pixel with the value 0 would be sharp and the higher the number, the blurrier the pixel. So far, for each pixel, the distance to the focal distance is calculated. It is a useful starting point. But this is not enough, because the blurriness of a pixel that is e.g. 1 unit away from the focal distance is not always the same. It depends on the camera settings like F/stop, radius, … . And this is where I am struggling. Is there a way to calculate how much a pixel is “influenced” by the nearby pixels based on the camera settings? Or is there a way to compute the range of the possible angles in which the rays are “fired” from the camera? Any hint would be welcome!
I am trying to understand how Cycles calculates the rays for individual pixels when depth of field is used. Where is the origin of the ray shifted and what defines how strong? And are the rays always intersecting at the depth of field’s distance?