Tag: art

  • A Kennel in Blender

    A Kennel in Blender

    About a year ago I have started experimenting with various all kind of graphical stuff. From simply learning how to draw with pencils of varying hardness, to figuring out how to use digital tools like Krita or Inkscape. Recently I decided to give Blender a three dimensional try.

    Project

    I find that the best way to learn a tool is to try a simple project. For me, in honour of my Shetland sheepdog, I choose to create a virtual kennel. In my opinion it the perfect beginner’s task. It is more complex than a cube / cylinder variant but the geometry stays straightforward. Not every face is parallel, there are multiple objects, extruding to be done, …

    Creating the objects

    The first step was to turn the starting cube into a house shaped object using basic editing tools include the loop cut tool.

    So far it is just a big bulky block, the desired kennel needs an opening. To create opening I created additional objects (one cylinder and one elongated cube) which I then used to extrude the original object using a boolean modifier. Basically I cut a hole. Finally I added a second object to be the roof, which I placed on the first object using snapping.

    Adding textures

    The next step is to add textures to the two objects. I choose to make the base wooden, and use red roof tiles for the roof. I downloaded the assets from https://ambientcg.com/.

    Applying textures is quite straightforward. It is mostly drag and dropping texture files into Blender and connecting the different boxes appropriately. It is almost as simple as putting the red wire into the red socket, blue wire into the blue socket once you understand the purpose of various files.

    Applying a texture is not just mapping an image to a 3D structure. There are other files like normal mapping which will fake bumps and dents in the lightning without adding details to the object.

    View of Blender's texture mapping

    Texture mapping doesn’t always work on the first try. The roof for instance was stretched.

    Fixing textures through UV unwrapping

    The roof looks just wrong. That is because when mapping the texture to the roof, the right side has a large chunk of the image but the left gets a small chunk which ends up being stretched.

    The reason for that is how texture is mapped onto the object. This process is called UV unwrapping. To fix the unwrapping I identified the face that was squashed and stretched it out.

    Finally this fixes the unwrapping and how the texture looks

    Publishing to the web

    To export my asset I decided to create a GLB file to then incorporate into a web friendly tool. The challenge here is to avoid huge web unfriendly files. To achieve this I used compression (in my case draco compression) and updated my textures 1K formats instead of 4K. On more complex models there is more to do (see https://docs.blender.org/manual/en/latest/addons/scene_gltf2.html). Here is the result :

  • Pixel Pal (PART 3) : Measuring model quality

    This article is part of a series about upscaling icon themes with AI. While this page is part 3, part 2 is available here and part 4 is available here.

    Pixel Pal is a project I have started whose purpose is to bring new life to old icon themes. Many old icon themes are in raster format and are not available for HiDPI screens. Because the icons are low-resolution. Currently the only way to handle old icon themes is to resample them by the desired factor, but the icons look pixelated. The goal of this project is to upscale icon themes with AI.

    In this part I will cover losses, metrics and targets. Before going on about training deep learning networks to upsample intelligently icon images, we need ways to measure whether our models are doing a good job. In particular, I need to know if a model does better than simply pixel doubling.

    Low resolution 64 pixels by 64 pixels icon of a non empty folder
    Low resolution 32 pixels by 32 pixels icon of a non empty folder

    The images above show side by side the same vector icon but the left icon was rasterised as a 32 by 32 pixel image and the right icon was rasterized as a 64 by 64 pixel image. Furthermore, the former was upsampled using pixel doubling.

    As you can see the two images are similar but not identical. I need some way to measure how similar the two are. Simply counting the number of identical pixels is problematic. Just because two pixels aren’t identical does not mean they are not similar. Counting the number of identical pixels as a metric will probably be too strict. So, for this project, I will rely on two metrics suggested in the following article: An Introduction to Super Resolution using Deep Learning. The metrics in question are the following:

    1. Peak Signal-to-Noise Ratio (PSNR)
    2. Structural Similarity (SSIM)

    For reference the metrics for the pair of images above are :

    1. Peak Signal-to-Noise Ratio: 16.91 dB
    2. Structural Similarity: 0.83

    Measuring how similar two images are is already a good start. It provides us an idea of how well our models are working. However, there are some limits to metrics:

    • Metrics are not always differentiable. However training neural networks requires a way to measure the distance between the desired output and the output the network is producing. This is where losses come into play.
    • You need to have some good baselines. In other words, the metric in itself is not useful; you need to have an objective. Such as doing better than simple pixel doubling or bicubic interpolation.
    • Metrics will be sensitive to the data you use. You may end up with images that are easy to upsample, and the metric may be deceptively good. This is why you should compute the metrics on the entire dataset and do some statistics on it.
    • Metrics are not perfect. In the end we want something to be visually pleasing not something that maximises a mathematical function. This is why you should also visually inspect the output of a neural networks.

    To train the network, I will use a loss function. Loss function are ways to measure the distance between the ideal output and the current output. In our case, I will use mean squared error as it is simple and fits our purpose. Always make sure you are using an appropriate loss function.

    My objective will be to perform better than straight upsampling via nearest-neighbour and bilinear interpolation.