It’s such a shame that it isn’t more well known…

All you need to do is add a tutorial, maybe a few more features, and it’s practically ready for steam!

For the tutorial, just add another button on the left in the lobby, named “Instructions”.

A few simple pieces of text in there, practically the same as what you have on this page, and it’s a masterpiece.

This is a brilliant concept, so don’t stop working on it. ]]>

2. I can’t remember precisely because I wrote this ages ago, but I think it’s so you have a uniform sampling in each direction. Imagine you’re doing one blur to the right, and then a second to the left. You’d first sample at coords 0.5, 1.5, 2,5…, and then at coords -0.5, -1.5, -2.5… etc. The distance between each sample is 1, even across the boundary. It’s the same principle but in a hexagon.

3. Texture coordinates for sampling are [0, 1] in both directions. Because we want to step one pixel at a time, we convert [0, ScreenHeight] to the correct tex coord range [0, 1] by multiplying by OneOverScreenHeight. Then, we need to correct for the aspect ratio in xStep to keep it stepping whole pixels in x, so scale x by (OneOverScreenWidth/OneOverScreenHeight). Alternatively you could of course scale by ScreenWidth first, then correct the y coord the other way if you wanted.

Hope that helps.

]]>1. Why is the diagonal blur xStep downwards if the xStep value is positive ? A direction vector of(0.866, -0.5) in my mind would point towards the bottom right, not left. It seems like the x-axis is negated. How come ?

2. Maybe a noob question but why do you add the 0.5f to the sampleIndex in “stepDist”

3. Related to question 2: Why are you only multiplying your pixel distances by OneOverScreenHeight ?

For the xStep you use (OneOverScreenWidth/OneOverScreenHeight), why not for the other occasions ?

If you remove the line where you multiply the CoC by the reciprocal of the filmSize then it works quite nicely.

]]>Something like Aperture = (focalLength / fStopNumber) * 0.1 produces a more realistic behavior, however I really dislike using some magic empirical number to change an otherwise physically correct calculation. ]]>

My focal length is e.g. 210mm / 1000.0f (so that it’s measured in meters)

Aperture has to be the diameter not the fstop number which is calculated as (focalLength / fStopNumber).

FocalPlane I just use a linear value from 0 to 1 and multiply that by the farClip

My filmSize is 0.04326 (43.26mm)

Hope that helps anyone who’s also unsure

]]>Focal length is in metres. In my code it’s calculated as:

focalLength = (0.5f * filmSize) / tanf(0.5f * fovY) = 21mm (where film size is 0.024 (24mm film) and field of view is 60 degrees).

Focal plane is in metres. In the final image above it’s probably around 5m.

Aperture I’m just not sure about. The code uses a value of 0.1. Larger values mean a larger CoC, so I assume it’s proportional to the inverse of the camera f-stop. I imagine this can be worked out geometrically, but that’s left as an exercise for the reader ðŸ™‚

Sorry I can’t be more help with this bit!

]]>