Now depth
of field can be achieved in two ways one way is the use the distances of the
nearest and the farthest parts of an object and feed them into a fragment
shader and anything within that range of distance stays on focus but anything
outside of it is blurred. The other way is to calculate the blur radius of the
camera with some camera properties such as focal length and focal stop. This is the method I am going to explain.
The first thing we do is calculate the how much
an object is blurred depending on the distance the object is from the camera.
This can be done using the blur disc diameter equation
Focal length(magnification) distance =
blur
Focal stop distance
of object +/- the distance of object from fragment
Now the pixels/millimeter needs to be
calculated. After that we blur, we can do this by separating bur into two
passes one for blurring all the pixels horizontally and the other is for all
the pixels vertically (aka box blur). When done we combine it all together, the blurred scene
we just did and the regularly rendered scene so that the highly blurry parts
blends with the really low resolution parts (as defined by the blur-disc
equation) and the highly defined parts blend with the high resolution parts
(again, as defined by the equation).
No comments:
Post a Comment