Aether3D
Game Engine
Public Member Functions | List of all members
Material Class Referenceabstract

Stores material properties for Mesh. Their names/values are directly mapped into shader uniforms. More...

#include <Material.hpp>

Public Member Functions

virtual void LoadFromFile (const char *path)=0
 
virtual const char * Name () const =0
 
virtual bool Opaque () const =0
 
virtual void SetOpaque (bool opaque)=0
 
virtual Error::Enum SetShaders (const std::string &vertexShaderPath, const std::string &fragmentShaderPath, const std::string &geometryShaderPath, const std::string &defines)=0
 
virtual void SetFloat (const std::string &name, float value)=0
 
virtual void SetMatrix (const std::string &name, const Matrix44 &matrix)=0
 
virtual void SetName (const char *name)=0
 
virtual void SetTexture (const std::string &name, const Texture *texture)=0
 
virtual void SetVector (const std::string &name, const Vec3 &value)=0
 
virtual void SetVector (const std::string &name, const Vec4 &value)=0
 

Detailed Description

Stores material properties for Mesh. Their names/values are directly mapped into shader uniforms.

Member Function Documentation

◆ LoadFromFile()

virtual void Material::LoadFromFile ( const char *  path)
pure virtual

Loads parameters and shader names from an ASCII file. File is not hot-reloaded. If parsing fails, parameters parsed before failure are kept.

Example file contents:

texture checker checker.png texture checkerNormal checker_n.png shaders cook_torrance cook_torrance param_float roughness 0.2 param_vec3 materialSpecular 0.2 0.2 0.2 param_texture diffuseMap checker param_texture normalMap checkerNormal

Parameters
pathPath.

◆ Name()

virtual const char* Material::Name ( ) const
pure virtual
Returns
Name.

◆ Opaque()

virtual bool Material::Opaque ( ) const
pure virtual
Returns
opacity.

◆ SetFloat()

virtual void Material::SetFloat ( const std::string &  name,
float  value 
)
pure virtual

Sets a float.

Parameters
nameShader uniform name.
valueValue.

◆ SetMatrix()

virtual void Material::SetMatrix ( const std::string &  name,
const Matrix44 matrix 
)
pure virtual

Sets a Matrix.

Parameters
nameShader uniform name.
matrixMatrix.

◆ SetName()

virtual void Material::SetName ( const char *  name)
pure virtual
Parameters
nameName

◆ SetOpaque()

virtual void Material::SetOpaque ( bool  opaque)
pure virtual

Sets opacity on/off. Default is opaque.

If it's off, the mesh using this material will have its textures's alpha channel applied.

Parameters
opaqueOpacity.

◆ SetShaders()

virtual Error::Enum Material::SetShaders ( const std::string &  vertexShaderPath,
const std::string &  fragmentShaderPath,
const std::string &  geometryShaderPath,
const std::string &  defines 
)
pure virtual

Sets shaders. Source language must match renderer API, eg. you can't use HLSL shaders if you're using OpenGL renderer. HLSL shaders are compiled in HLSL version 5.

Parameters
vertexShaderPathVertex shader path or shader's file name without path or extension to use search paths.
fragmentShaderPathFragment (Pixel) shader path or shader's file name without path or extension to use search paths.
geometryShaderPathGeometry shader path, can be an empty string if not used. Alternatively shader's file name without path or extension to use search paths. Ignored on unsupported renderers.
definesSpace separated shader source defines.
See also
Renderer.SetShaderSearchPaths.
Returns
Error::NO_ERRORS on success, error otherwise.

◆ SetTexture()

virtual void Material::SetTexture ( const std::string &  name,
const Texture texture 
)
pure virtual

Sets a texture. If the texture name is "textureMap", its UV scale and offset are in 4-dimensional vector "textureMap_ST".

Parameters
nameShader uniform name.
textureTexture.

◆ SetVector() [1/2]

virtual void Material::SetVector ( const std::string &  name,
const Vec3 value 
)
pure virtual

Sets a vector.

Parameters
nameShader uniform name.
valueValue.

◆ SetVector() [2/2]

virtual void Material::SetVector ( const std::string &  name,
const Vec4 value 
)
pure virtual

Sets a vector.

Parameters
nameShader uniform name.
valueValue.

The documentation for this class was generated from the following file: