This page has been translated automatically.
Unigine Basics
1. Introduction
2. Managing Virtual Worlds
3. Preparing 3D Models
5. Cameras and Lighting
6. Implementing Application Logic
7. Making Cutscenes and Recording Videos
8. Preparing Your Project for Release
9. Physics
10. Optimization Basics
11. PROJECT2: First-Person Shooter
12. PROJECT3: Third-Person Cross-Country Arcade Racing Game
13. PROJECT4: VR Application With Simple Interaction

Materials Basics

The virtual world, similar to the real world, contains many different objects, and we can see and distinguish them due to the interaction of the their materials with light. It is materials that make objects green, transparent or, for example, mirror-like. PBR (Physically-Based Rendering) system was developed to ensure uniformity of materials and make them look as realistic as possible. This system considers the properties of each material and uses mathematical formulas to accurately simulate how light behaves when it interacts with the object's surface. In other words, it creates a realistic environment where light behaves as it would in the real world. This model is widely used in various engines, including UNIGINE.

In terms of UNIGINE, a material is a rule defining how the surface (or in some cases a volume) will look like: its color, interaction with lights, reflection and refraction parameters, etc. The material can imitate red plastic, yellow sand, transparent glass, shiny metal, muddy water and much more. The set of basic material properties includes:

  • States that specify conditions, based on which the Engine applies corresponding shaders, textures, and parameters. For example, you can set the Water state to enable/disable sea foam. Depending on the selected state (foam / no foam), the engine will choose the required shaders.
  • A set of Textures. As a rule, a base material has several textures. This is caused by the following reasons:

    • Shader may require more than one texture.
    • Different rendering stages user different textures.
    • A state may require a specific texture.
  • Parameters — arguments passed to the shader that define how the shader will be used.
  • Shaders — basis of materials, special programs that actually draw the material, taking into account the defined parameters, modes, textures, and so on. Each material has several shaders, and one of them is used depending on the selected mode and stage of drawing. In addition to the basic shader types — vertex, fragment and geometry shaders, there are other types.

UNIGINE Materials Concept

Materials have limitations in terms of their application to different types of objects: some are used for surfaces of objects that have a defined geometric shape (like a car, a tree or a kitten), some define volumes (clouds), some — volume and surface (water), and some are just projected on any surface, like a spot from a spotlight with a multicolored light filter. Therefore, keep in mind that different types of objects have their own (applicable) materials.

Material Hierarchy
#

UNIGINE has its own hierarchical material system. The hierarchy is formed by inheriting one material from another. All properties are passed from the parent to the child and can be overridden (as in object-oriented programming). If any parameter value changes for the parent, it is automatically changed for all its children, except for those in which it was previously overridden (adjusted) manually.

For example, Material A has two parameters (Color = Blue and Reflection Coefficient = 1.4), and Material B is inherited from Material A, and its color is changed manually (to Red). When you change the reflection coefficient of Material A to 2.0, Material B will have the following parameters: Color = Red (overridden) and Reflection Coefficient = 2.0 (inherited).

This is very convenient, because by changing one parameter, you can customize several materials at once. For example, a whole group of materials imitating car paint and overriding only the parent's base color can be turned into metallic or matte by changing just a couple of parameters in the parent.

Base and User Materials
#

In general, materials can be divided into two categories:

  • Base materials are the basis for all customizable materials in the project. The base material can be implemented by programmers (it can be changed only by editing the text file itself manually, as code), or without code using a special visual editor. The second approach is convenient for 3D artists, because it allows independently implementing almost any functionality. A base material is always at the top of the hierarchy and cannot be inherited from another base material. Base materials have the *.basemat extension.
  • User materials are the materials inherited from base materials. Their parameters can be customized in the editor, changing the appearance of objects that use them. The set of parameters of a user material cannot differ from its parent, only the values (textures, values, etc.) can be changed. User materials have the *.mat extension.

 The hierarchy of materials in the Materials Hierarchy window

The hierarchy of materials in the Materials Hierarchy window

Post Effects
#

In addition to the materials that are assigned to the objects directly, there are materials that can be applied to the whole image in order to modify it, like a colored light filter that is placed on the camera lens. They are called post effects because they are applied (overlaid) after the overall picture is already rendered. Post effects allow implementing such visual effects as thermal imaging or night vision.

Extending the Set of Materials
#

UNIGINE provides a rich set of built-in base materials out of the box. But no matter how rich the library is, you'll always want to add something and UNIGINE allows that, because the principle of extensibility is the basis of the material system. You can create your own materials that implement almost any functionality in either of the following ways:

  • In the visual editor without code, we will talk about this later.
  • Create your own abstract material and inherit the base material from it. Abstract materials allow you to simplify the programming of shaders and hide the complexity of the functionality implementation. Like abstract classes in object-oriented programming, they serve as a template for defining certain parameters and functions that can be extended later. The abstract material itself cannot be assigned to an object.
  • Create a custom shader using UUSL.
Last update: 2024-01-18
Build: ()