Jump to content

Applied Distance Blur (using Alpha Masking)

Recommended Posts

Season's greetings to all!

I'm relatively new to Paint.NET. I discovered this forum when searching for an alpha mask add-on for PdN. In turn, I decided to contribute a tutorial of my own, in tribute to Illnab's amazing alpha-masking tool.

This tutorial explains how to apply distance blur to an entirely in-focus image

To follow this tutorial, we will need Illnab's alpha-masking add-on. Here is a good tutorial, with a link to the tool itself.

Also, you will need to be comfortable with layering, using the magic wand, multiple selections (hold ctrl when 'wanding'), inverting the selection (ctrl-I), using the gradient tool, and adjusting colour brightness values (Colors window, More>>, V).

In case you are wondering, I borrowed the image from this page of google image search.

This is the original image:


I selected this image for two reasons.

Firstly, although Wolfenstein 3D was the granddaddy of all first-person shooters, DooM was the BIG daddy! My choice was obviously an emotional one.

Secondly, this image is entirely in-focus. The walls in the background are as sharp as the shutgunner standing in front of our space marine.

The ".pdn" files for this tutorial are here.

Step 1: Separating the objects

The objects I selected in our image are the status bar, our marine's shotgun and glove, the zombie shotgunner, and the various other surfaces in the background. In this step we separate each object to it's own layer.

This first step is the most difficult, the most boring, and the most work. Patience is demanded!

- Open up our image and save it as a ".pdn".

- Duplicate the layer containing the original image. For convenience, let's call this the original image layer (OIL). Uncheck the OIL visiblity to avoid any confusion later on.

- Using whatever tools you are comfortable with, cut around the object so that only the object exists in that layer, surrounded by transparency. For convenience, let's call this layer 'object 1 layer' (OB1L). Take this for example:


This handsome fellow is probably surrounded by a white background due to technical limitations. Please just use your imagination; He's surrounded by transparency.

- Duplicate the OIL again so we can start working on OB2L.

- Go to OB1L. magic wand the transparent area (preferably at 0% tolerance). Invert selection. Now we should only have the object itself selected on the OB1L.

- Switch to OB2L and press delete. Now we should have a transparent gap in OB2L the exact same size and shape as the object in OB1L.

- Once again, cut around the OB2L object so that only it is the only thing in the layer, surrounded by transparency.

- Duplicate the OIL again so we can start working on OB3L.

- Take the shape of the object in OB1L and create a transparency gap in OB3L, just as we did for OB2L.

- Now do the same again, but using the object shape from OB2L to create the gap in OB3L.

- I'm guessing you've noticed the pattern developing here. Use the previous objects to create the transparency gaps in all additional object layers. This way, we prevent any objects from overlapping. Do this until our jigsaw pieces altogether make the complete image. Remember that it does not have to be pixel perfect - avoid little 'islands' of pixels.

Step 2: Colouring the objects


Switching from layer to layer, we will now colour the objects in a solid colour. This is not absolutely necessary, but makes things a lot easier in the long run. An expert pdn-ner could probably skip this step.

- Using the 'inverted magic wand trick' we used in step 1, select only the object on OB1L. Get your paintbrush out, whack the size up to 400, and monochromize the object! It is absolutely crucial that we do not use a greyscale colour at this point. Pick something you'd see in a circus, like purple, yellow, pink, blue, orange, and any of your other favourite colours.

- Repeat this for each layer, making sure each layer's object has a unique non-greyscale colour.

Step 3: Setting the 'distance-flats'


In this step, we will begin to set the distances for each object. In basic terms, white objects are very close and black objects are the furthest objects in the image. Go to colours, select white or black, click on More>>, and adjust the 'V' slider. You will see that sliding between black and white gives a numerical value. We can set the distance of our objects by choosing a value for them on the 0-to-100 scale, 0 being the furthest (black).

'Distance-flat' objects are entirely the same distance from the viewer, so each one can be kept in a single grey-scale colour. We will colour those irst, as they provide a good starting point for our gradients later.

- Go to a layer containing a distance flat object. Recolour the object with a shade of grey between 0 and 100 (between white and black, of course!)

- Repeat this for all 'distance-flat' objects.

Step 4: Setting the distance gradients


In this step, we will colour the remaining objects using grey gradients to give a feel of objects that are both near but long enough to sweep away into the distance. The obvious example of this is floor or ground, and perhaps long walls.

- Go to a layer containing a non-distance-flat object (IE any of the remaining objects).

- Using the 'inverted magic wand trick', select only the object in the layer.

- Go to colours, make sure both the primary and secondary colours are black or white, and click 'More>>'. Now, using your judgement, choose a value for the nearest point of the object and put it into the 'V' slider. Switch the colours around and select a value for the furthest point of the object, again, in the 'V' slider. In my example, the wall to our left of the shotgunner had a 'near value' of about 65 and a 'far value' of a about 25.

- Now use the gradient tool to make a gradient from one end of the object to the other. Common sense is key here; Remember that brighter areas are closer and darker areas are further away. It is very important that the gradient only applies inside the shape, not over the whole layer!

- Repeat this step for all the remaining layers, so that the entire image is greyscale as in the above image.

Step 5: Creating the Alpha Mask

In this step, we are going to create the alpha mask. The alpha mask the the greyscale image that decides how blurry parts of our final image will be. Users familiar with Illnab's alpha masking add-on can most likely skip this step.

- Go to the uppermost layer, and merge it down to the layer below.

- Repeat this until all the layers are flattened.

- At this point, in the tutorial example I chose to apply the Gaussian Blur effect (in the Effects menu!) with a value of 1. However, whatever effects you apply to the alpha mask is a matter of personal taste. Remember that this is not the final image blur! My gaussian alpha mask was 'a blur of a blur'.

- Save the file as a ".png". Be careful not to overwrite your ".pdn" image. When saving as a ".png", make sure you select 32-bit to avoid any quality loss, just in case.

Step 6: Setting the image maximum blur


In this step, we are going to set the maximum (and minimum) blur levels of our final image.

- Open up the ".pdn" file that contains our OIL. Hide any layers that are above the OIL, we need them out of the way for the rest of the tutorial!

- Duplicate the OIL. Now we should have two layers containing the original image. For convenience, let's call these OIL1 and OIL2, OIL2 being underneath OIL1.

- Go to OIL2. Now we will set the blur (or whatever effect you like) for the distant areas. Go to Effects, Blur, Gaussian Blur, and select the blur level that looks correct for the most distant part of the image. In the tutorial example, the mountains in the window are furthest away.

- If you want the nearest parts of the image to have an effect, then repeat the last step on OIL1. I did not apply any effects on OIL1 in the tutorial example.

Step 7: Applying the Alpha Mask


- Uncheck all layer visibilities, so that no layers are visible at all.

- Go to OIL1, and check its visibilty so that we can only 'see' OIL1.

- Go to Effects, Alpha Mask, then select the ".png" alpha mask we saved earlier.

- Now you should see that OIL1 is clear where the alpha mask was brighter, and more transparent where the alpha mask was darker.

- Check OIL2 visibilty so that we can see OIL2 behind the transparent parts of OIL1.

There you go, a quasi-expertly distance-blurred image.


Here's the original again, for comparison:


I hope you have fun with this tutorial and with these skills. Enjoy!

Link to comment
Share on other sites

:shock: We haven't had a great tutorial in so long. And, I think this may be the best written! Two thumbs up big time, and I definettly recommend stickying this tutorial.

Thanks! That made my day! :mrgreen:

welcome to the forums ;)


I look forward to taking part in this mature, friendly, and talented community. 8)

Link to comment
Share on other sites

That, Is, Awesomeness.

A quality tutorial, from a first time poster. Who'd a thunk it? (Not that there's anything wrong with that.)

Very well written, very informative. My hat off to you, my friend.

Hope to see more great tutorials from you in the future!

Call me expired. Please.


Don't go counting your chickens before the pack of rabid ravaging foxes attacks. -Sozo
Link to comment
Share on other sites

Wrong. This is a more exact way to set the focal point. The plugin you mentioned just allows you to set a point that is left unblurred, while blurring everything else.


This tutorial:


Focal Point plugin:



Take responsibility for your own intelligence. 😉 -Rick Brewster

Link to comment
Share on other sites

  • 5 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...