This page has been translated automatically.
Видеоуроки
Интерфейс
Основы
Продвинутый уровень
Подсказки и советы
Основы
Программирование на C#
Рендеринг
Профессиональный уровень (SIM)
Принципы работы
Свойства (properties)
Компонентная Система
Рендер
Физика
Редактор UnigineEditor
Обзор интерфейса
Работа с ассетами
Контроль версий
Настройки и предпочтения
Работа с проектами
Настройка параметров ноды
Setting Up Materials
Настройка свойств
Освещение
Sandworm
Использование инструментов редактора для конкретных задач
Расширение функционала редактора
Встроенные объекты
Ноды (Nodes)
Объекты (Objects)
Эффекты
Декали
Источники света
Geodetics
World-ноды
Звуковые объекты
Объекты поиска пути
Player-ноды
Программирование
Основы
Настройка среды разработки
Примеры использования
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Плагины
Форматы файлов
Материалы и шейдеры
Rebuilding the Engine Tools
Интерфейс пользователя (GUI)
Двойная точность координат
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
Работа с контентом
Оптимизация контента
Материалы
Визуальный редактор материалов
Сэмплы материалов
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Учебные материалы
Внимание! Эта версия документация УСТАРЕЛА, поскольку относится к более ранней версии SDK! Пожалуйста, переключитесь на самую актуальную документацию для последней версии SDK.
Внимание! Эта версия документации описывает устаревшую версию SDK, которая больше не поддерживается! Пожалуйста, обновитесь до последней версии SDK.

Unigine::Materials Class

Header: #include <UnigineMaterials.h>

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.
ИмяОписание
LOADING_MODE_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.
LOADING_MODE_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).
LOADING_MODE_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!

Members


void setLoadingMode ( Materials::LOADING_MODE mode ) #

Sets loading mode for materials to be used by the Engine at startup. By default materials loading in UNIGINE is optimized to reduce spikes during run time as much as possible, as they are totally unacceptable for simulators, as well as for a lot of other applications. However, this approach may significantly increase memory consumption and loading time at Engine’s and Editor startup. This may be a problem in case of insufficient memory capacity or when it is necessary to perform a lot of iterations quickly (e.g. development stage). This option enables you to choose between low memory consumption with faster loading time and smooth spikes-free run-time operation.

Arguments

Materials::LOADING_MODE getLoadingMode ( ) const#

Returns the current loading mode for materials used by the Engine at startup. By default materials loading in UNIGINE is optimized to reduce spikes during run time as much as possible, as they are totally unacceptable for simulators, as well as for a lot of other applications. However, this approach may significantly increase memory consumption and loading time at Engine’s and Editor startup. This may be a problem in case of insufficient memory capacity or when it is necessary to perform a lot of iterations quickly (e.g. development stage). This option enables you to choose between low memory consumption with faster loading time and smooth spikes-free run-time operation.

Return value

Materials loading mode currently used by the Engine. One of the LOADING_MODE_* values.

Ptr<Material> loadMaterial ( const char * 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

  • const char * path - A path to the material (including its name).

Return value

A loaded material.

bool isMaterialGUID ( const UGUID& guid ) const#

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

Arguments

  • const UGUID& guid - A material GUID.

Return value

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

int getNumMaterials ( ) const#

Returns the number of materials loaded for the current project.

Return value

The number of materials.

Ptr<Material> getMaterial ( int num ) const#

Returns the material by its number.

Arguments

  • int num - Material number.

Return value

A material.

Ptr<Material> findManualMaterial ( const char * name ) const#

Searches for a manual material by the given name.

Arguments

  • const char * name - A manual material name.

Return value

A manual material smart pointer.

Ptr<Material> findMaterialByGUID ( const UGUID & guid ) const#

Searches for a material with the given GUID.

Arguments

Return value

A material smart pointer.

Ptr<Material> findMaterialByFileGUID ( const UGUID & guid ) const#

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

Arguments

  • const UGUID & guid - A GUID of a material file.

Return value

A material smart pointer.

Ptr<Material> findMaterialByPath ( const char * path ) const#

Searches for a material stored by the specified path.

Arguments

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

Return value

A material smart pointer.

void setCachedMaterial ( const Ptr<Material> & mat ) #

Arguments

Ptr<Material> getCachedMaterial ( ) #

void setCachedState ( const char * name, int value ) #

Arguments

  • const char * name
  • int value

bool removeMaterial ( const 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

  • const 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 ( const Ptr<Material> & material, const Ptr<Material> & new_material ) #

Replaces the material with the given one.

Arguments

  • const Ptr<Material> & material - A material to be replaced.
  • const Ptr<Material> & new_material - A replacing material.

Return value

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

bool saveMaterials ( ) const#

Saves changes made for all loaded materials.

Return value

true if materials are saved successfully; otherwise, false.

void compileShaders ( const Vector< Ptr<Material> > & materials ) #

Compiles shaders for all specified materials.

Arguments

  • const Vector< Ptr<Material> > & materials - Vector containing the list of materials for which shaders are to be compiled.

void compileShaders ( ) #

Compiles shaders for all loaded materials.

void setPrecompileAllShaders ( bool shaders ) #

Enables or disables shader precompilation.

Arguments

  • bool shaders - 1 to enable shader precompilation, 0 - to disable it.

bool isPrecompileAllShaders ( ) const#

Returns a value indicating if shader precompilation is enabled.

Return value

1 if shader precompilation is enabled; otherwise, 0.

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: 23.06.2023
Build: ()