Sunday, July 8, 2018

Non Photorealistic Rendering Software - The Painter

"The Painter" is software to painterly render a photograph. Details of the methodology can be found in Non Photorealistic Rendering - Stroke-Based Rendering (SBR).

When you extract thepainter-x64.rar (windows 64 bit), you will end up with something like this:

The directories "barn1024_brushmarks", "barn1024_digital", and "barn1024_impasto" show how to use the software to get painting effects that kinda simulate oil painting with visible brush marks, digital painting, and impasto oil painting, respectively. The directory "texture" contains the brush textures (opacity and height aka bumpity) for various brush radii.

If you go into "barn1024_impasto", you should see something like this:

The file called "thepainter.bat" is the one you will double-click to run the software. It tells windows where the executable is. You need to edit the file so that the location of the executable is the correct one for your installation. I use notepad++ to edit text files but I am sure you can use notepad or wordpad with equal success.

The file that controls the input to the software is "thepainter_input.txt". It should look like this:

64 1.0 1.0 32 1.0 1.0 16 1.0 1.0 8 1.0 1.0 4 1.0 1.0 2 0.5 1.0

Line 1 contains the name of the input photograph you want to render (here, barn1024.jpg). There should be no spaces in the image name.

Line 2 contains the list of brush radii (here, 64, 32, 16, 8, 4, and 2) you want to use for the painting. Each brush radius is followed by the opacity strength (between 0.0 and 1.0) and the bumpity strength (between 0.0 and 1.0) for that brush radius.

Line 3 contains the Gaussian blur sigma factor (here, 0.1). For the input photo not to be smoothed at all, use a small value like 0.00001.

Line 4 contains the color error threshold (here, 60.0). The larger the color error threshold, the coarser the painting will look.

Line 5 contains the name of the output canvas image (here, canvas_rgb_image.png). There should be no spaces in the image name.

Line 6 contains the name of the output height map aka bumpity map (here, canvas_bumpity_image.png). There should be no spaces in the image name.

For each brush radius XXX, there needs to be a file called textureXXX.txt. Here, because the brush radii are 64, 32, 16, 8, 4, and 2, the files texture064.txt, texture032.txt, texture016.txt, texture008.txt, texture004.txt, texture002.txt must be present. These texture files contain the textures to be used for the brushes. Let's look, for example, at texture064.txt. It should look like this:


Line 1 is the image that describes the opacity of the brush.

Line 2 is the image that describes the height (aka bumpity) of the brush.

You can use as many opacity/bumpity texture combos you want. The software will pick a texture at random among the ones that are present in the texture file. For example, you could have "texture064.txt" looking like this:


The software would then pick at random, for each brush stroke to paint on the canvas, either the combo opacity04.png/bumpity04.png, opacity04_var1.png/bumpity04_var1.png, or opacity04_var2.png/bumpity04_var2.png. Of course, you would have to create those texture variations yourself.

The brush textures are stored in the "texture" directory. What does a typical brush texture look like? Let's have a look at the brush texture images for brush radius = 64.

Brush texture opacity image "opacity04.png".

As you build up layers of paint on the canvas with brush strokes, if the opacity is high (grayscale value is close to white), the paint that's underneath the current brush stroke will not be seen by transparency. If the opacity is low (grayscale value is close to black), the paint that's underneath the current brush stroke will be seen by transparency. The lower the opacity, the more the paint that's underneath will show. If the opacity is pure black, the current brush stroke will not deposit any paint on the canvas.

The opacity value coming from the brush texture opacity image is multiplied by the opacity strength to give the actual opacity value that's gonna be used. So, for example, if the opacity strength is set at 0.5, the opacity that is actually used is half the opacity that's in the brush texture opacity image. This enables to change the opacity quite easily without having to change the brush texture opacity image.

Brush texture bumpity image "bumpity04.png".

I am calling the brush height map the brush bumpity map because it rhymes with brush opacity map. It's really a brush bump map which is applied to the canvas bump map (aka canvas height map or canvas bumpity map). The brush bumpity map describes the height of the paint that's deposited by the brush. If the value is middle gray (grayscale value = 128), there is no bump and the paint is laid flat. The white the value, the more height the paint will have when it is deposited by the brush stroke. Here, we are simulating impasto oil painting which is characterized by thick layers of paint.

Just like with opacity, the actual bumpity used is the bumpity in the brush texture bumpity image times the bumpity strength.

This is the canvas rgb image.

This is the canvas bumpity image.

To apply the canvas bumpity map to the canvas rgb image, I use gimp:

- Open as layers the canvas rgb image and the canvas bumpity image
- Activate the layer containing the canvas rgb image and click on Filters->Map->Bump Map
- For the Bump Map, choose the canvas bumpity image
- You may want to adjust the Depth Parameter to adjust the height
- Click OK and then export the bumpmapped image

This is the bumpmapped canvas rgb image.

Posts about "The Painter":
The Painter - Blade Runner

No comments:

Post a Comment