1
$\begingroup$

I have just started learning how to use and create shaders in ThreeJS and, while going through some shaders in the example folder, I have come across a bokeh shader. Inside the shader, blur is computed using a formula, but I dont really understand where does this formula come from and what it really computes. Here is some code:

float f = focalLength; // focal length in mm",
        "       float d = fDepth*1000.0; // focal plane in mm",
        "       float o = depth*1000.0; // depth in mm",

        "       float a = (o*f)/(o-f);",
        "       float b = (d*f)/(d-f);",
        "       float c = (d-f)/(d*fstop*CoC);",

        "       blur = abs(a-b)*c;",

What I don't understand is what c is and how I can then use it to compute the blur. For reference, the shader I am talking about is BokehShader2 by Martins Upitis. Can anyone help me out?

$\endgroup$

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.