Difference between revisions of "Krita - Seamless Texture Creation"

From Wiki.OSArch
Line 4: Line 4:
 
''by João Queiroz e Lima''
 
''by João Queiroz e Lima''
  
=== Introduction ===
+
== Introduction ==
  
 
In this tutorial we are going to turn a '''photo''' that we found online, '''into a seamless texture''' that we can use as '''Base Color''' for a '''PBR material'''.
 
In this tutorial we are going to turn a '''photo''' that we found online, '''into a seamless texture''' that we can use as '''Base Color''' for a '''PBR material'''.
Line 14: Line 14:
 
The photo we will base our material was taken by '''[https://unsplash.com/@peetwillis?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText Pete Willis]''' and is freely available on '''[https://unsplash.com/s/photos/wood?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText Unsplash]'''. You can find a bunch more excellent examples there, either taken by him or by other Unsplash artists/curators.
 
The photo we will base our material was taken by '''[https://unsplash.com/@peetwillis?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText Pete Willis]''' and is freely available on '''[https://unsplash.com/s/photos/wood?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText Unsplash]'''. You can find a bunch more excellent examples there, either taken by him or by other Unsplash artists/curators.
  
https://images.unsplash.com/photo-1587239549476-295aa1dac397?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=2167&q=80
+
'''[https://images.unsplash.com/photo-1587239549476-295aa1dac397?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=2167&q=80 Download it here.]'''
  
 
The tutorial will be based in Krita 4.4.1 for Windows but it should be able to be followed in other platforms as Krita is platform agnostic.
 
The tutorial will be based in Krita 4.4.1 for Windows but it should be able to be followed in other platforms as Krita is platform agnostic.
  
=== Opening File + Activate Wrap Around Mode ===
+
== Opening File + Activate Wrap Around Mode ==
  
 
As you open '''Krita''' a welcome scree will allow you to open or drag and drop a file, as well as giving you access to your recent files.  Alternatively you can close this window and use '''File > Open''' or '''File > New''' and '''Layer > Import'''. You can also setup Krita to automatically open your files.
 
As you open '''Krita''' a welcome scree will allow you to open or drag and drop a file, as well as giving you access to your recent files.  Alternatively you can close this window and use '''File > Open''' or '''File > New''' and '''Layer > Import'''. You can also setup Krita to automatically open your files.
Line 26: Line 26:
 
[IMAGE PLACEHOLDER]
 
[IMAGE PLACEHOLDER]
  
=== Setting Up a Shortcut for Wrap Around Mode ===
+
== Setting Up a Shortcut for Wrap Around Mode ==
  
 
As we are going to use this mode several times in this tutorial it’s convenient to set up a '''shortcut''' for it. I’ll use '''W''':
 
As we are going to use this mode several times in this tutorial it’s convenient to set up a '''shortcut''' for it. I’ll use '''W''':
Line 40: Line 40:
 
[IMAGE PLACEHOLDER]
 
[IMAGE PLACEHOLDER]
  
=== Preparing Image Geometry – Vertical and Horizontal Guides ===
+
== Preparing Image Geometry – Vertical and Horizontal Guides ==
  
 
Most times texture pictures are taken slightly tilted or with a slight perspective. If the materials being pictured are random, or don’t have clear geometry this might be negligible, however, most human made materials seams, joints or other geometric elements that form patterns, will require extra atention.
 
Most times texture pictures are taken slightly tilted or with a slight perspective. If the materials being pictured are random, or don’t have clear geometry this might be negligible, however, most human made materials seams, joints or other geometric elements that form patterns, will require extra atention.
Line 64: Line 64:
 
[IMAGE PLACEHOLDER]
 
[IMAGE PLACEHOLDER]
  
=== Perspective Transformation ===
+
== Perspective Transformation ==
  
 
The transformation we usually need is to correct perspective. Krita features a single tool for transformation actions and this tool has a subset of tools. The default is the scale tool but you should investigate other transformations as they are very powerful and might be helpful in future scenarios.
 
The transformation we usually need is to correct perspective. Krita features a single tool for transformation actions and this tool has a subset of tools. The default is the scale tool but you should investigate other transformations as they are very powerful and might be helpful in future scenarios.
Line 84: Line 84:
 
[IMAGE PLACEHOLDER]
 
[IMAGE PLACEHOLDER]
  
=== Cropping ===
+
== Cropping ==
  
 
You should now crop the image so the point it starts will be matching the point it ends. You can either crop at a joint line, if those lines are matching in appearance or you can crop at the middle of a plank if the joints are very irregular or colored differently.
 
You should now crop the image so the point it starts will be matching the point it ends. You can either crop at a joint line, if those lines are matching in appearance or you can crop at the middle of a plank if the joints are very irregular or colored differently.
Line 99: Line 99:
 
''Note: Sometimes our transformation action leaves some transparent pixels on the margins of the image. Take care with those while cropping.''
 
''Note: Sometimes our transformation action leaves some transparent pixels on the margins of the image. Take care with those while cropping.''
  
==== Cropping 1 ====
+
=== Cropping 1 ===
  
 
[IMAGE PLACEHOLDER]
 
[IMAGE PLACEHOLDER]
  
==== Cropping 2 ====
+
=== Cropping 2 ===
  
 
[IMAGE PLACEHOLDER]
 
[IMAGE PLACEHOLDER]
  
=== Removing Soft Shadow Effects ===  
+
== Removing Soft Shadow Effects ==  
  
 
After cropping we can turn on Wrap Around Mode and also Toggle Guid Visibility off. Hit W and go to View > Guides.
 
After cropping we can turn on Wrap Around Mode and also Toggle Guid Visibility off. Hit W and go to View > Guides.
Line 138: Line 138:
 
[IMAGE PLACEHOLDER]
 
[IMAGE PLACEHOLDER]
  
=== Save a Duplicate of Your File and Merge Layers ===  
+
== Save a Duplicate of Your File and Merge Layers ==  
  
 
When you’re happy with the results you will have to consolidate the final image by merging Layers.
 
When you’re happy with the results you will have to consolidate the final image by merging Layers.
Line 149: Line 149:
 
[IMAGE PLACEHOLDER]
 
[IMAGE PLACEHOLDER]
  
=== Removing Seams and Exceptional Features ===  
+
== Removing Seams and Exceptional Features ==  
  
 
The final step of the process involves removing seams and, if you really want to be precise, removing exceptional features. Seams will be the obvious issue that breaks texture continuity, however, exceptional features on a texture, also contribute to see the pattern repetition and break realism.
 
The final step of the process involves removing seams and, if you really want to be precise, removing exceptional features. Seams will be the obvious issue that breaks texture continuity, however, exceptional features on a texture, also contribute to see the pattern repetition and break realism.
Line 165: Line 165:
 
[IMAGE PLACEHOLDER]
 
[IMAGE PLACEHOLDER]
  
==== Removing Seams ====
+
=== Removing Seams ===
  
 
In this case we’ll have a very difficult task ahead as we will have to break a huge color difference from the bottom to the top. Using the clone tool we have to keep an eye on geometrical features in the image and try following them.  
 
In this case we’ll have a very difficult task ahead as we will have to break a huge color difference from the bottom to the top. Using the clone tool we have to keep an eye on geometrical features in the image and try following them.  
Line 184: Line 184:
 
[IMAGE PLACEHOLDER]
 
[IMAGE PLACEHOLDER]
  
=== Final Output ===  
+
== Final Output ==  
  
 
You have to consider what will be the purpose of the final image. If it will be used in any offline renderer the size of the image is irrelevant as long as you have RAM or VRAM available in your system to hold up all the assets of your render. However, if you’re going to use the image in realtime render engines you should consider that a square image with a power of two pixel size be needed.
 
You have to consider what will be the purpose of the final image. If it will be used in any offline renderer the size of the image is irrelevant as long as you have RAM or VRAM available in your system to hold up all the assets of your render. However, if you’re going to use the image in realtime render engines you should consider that a square image with a power of two pixel size be needed.
Line 190: Line 190:
 
I always export as a power of two version for flexibility. However, with images like this which are very far from square, I first export it at real size and then create a second version as power of two.
 
I always export as a power of two version for flexibility. However, with images like this which are very far from square, I first export it at real size and then create a second version as power of two.
  
==== Export at Real Size ====
+
=== Export at Real Size ===
 
To export the image you go to File > Export and replace the extension from .kra (Krita’s native file format) to the format of your liking. I use PNG as I can later add transparency to it if I like, without having to replace the image reference on my render engine.
 
To export the image you go to File > Export and replace the extension from .kra (Krita’s native file format) to the format of your liking. I use PNG as I can later add transparency to it if I like, without having to replace the image reference on my render engine.
  
Line 197: Line 197:
 
[IMAGE PLACEHOLDER]
 
[IMAGE PLACEHOLDER]
  
==== Export as power of two version ====
+
=== Export as power of two version ===
 
To play it safe I don’t like to scale the .kra working file, I tend to save a lot so I will proably ruin it. So I open the exported version instead, scale it to the power of two and then export it. If I happen to accidently save it, I will only ruin the first export.
 
To play it safe I don’t like to scale the .kra working file, I tend to save a lot so I will proably ruin it. So I open the exported version instead, scale it to the power of two and then export it. If I happen to accidently save it, I will only ruin the first export.
  
Line 211: Line 211:
 
[IMAGE PLACEHOLDER]
 
[IMAGE PLACEHOLDER]
  
=== Final thoughts ===  
+
== Final thoughts ==  
  
 
I’m not a professional renderer, just an architect that considers rendering as a part of the process and the best way to integrate materiality into the conceptual process.
 
I’m not a professional renderer, just an architect that considers rendering as a part of the process and the best way to integrate materiality into the conceptual process.

Revision as of 09:42, 16 December 2020

Krita is a professional free and open source painting program. See the Krita page for general information.

Seamless Texture Creation with Krita

by João Queiroz e Lima

Introduction

In this tutorial we are going to turn a photo that we found online, into a seamless texture that we can use as Base Color for a PBR material.

PBR stands for Photorealistic Based Rendering, it’s been standard for Architecture Visualization for a long time, but it is now being widely adopted by other industries relying in computer graphics. You can read a nicely detailed description about this material creation workflow here:

https://academy.substance3d.com/courses/the-pbr-guide-part-1

The photo we will base our material was taken by Pete Willis and is freely available on Unsplash. You can find a bunch more excellent examples there, either taken by him or by other Unsplash artists/curators.

Download it here.

The tutorial will be based in Krita 4.4.1 for Windows but it should be able to be followed in other platforms as Krita is platform agnostic.

Opening File + Activate Wrap Around Mode

As you open Krita a welcome scree will allow you to open or drag and drop a file, as well as giving you access to your recent files. Alternatively you can close this window and use File > Open or File > New and Layer > Import. You can also setup Krita to automatically open your files.

After opening the file you can see how it works as a seamless material by activating Wrap Around Mode.

[IMAGE PLACEHOLDER]

Setting Up a Shortcut for Wrap Around Mode

As we are going to use this mode several times in this tutorial it’s convenient to set up a shortcut for it. I’ll use W:

  1. Go to Settings > Configure Krita
  2. Find the Shortcuts panel icon on your left
  3. On the top search box start typing Wrap and the search filter should be fast to show the Wrap Around Mode command
  4. Click it and click the box button next to Custom:
  5. Hit W key.
  6. Press the OK button in the bottom of the Settings Panel

Now on Krita you can hit W to toggle Wrap Around Mode.

[IMAGE PLACEHOLDER]

Preparing Image Geometry – Vertical and Horizontal Guides

Most times texture pictures are taken slightly tilted or with a slight perspective. If the materials being pictured are random, or don’t have clear geometry this might be negligible, however, most human made materials seams, joints or other geometric elements that form patterns, will require extra atention.

To create seamless textures from images with geometric patterns the first step is to make the geometry in each edge of the image match the opposite edge. This is what will make it continuous in the two directions Vertical (V) and horizontal (U). This will then allow the geometric pattern to be repeated along the UV mapping of your geometry.

The process will envolve Krita’s transformation tools and cropping the image so it’s basic geometry aligns in horizontal and vertical directions.

Our example picture features vertical lines for wood planks, we just need to be concerned that the geometry matches vertically as we will be able to take care of other minor horizontal features later. For more complex geometrical patterns the tiling might have to be performed both horizontally and vertically but the principles we will use for vertical tiling will be the same for horizontal.

To help us align the images vertically or horizontally Krita allows us to use Guide Lines but for them to be shown, created and edited we have to activate some settings:

  1. Go to View menu and activate View > Show Rulers and View > Show Guides
  2. On Settings menu activate Settings > Dockers > Grid and Guides
  3. A New Docker will appear on your docked panels, even if it’s tabbed in an already existing panel.
  4. In this docker you can configure Krita’s Grid and Guides. You have a tab for each. Click the Guides tab.
  5. On this Guides tab choose a stronger color for your guides, that contrasts with the image you’re working with. Click the button at the right of the Guides: Lines which displays a color that might be dark grey on the first run.
  6. You can also change the Guide’s linetype by hitting the Lines button.
  7. Rulers will now also be visible on top and left of the canvas. If they’re not, you can also make them visible from the Guides Docker.
  8. To Create a Guide you must click and drag your mouse on a ruler and move it to the top of your canvas.
  9. If Wrap Around Mode is active it might be hard to drag your ruler to the right spot. Hit W to deactivate it and drag again.

[IMAGE PLACEHOLDER]

Perspective Transformation

The transformation we usually need is to correct perspective. Krita features a single tool for transformation actions and this tool has a subset of tools. The default is the scale tool but you should investigate other transformations as they are very powerful and might be helpful in future scenarios.

Our objective will be to align wood joints vertically so we should start by creating two guides at the extremes of the image, were deformation is bigger:

Using the guide lines for reference we will now perform the Perspective Transformation:

  1. Click the Transformation tool,
  2. Select Perspective Transformation tool (second icon),
  3. The first thing you’ll notice when trying to transform the Layer is that as soon as you start deforming it, guidelines will be hidden.
  4. Slide down the Background Layer’s opacity slider like in the animation below to around 50%
  5. After that you can keep transforming the layer by using the corner handles on the perspective transformation tool.
  6. Keep zooming in and out and panning around so you have more control and also to avoid any Krita snapping that might be active. You might deactivate snapping on the Grid and Guides Docker.
  7. Shift the image until the joints align with the corresponding guide lines.
  8. Hit Enter/Return key on your keyboard when you’re finished.

Note: On more severe transformations finishing one side after having done the first side will probably deform the first. You should check both sides before hitting ENTER to comit the transformation.

[IMAGE PLACEHOLDER]

Cropping

You should now crop the image so the point it starts will be matching the point it ends. You can either crop at a joint line, if those lines are matching in appearance or you can crop at the middle of a plank if the joints are very irregular or colored differently.

In this example both methods will work so I’ll exemplify both.

The overall process for cropping is to:

  1. Activate the cropping tool.
  2. Click on the first corner of a rectangle that represents the cropping.
  3. Click on the second oposite corner of the rectangle
  4. Fine tune by zooming, panning and dragging the resulting rectangle
  5. Hit enter to commit.

Note: Sometimes our transformation action leaves some transparent pixels on the margins of the image. Take care with those while cropping.

Cropping 1

[IMAGE PLACEHOLDER]

Cropping 2

[IMAGE PLACEHOLDER]

Removing Soft Shadow Effects

After cropping we can turn on Wrap Around Mode and also Toggle Guid Visibility off. Hit W and go to View > Guides. We can see the globally we now have a fairly good geometric match but in terms of colors and texture we still have noticeable seems as well as areas of the image that are much darker than others.

This is usually due to vignetting effect that is either introduced by the camera or post producion effects on the original image. It might also be related to some objects casting shadows on the geometry. If this shadows are soft we can try removing them, if they are hard shadows, removing them will be very difficult.

We will try to get rid of these soft shadows or vignetting in a fast way, using pixel information on the original layer:

  1. Make sure that Wrap Around Mode is Turned On
  2. On the Layers Docker Duplicate the background layer by Right Click on it and choosing Duplicate Layer or Mask
  3. Desaturate the new Layer by clicking on it and going to Filter > Adjust > Desaturate.
  4. You can accept the standard desaturation mode but usually it’s better to use the one that gives you higher contrast.

[IMAGE PLACEHOLDER]

The next step will be used to remove shadow information to the background using this desaturated layer.

  1. Make sure the Desaturated Layer is selected and change it’s blending mode to Grain Extract.
  2. Do this by clicking to the Layer Blend modes dropdown menu on the top of the Layers Panel. It’s a button that reads Normal, above the opacity slider.
  3. You’ll find Grain Extract in the Mix submenu in the bottom of the list.
  4. While you’re at it click the box next to Grain Extract to make it a favorite, and readily accessible at the top of the list.
  5. You’ll notice that the result will be an image with basic colors and the darkest pixels have been reduced to grey.
  6. Now we’ll blur the image by Going to Filter > Blur > Gaussian Blur.
  7. Slide the top slider to something about 100.
  8. You’ll notice texture detail will start to pop up again. The image will increase texture definition while also getting rid of the shadow fills caused by the soft shadows or vignetting.
  9. Fine tune the Opacity slider of this Layer, to have a less intense effect and fine tune it until you feel it’s right. Info.

The idea here is to get rid of darker areas and projected shadow artifacts to get the basic colors with no lighting info. The lighting info will be given by your render engine when it renders. Having shaodow on the texture will create noticeable errors on your final image, as the lighting effects on the texture will conflict with the light being produced by the render engine on the surface.

[IMAGE PLACEHOLDER]

Save a Duplicate of Your File and Merge Layers

When you’re happy with the results you will have to consolidate the final image by merging Layers. If you don’t do this the final step will not work right as it requires a single Layer. In order not to loose the possibility of fine tuning the last step and produce a more expressive image to use for other purposes besides rendering, you should save a duplicate now and then merge layers.

  1. Save your file with a different name;
  2. Save it again with the final name;
  3. Right click on the Desaturated layer and select Merge Layers.
  4. Save the file again.

[IMAGE PLACEHOLDER]

Removing Seams and Exceptional Features

The final step of the process involves removing seams and, if you really want to be precise, removing exceptional features. Seams will be the obvious issue that breaks texture continuity, however, exceptional features on a texture, also contribute to see the pattern repetition and break realism.

Though the concept is very easy to grasp, this is the most demanding part of the process, as it involves using a Clone tool. You’ll notice that Krita’s clone tool isn’t an individual tool as it is in most image editing software as Photoshop, Affinity or Gimp. What happens is that Krita has a very powerful brush system and any of it’s brushes can be converted into a clone tool.

I’m not going to go deep into that regard though, as one of Krita’s brushes is the Clone tool and it works very well. You just have to search for it, among the hundreds of brushes there are available like this:

  1. On the Brush Presets Docker click on the dropdown list and find the Digital Submenu;
  2. You’ll find the Clone Tool in the bottom of that List.
  3. To work with it you can leave default values and just change the size of the Brush in the Top bar or, if you want to be fast, by Holding Down SHIFT+Left Click and Drag the Mouse Left or Right to decrease or increase the Brush’s size.
  4. You’ll also notice that the brush pointer has two circles. One is the actual Brush and the other represents where’s the clone being referenced on the image. To use the brush you must first find which part of the image to reference. To do that, you hold CTRL key and click on your image.

[IMAGE PLACEHOLDER]

Removing Seams

In this case we’ll have a very difficult task ahead as we will have to break a huge color difference from the bottom to the top. Using the clone tool we have to keep an eye on geometrical features in the image and try following them. Being careful where to pick the reference and how big should the Clone brush be, we can try figure out what should match what. This is a trial and error process where the only rule is: If it seems right it’s right.

I’ve managed to remove seams and use one of the existing features to create the transition between colors. Removing Prominent Features and Details However, zooming out, we can clearly see clear repetition arising on the most prominent features:

If we zoom in a bit we can also see even more evident repetition, in this case of some details:

We should consider what to do with these as:

  • Imperfections matter for the quality of some materials. Without them the materials will be less interesting.
  • However, on bigger buildings, those features might cause more harm than richness as the tiling they produce is obvious.

For the sake of this tutorial, using the clone tool again, we will remove them:

[IMAGE PLACEHOLDER]

Final Output

You have to consider what will be the purpose of the final image. If it will be used in any offline renderer the size of the image is irrelevant as long as you have RAM or VRAM available in your system to hold up all the assets of your render. However, if you’re going to use the image in realtime render engines you should consider that a square image with a power of two pixel size be needed.

I always export as a power of two version for flexibility. However, with images like this which are very far from square, I first export it at real size and then create a second version as power of two.

Export at Real Size

To export the image you go to File > Export and replace the extension from .kra (Krita’s native file format) to the format of your liking. I use PNG as I can later add transparency to it if I like, without having to replace the image reference on my render engine.

In the following example I do not use compression for saving the image, but that is usually overkill as the size of the image will be huge. Having no compression will only allow me to further edit it if I like, without loosing quality with each edit.

[IMAGE PLACEHOLDER]

Export as power of two version

To play it safe I don’t like to scale the .kra working file, I tend to save a lot so I will proably ruin it. So I open the exported version instead, scale it to the power of two and then export it. If I happen to accidently save it, I will only ruin the first export.

Most used power of 2 image sizes are the following:

  • 512px*512px
  • 1024px*1024px
  • 2048px*2048px - often called 2k
  • 4096px*4096px - 4k
  • 8192px*8192px - 8k

We can keep going up the scale, but 8k is already a very heavy image that consumes a lot of RAM and, these days, with GPU rendering, a lot of VRAM, which is limited in our Graphics Processing Units. Also consider that each material will use more than one texture so the BaseColor texture can go along very heavy textures like Normal Maps which are also colored.

[IMAGE PLACEHOLDER]

Final thoughts

I’m not a professional renderer, just an architect that considers rendering as a part of the process and the best way to integrate materiality into the conceptual process.

As an architect I don’t really like to waste time with too much work but I do like to have things looking good. In that sense, this is the fastest way to create a good quality seamless texture I know of, and I do use Substance tools, Affinity Photo, Gimp and have tried many others in the past. This is the one that yields the best results, with minimum control too.

Having said that, for I don’t usually deal with very geometric patterns unless I’m creating them from scratch. That might get tricky but it will be tricky with every software.

I hope it’s been useful and I also hope you’ll consider Krita as an extra tool in your arsenal and explore it’s huge creative potential. It won’t let you down.

All the best and see you next time,

João Queiroz e Lima casca.pt