I am trying to add a blur effect on 3D objects as a 2D image processing effect after the objects are already rendered to a buffer. Since I want to be able to blur individual objects differently or none at all, I first render a mask of each object to a texture (each object is rendered using a fixed colour based on the blur setting (0-32, which is the size of the kernel), no lighting of course). Then after the ‘normal’ render is finished, blur is added to pixels with non-zero masks using a blur kernel size based on the mask value.
As far as I know, this is similar to how depth of field effects work. However, this is far from ideal, since I need to not only blur the actual pixels of the objects, but their neighbourhoods as well (that is why a blurred object always looks ‘bigger’ then its original). Somehow I have to render the mask of the objects with a bigger outline, at least as big as half the size of the filter kernel.
My question is: how can I do that? I tried to render the masks in a second pass, this time as lines instead of polygons and using the line width setting to make the outline bigger. But the maximum line width is 10, which is not enough for bigger kernels, and my objects do not look very good at the edges, probably because of this.
Is there any other way?