This page has been translated automatically.
Video Tutorials
Interface
Essentials
Advanced
How To
Professional (SIM)
UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Lighting
Sandworm
Using Editor Tools for Specific Tasks
Extending Editor Functionality
Built-in Node Types
Nodes
Objects
Effects
Decals
Light Sources
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
Materials and Shaders
Rebuilding the Engine Tools
GUI
Double Precision Coordinates
API
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Content Creation
Content Optimization
Materials
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

Unigine.Materials Class

Interface for managing loaded materials via the code. All materials existing in the project are loaded depending on the current mode and saved on world's saving or on calling the materials_save console command.

See Also#

  • C++ API sample located in the folder <UnigineSDK>/source/samples/Api/Systems/Materials

Materials Class

Enums

LOADING_MODE#

Materials loading mode to be used by the Engine at startup. Enables you to choose between low memory consumption with faster loading time and smooth spikes-free run-time operation.
NameDescription
FAST = 0No caching - minimum memory consumption and maximum Engine loading speed. Сaching for materials and shaders is disabled, so everything is loaded on demand resulting in lots of freezes, spikes, etc. This method can be used when spikes are less important than memory consumption. Recommended for fast iterations during the application development phase as less time is spent on launching your application and loading resources.
FULL_MATERIALS = 1Caching for materials - materials are created at Engine's startup rather than at run time. Engine startup takes more time than for the first mode and more memory is used. There are less spikes in this mode, but they occur sometimes. This mode can be enabled on a constant basis for a small project having a small number of materials (in case of satisfactory performance and sufficient memory amount).
FULL_MATERIALS_SHADERS = 2Caching for materials and shaders - Caching of materials is enabled along with shader cache generation and loading. This mode requires compilation of all shaders resulting in long loading times. Everything is kept in memory with no streaming required. This mode is the best as it ensures stable work and significant reduction of spikes, but takes a lot of memory and increases loading time at startup. Recommended for production phase (when you hand over your application to the end user).This mode is enabled by default, in case of invalid shaders cache in your project both, the Engine and UnigineEditor may take too long to load. Switch mode for faster loading if necessary!

Properties

bool PrecompileAllShaders#

The A value indicating if shader precompilation is enabled.

int NumMaterials#

The number of materials loaded for the current project.

Materials.LOADING_MODE LoadingMode#

The Materials loading mode used by the Engine at startup. Enables you to choose between faster loading time and smooth spikes-free run-time operation.

Members


Material LoadMaterial ( string path ) #

Loads a material stored by the given path. The function can be used to load materials created during application execution or stored outside the data directory.

Arguments

  • string path - A path to the material (including its name).

Return value

A loaded material.

bool IsMaterialGUID ( UGUID guid ) #

Returns a value indicating if a material with the specified GUID exists.

Arguments

Return value

true if the material with the specified GUID exists; otherwise, false.

Material GetMaterial ( int num ) #

Returns the material by its number.

Arguments

  • int num - Material number.

Return value

A material.

Material FindManualMaterial ( string name ) #

Searches for a manual material by the given name.

Arguments

  • string name - A manual material name.

Return value

A manual material instance.

Material FindMaterialByGUID ( UGUID guid ) #

Searches for a material with the given GUID.

Arguments

Return value

A material instance.

Material FindMaterialByFileGUID ( UGUID guid ) #

Searches for a material with the given GUID of a material file.

Arguments

Return value

A material instance.

Material FindMaterialByPath ( string path ) #

Searches for a material stored by the specified path.

Arguments

  • string path - A loading path of the material (including a material's name).

Return value

A material instance.

void SetCachedMaterial ( Material mat ) #

Arguments

Material GetCachedMaterial ( ) #

void SetCachedState ( string name, int value ) #

Arguments

  • string name
  • int value

bool RemoveMaterial ( UGUID guid, bool remove_file = 0, bool remove_children = 1 ) #

Deletes a material. If the remove_file flag is enabled, the material file will be deleted as well. If the flag is disabled, the deleted material will be loaded again on the next application start-up. If the remove_children flag is enabled, all the children of the material will be deleted as well.

Arguments

  • UGUID guid - GUID of the material to be removed.
  • bool remove_file - Flag indicating if the material file will be deleted.
  • bool remove_children - Flag indicating if all the children of the material will be also deleted.

Return value

1 if the material is deleted successfully; otherwise, 0.

bool ReplaceMaterial ( Material material, Material new_material ) #

Replaces the material with the given one.

Arguments

  • Material material - A material to be replaced.
  • Material new_material - A replacing material.

Return value

1 if the material is replaced successfully; otherwise, 0.

bool SaveMaterials ( ) #

Saves changes made for all loaded materials.

Return value

true if materials are saved successfully; otherwise, false.

void CompileShaders ( Material[] materials ) #

Compiles shaders for all specified materials.

Arguments

  • Material[] materials - Vector containing the list of materials for which shaders are to be compiled.

void CompileShaders ( ) #

Compiles shaders for all loaded materials.

void ReloadMaterials ( ) #

Reloads all loaded materials.

void DestroyShaders ( ) #

Deletes all shaders used for the loaded materials.

void DestroyTextures ( ) #

Deletes all textures used by the loaded materials.

void CreateShaders ( ) #

Creates all shaders for all loaded materials.
Last update: 2022-12-14
Build: ()