This page has been translated automatically.
Programming
Fundamentials
Setting Up Development Environment
UnigineScript
High-Level Systems
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
API
Core Library
Containers
Engine Classes
Node-Related Classes
Physics-Related Classes
Bounds-Related Classes
GUI-Related Classes
Controls-Related Classes
Pathfinding-Related Classes
Utility Classes
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.

Material Class

Interface for material manipulation.

To use this class, include the UnigineMaterial.h file.

Material Class

Members


int findState (const char * name, int fast_id)

Searches for a state by its name among all states of the current material.

Arguments

  • const char * name - State name.
  • int fast_id - State's fast identifier (hash of a name).

Return value

State number.

void setImageTextureProcedural (int num, const Ptr<Material> & procedural, int procedural_num)

Assigns the procedural texture to the specified image texture.

Arguments

  • int num - Number of the texture, to which the procedural texture will be assigned.
  • const Ptr<Material> & procedural - Procedural material.
  • int procedural_num - Procedural texture number.

int isHidden ()

Returns a value indicating if the material is hidden.

Return value

1 if the material is hidden; otherwise, 0.

int getNumParameters ()

Returns the number of material's parameters.

Return value

The number of parameters.

void setParameterArray (int num, const Vector< Math::vec4 > & values)

Sets values for the given array parameter.

Arguments

  • int num - Parameter number.
  • const Vector< Math::vec4 > & values - Array of parameter values.

int findParameter (const char * name)

Searches for a parameter by its name among all parameters of the current material.

Arguments

  • const char * name - Parameter name.

Return value

Parameter number.

void setTransparent (int transparent)

Sets the transparent option: a value indicating if an object with the material applied should be transparent. If the transparent option is set to TRANSPARENT_NONE or TRANSPARENT_DEFERRED, the blending function won't be used.

Arguments

  • int transparent - The transparent option (one of the TRANSPARENT_* variables).

int getLightMask ()

Gets the light mask of the material. The material is illuminated by a light source, if they both have corresponding masks.

Return value

An integer value, each bit of which is used to set a bit mask.

int getDepthMask ()

Returns a value indicating if the material uses a depth mask.

Return value

Positive number if the depth mask is used; otherwise, 0.

float getParameterSliderMaxValue (int id)

Returns the maximum allowed value of a slider parameter.

Arguments

  • int id - ID number of the target parameter.

Return value

Maximum value.

int getTextureType (int num)

Returns the texture type.

Arguments

  • int num - The texture number.

Return value

Texture type, if the texture with the given number exists; otherwise, -1.

int isStateHidden (int id)

Returns a value indicating if the state is hidden.

Arguments

  • int id - The state number.

Return value

1 is the state is hidden; otherwise, 0.

int loadWorld (const Ptr<Xml> & xml)

Loads material settings from the Xml.

Arguments

  • const Ptr<Xml> & xml - Xml smart pointer.

Return value

1 if the material settings are loaded successfully; otherwise, 0.

void setDepthMask (int mask)

Updates a value indicating if the material uses a depth mask.

Arguments

  • int mask - Positive number to use the depth mask, 0 not to use.

void setImageTextureFlags (int id, int flags)

Sets the flags on the image texture.

Arguments

  • int id - ID number of the target texture.
  • int flags - A flags mask.

int getImageTextureImage (int id, const Ptr<Image> & image)

Reads the given image texture into an Image smart pointer.

Arguments

  • int id - Texture number.
  • const Ptr<Image> & image - Image smart pointer into which the texture is read.

Return value

1 if the texture is read successfully; otherwise, 0.

const char * getTextureName (int num)

Returns the texture name.

Arguments

  • int num - The texture number.

Return value

Texture name.

void setImageTexture (int num, const Ptr<Texture> & texture)

Sets the given texture smart pointer to the specified image texture.

Arguments

  • int num - Texture number.
  • const Ptr<Texture> & texture - Texture smart pointer.

int restoreState (const Ptr<Stream> & stream, int forced = 0)

Restores material settings from the stream.

Arguments

  • const Ptr<Stream> & stream - Stream smart pointer.
  • int forced - Forced restoring of material settings.

Return value

1 if the material settings are restored successfully; otherwise, 0.

int setImageTextureImage (int id, const Ptr<Image> & image, int dynamic = 0)

Replaces the given image texture with an Image smart pointer. If you need to reset a texture of the inherited material instance, set dynamic flag to 1.

Arguments

  • int id - Texture number.
  • const Ptr<Image> & image - Image smart pointer to be set.
  • int dynamic - Dynamic texture flag.
    • If set to 0, changing a texture of the inherited material instance will also affect the base material. If the device is lost and the renderer resets its context, a texture will be reset to a default one instead of the specified image.
    • If set to 1, an image will be successfully set only for the current material instance.

Return value

1 if the image is set successfully; otherwise, 0.

int isProcedural ()

Returns a value indicating if the material has a procedural texture.

Return value

1 if the material has a procedural texture; otherwise, 0.

Ptr<Texture> getImageTexture (int num)

Gets the image texture smart pointer.

Arguments

  • int num - Texture number.

Return value

Texture smart pointer.

Ptr<Material> clone (const char * name)

Clones the material.

Arguments

  • const char * name - New material name.

Return value

Cloned material smart pointer.

float getParameterSliderMinValue (int id)

Returns the minimum allowed value of a slider parameter.

Arguments

  • int id - ID number of the target parameter.

Return value

Minimum value.

void setViewportMask (int mask)

Sets a viewport mask: a bit mask for rendering into the viewport. The material is rendered, if its mask matches the player's one.

Arguments

  • int mask - An integer value, each bit of which is used to set a bit mask.

int getParameterSliderMaxExpand (int id)

Returns a value indicating if the maximum value of a given parameter can be increased.

Arguments

  • int id - ID number of the target parameter.

Return value

Positive number if the maximum value can be changed; otherwise, 0.

int getNumTextures ()

Returns the number of material's textures.

Return value

Returns number of textures.

int getState (int num)

Gets the state value.

Arguments

  • int num - State number.

Return value

State value.

int getParameterSliderLog10 (int id)

Returns a value indicating if a given parameter uses a logarithmic scale (with the base ten).

Arguments

  • int id - ID number of the target parameter.

Return value

Positive number if the parameter uses a logarithmic scale; otherwise, 0.

const char * getImageTextureName (int id)

Gets the image texture name.

Arguments

  • int id - Texture number.

Return value

Image texture name.

void getParameterArray (int num, Vector< Math::vec4 > & values)

Gets values of the given array parameter.

Arguments

  • int num - Parameter number.
  • Vector< Math::vec4 > & values - Array of parameter values.

const char * getName ()

Returns a material name.

Return value

Material name.

Ptr<Material> getChild (int num)

Returns the child material.

Arguments

  • int num - The child material number.

Return value

The child material smart pointer.

int findParameter (const char * name, int fast_id)

Searches for a parameter by its name among all parameters of the current material.

Arguments

  • const char * name - Parameter name.
  • int fast_id - Parameter's fast identifier (hash of a name).

Return value

Parameter number.

int setParameterExpression (int id, const char * expression)

Sets the expression used as a parameter value.

Arguments

  • int id - Parameter number.
  • const char * expression - Expression parameter source.

Return value

1 if the expression is set successfully; otherwise, 0.

const char * getParameterExpression (int id)

Gets the expression used as the parameter value.

Arguments

  • int id - Parameter number.

Return value

Parameter expression, if it exists; otherwise, NULL.

Ptr<Shader> getShader (int pass)

Returns the rendering shader smart pointer for the specified rendering pass and the node type.

Arguments

  • int pass - The rendering pass number in range [0;13).

Return value

Shader smart pointer.

int isTextureHidden (int id)

Returns a value indicating if the texture is hidden.

Arguments

  • int id - The texture number.

Return value

1 is the texture is hidden; otherwise, 0.

void setCastWorldShadow (int shadow)

Sets the cast world shadow option: a value indicating if an object with the material applied should cast shadows created by the world light.

Arguments

  • int shadow - The cast world shadow option.

int findTexture (const char * name, int fast_id)

Searches for a texture by its name among all texture used by the current material.

Arguments

  • const char * name - Texture name.
  • int fast_id - Texture's fast identifier (hash of a name).

Return value

Texture number.

int getAlphaTest ()

Gets the alpha test option: a value indicating if alpha testing is enabled for the material.

Return value

The alpha test option.

int getParameterSliderMinExpand (int id)

Returns a value indicating if the minimum value of a given parameter can be decreased.

Arguments

  • int id - ID number of the target parameter.

Return value

Positive number if the minimum value can be changed; otherwise, 0.

int findTexture (const char * name)

Searches for a texture by its name among all texture used by the current material.

Arguments

  • const char * name - Texture name.

Return value

Texture number.

const char * getStateName (int num)

Returns the state name.

Arguments

  • int num - The state number.

Return value

State name.

float getParameterSlider (int id)

Gets the slider parameter value.

Arguments

  • int id - Parameter number.

Return value

Slider parameter value.

int getStateType (int num)

Returns the state type.

Arguments

  • int num - The state number.

Return value

State type.

Math::vec4 getParameter (int num)

Gets the material's parameter value.

Arguments

  • int num - Parameter number.

Return value

Parameter value.

Ptr<Material> getParent ()

Returns the parent material smart pointer.

Return value

Parent material smart pointer.

int getParameterType (int num)

Returns the material's parameter type.

Arguments

  • int num - The parameter number.

Return value

Parameter type.

int setProceduralTextureImage (int num, const Ptr<Image> & image)

Replaces the procedural texture image with an Image smart pointer. Procedural textures are calculated in run-time on GPU, using custom shaders. So, for example, this function can be used to set the initial value for such texture.

Arguments

  • int num - Texture number.
  • const Ptr<Image> & image - Image smart pointer.

Return value

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

int getStateSwitchNumItems (int num)

Returns the number of switch item names.

Arguments

  • int num - State number.

Return value

Number of switch item names.

void setAlphaTest (int test)

Sets the alpha test option: a value indicating if alpha testing is enabled for the material.

Arguments

  • int test - The alpha test option.

const char * getStateSwitchItem (int num, int item)

Returns the switch item name.

Arguments

  • int num - State number.
  • int item - Item number.

Return value

Switch item name.

int isEditable ()

Returns a value indicating if the material is editable.

Return value

1 if the material is editable; otherwise, 0.

int getImageTextureFlags (int id)

Returns the flags set on the image texture.

Arguments

  • int id - ID number of the target texture.

Return value

A flags mask.

Ptr<Shader> getShader (int pass, int node)

Returns the rendering shader smart pointer for the specified rendering pass and the node type.

Arguments

  • int pass - The rendering pass number in range [0;13).
  • int node - Node type.

Return value

Shader smart pointer.

void setParameter (int num, const Math::vec4 & arg2)

Sets a material's parameter value.

Arguments

  • int num - Parameter number.
  • const Math::vec4 & arg2 - Parameter value.

int getTwoSided ()

Gets the two sided option of the material.

Return value

The two sided option.

const char * getParameterName (int id)

Returns the material's parameter name.

Arguments

  • int id - The parameter number.

Return value

Parameter name.

int isReflection2D ()

Returns a value indicating if the material has a 2d reflection texture.

Return value

1 if the material has a 2d reflection texture; otherwise, 0.

int findState (const char * name)

Searches for a state by its name among all states of the current material.

Arguments

  • const char * name - State name.

Return value

State number.

int saveWorld (const Ptr<Xml> & xml, int force)

Saves material settings into the Xml.

Arguments

  • const Ptr<Xml> & xml - Xml smart pointer.
  • int force - Forced saving of material settings.

Return value

1 if the material settings are saved successfully; otherwise, 0.

int getCastWorldShadow ()

Gets the cast world shadow option: a value indicating if an object with the material applied should cast shadows created by the world light.

Return value

The cast world shadow option.

int getProceduralTextureImage (int num, const Ptr<Image> & image)

Reads the given procedural texture into an Image smart pointer. Procedural textures are calculated in run-time on GPU, using custom shaders. So, for example, this function enables to read the value of such texture at any moment.

Arguments

  • int num - Texture number.
  • const Ptr<Image> & image - Image smart pointer.

Return value

1 if the texture is read successfully; otherwise, 0.

int getNumChildren ()

Returns the number of child materials.

Return value

The number of child materials.

void setLightMask (int mask)

Sets a light mask for the material. The material is illuminated by a light source, if they both have corresponding masks.

Arguments

  • int mask - An integer value, each bit of which is used to set a bit mask.

int getBlendSrcFunc ()

Gets the source blending function.

Return value

The source blending function (one of the BLEND_* values described in the State class).

void setImageTextureName (int id, const char * name)

Sets the image texture name.

Arguments

  • int id - Texture number.
  • const char * name - Image texture name.

int getCastShadow ()

Gets the cast shadow option: a value indicating if an object with the material applied should cast shadows.

Return value

The cast shadow option.

int getViewportMask ()

Gets the viewport mask: a bit mask for rendering into the viewport.

Return value

An integer value, each bit of which is used to set a bit mask.

void setTwoSided (int sided)

Sets the two sided option for the material.

Arguments

  • int sided - The two sided option.

int isParent (const char * name)

Returns a value indicating if the material is a parent one.

Arguments

  • const char * name - Material name.

Return value

1 if the material is a parent material.

int getOffset ()

Gets the rendering polygon offset.

Return value

The rendering polygon offset.

int getBlendDestFunc ()

Gets the destination blending function.

Return value

The destination blending function (one of the BLEND_* values described in the State class).

void setParameterSlider (int id, float value)

Sets a slider parameter value.

Arguments

  • int id - Parameter number.
  • float value - Slider parameter value.

int saveState (const Ptr<Stream> & stream, int forced = 0)

Saves material settings into the stream.

Arguments

  • const Ptr<Stream> & stream - Stream smart pointer.
  • int forced - Forced saving of material settings.

Return value

1 if the material settings are saved successfully; otherwise, 0.

Ptr<Material> getCompare ()

Returns the compare material smart pointer.

Return value

Compare material smart pointer.

int getTransparent ()

Gets the transparent option: a value indicating if an object with the material applied should be transparent.

Return value

The transparent option (one of the TRANSPARENT_* variables).

void setState (int num, int value)

Sets the state value.

Arguments

  • int num - State number.
  • int value - State value to be set.

void setOffset (int offset)

Sets the rendering polygon offset for the material.

Arguments

  • int offset - The rendering polygon offset.

void setOrder (int order)

Updates the rendering order of material. The higher the rendering order, the lower the rendering priority (the material with the -8 order will be rendered first).

Arguments

  • int order - The rendering order.

void setCastShadow (int shadow)

Sets the cast shadow option: a value indicating if an object with the material applied should cast shadows.

Arguments

  • int shadow - The cast shadow option.

Ptr<Material> inherit (const char * name)

Inherits the material.

Arguments

  • const char * name - New material name.

Return value

Inherited material smart pointer.

int isFilter ()

Returns a value indicating if the material has a filter texture.

Return value

1 if the material has a filter texture; otherwise, 0.

int isParameterHidden (int num)

Returns a value indicating if the material's parameter is hidden.

Arguments

  • int num - The parameter number.

Return value

1 if the parameter is hidden; otherwise, 0.

void setBlendFunc (int src, int dest)

Sets the source and destination blending functions.

Arguments

  • int src - The source blending function (one of the BLEND_* values described in the State class).
  • int dest - The destination blending function (one of the BLEND_* values described in the State class).

int getOrder ()

Gets the rendering order.

Return value

Returns rendering order.

int getNumStates ()

Returns the number of material states.

Return value

The number of material states.

int TRANSPARENT_NONE

Description

An opaque material (non-transparent), doesn't use blend func.

int TRANSPARENT_BLEND

Description

A transparent material which is rendered in forward pass, uses blend func.

int TRANSPARENT_DEFERRED

Description

A transparent material which is rendered in deferred pass upon the deferred geometry into the g-buffer with alpha blend, doesn't use blend func.

int STATE_TOGGLE

Description

State of this type allows only two possible values.

int STATE_SWITCH

Description

State of this type allows specifying a set of more than two possible values.

int TEXTURE_IMAGE

Description

A standard bitmap image.

int TEXTURE_ALPHA_FADE

int TEXTURE_ENVIRONMENT

Description

A texture of this type stores an environment cube map.

int TEXTURE_DEFERRED_DEPTH

Description

A texture of this type uses a deferred buffer to store depth values.

int TEXTURE_DEFERRED_DIFFUSE

Description

A texture of this type uses a deferred buffer to store diffuse values.

int TEXTURE_DEFERRED_NORMAL

Description

A texture of this type uses a deferred buffer to store normal values.

int TEXTURE_DEFERRED_SPECULAR

Description

A texture of this type uses a deferred buffer to store specular values.

int TEXTURE_DEFERRED_VELOCITY

Description

A texture of this type uses a deferred buffer to store velocity values.

int TEXTURE_DEFERRED_DECAL_MASK

int TEXTURE_DEFERRED_LIGHT_MAP

int TEXTURE_DEFERRED_OCCLUSION

int TEXTURE_DEFERRED_LIGHT

Description

A texture of this type uses a deferred buffer to store light values.

int TEXTURE_DEFERRED_REFLECTION

int TEXTURE_LIGHT_IMAGE

Description

A texture of this type stores the light values provided by projected light sources.

int TEXTURE_LIGHT_DEPTH

Description

A texture of this type stores depth values (used to render shadows).

int TEXTURE_LIGHT_NOISE

Description

A texture of this type stores 3D noise values (used to render soft shadows).

int TEXTURE_LIGHT_VCUBE

Description

Texture of this type is used to map coordinates of the special 2D depth texture to cube map coordinates.

int TEXTURE_REFLECTION_2D

int TEXTURE_PROCEDURAL

Description

A procedurally generated texture.

int TEXTURE_FILTER

Description

A filtering texture.

int PARAMETER_CONSTANT

Description

Parameter of this type accepts only a constant value.

int PARAMETER_COLOR

Description

Parameter of this type requires a color value—a quad of floats corresponding to RGBA color components.

int PARAMETER_SLIDER

Description

Parameter of this type accepts values only from a continuous range of allowed values.

int PARAMETER_EXPRESSION

Description

Parameter of this type accepts expressions, which may include any operators, functions, and constants from the UnigineScript core library plus additional variable time and functions random() and noise().

int PARAMETER_ARRAY

Description

Parameter of this type accepts vec4 data type.

int TRANSPARENT_WATER

Last update: 2017-07-03
Build: ()