How materials and texture work in Unity

Applying a material inside of the Unity is one of the first things many tutorials from unity explain how to do. After creating a shape such as a sphere or cube, you right click, scroll to the top where it says create, and select material.

The defaults properties inside of the new material you make are small things such as:

  • Albedo (the RGB components along with how transparent you make that colour)
  • Metallic & Smoothness (how much the colour will reflect and absorb light)
  • Mapping details

This is an easy and simple way of being able to quickly implement something and see how you can apply a material to an object. However, during the rendering stage of an object, you take all the surface properties into account when calculating the pixel colours. The most common way is by using a texture buffer.

Enter the fragment shader within texturing. The fragment shader is used to sample texture buffers in which the buffer is an image of data that gets bound to the GPU. Called a texel (a texture element), it uses the power of two rule, that is, 128×128, 256×256, etc. As the texture is applied to a geometry, the term is called texture mapping. This allows the map to know which parts need to be mapped by to the correct part of the geometry.

So how does this apply to Unity? Within unity, textures get seen as a series of images of movie files that wrap around the objects you apply on the object. As the textures are passed into unity, all compression is done internally, allowing you to get to the properties of the textures. These include the type of texture shape, the transparency, how the mode and filters apply, and what size you would like to apply to the texture for the device you are going to apply to the unit.

During investigation of the texture settings for platform specific overrides, I discovered you can use a format called crunch compression. How this format works is it scales the size of the compression can be almost compressed to 2% of its maximum size. However, the draw back to compression of this scale is the time it takes to compress. It takes a long time to compress but is decompressed onto the GPU at runtime (Unity Technologies 2020).

References: Unity Technologies 2020, Unity Manual Version: 2018.3, viewed 22 April 2020 https://docs.unity3d.com/2018.3/Documentation/Manual/class-TextureImporter.html

Leave a comment