Oxygen Engine
Modern C++ 3D Engine using OpenGL
Loading...
Searching...
No Matches
oe::scene::Material Class Reference

Render agnostic material. More...

#include <OxygenEngine/scene/material.h>

Collaboration diagram for oe::scene::Material:
[legend]

Classes

struct  TransmissiveProperties
 Material properties related to physically-based transparency related effects. More...
 

Public Types

enum class  DrawMode : uint8_t {
  TRIANGLES = 0x04 , TRIANGLE_STRIP = 0x05 , TRIANGLE_FAN = 0x06 , POINTS = 0x00 ,
  LINES = 0x01
}
 Specify how the mesh vertices will be rendered. More...
 

Public Member Functions

void setTexture (const std::string &name, std::shared_ptr< oe::render::Texture > texture, const int32_t layer=-1)
 Set Texture at specified layer.
 
std::shared_ptr< oe::render::TexturegetTexture (const uint32_t &layer) const noexcept
 Get Texture stored at specified layer.
 
uint32_t getNextAvailableTextureLayer (const uint32_t start=0) const
 Get an available texture layer for this material.
 
const auto & getTextures () const
 Get all material textures.
 
template<typename T >
MaterialsetProperty (const std::string &name, const T &value)=delete
 Set a property on a material.
 
template<typename T >
MaterialsetArray (const std::string &name, const std::vector< T > &value)=delete
 Set a array of properties on a material.
 
template<>
MaterialsetProperty (const std::string &name, const size_t &value)
 
template<>
MaterialsetProperty (const std::string &name, const bool &value)
 
template<>
MaterialsetArray (const std::string &name, const std::vector< bool > &values)
 

Public Attributes

DrawMode draw_mode = DrawMode::TRIANGLES
 Describe how the mesh should be drawn.
 
uint32_t flags = 0
 General purpose user flags, may be used for collisions / sounds / etc...
 
std::shared_ptr< oe::render::ShaderBaseshader = nullptr
 Shader to use to render this material.
 
bool double_sided = false
 Draws two sides of faces.
 
bool invert_faces = false
 If not double sided, draws back faces instead of front ones.
 
glm::vec2 texture_tiling = glm::vec2(1.f)
 Apply a tiling to the texture UV.
 
glm::vec2 texture_offset = glm::vec2(0.f)
 Apply an offset to the texture UV.
 
bool is_blend = false
 This material need blending (transparency, effects, ...)
 
TransmissiveProperties transmissive_properties
 Physically-based transmission properties.
 
float alpha_threshold = 0.5f
 Texture with alpha below this value will be considered completely transparent.
 
Materialparent = nullptr
 Material source where properties/textures should be inherited from.
 
bool inherit_properties = false
 Check if Material properties should be inherited from parent Material.
 
bool inherit_textures = false
 Check if Material textures should be inherited from parent Material.
 

Friends

class oe::render::ShaderBase
 

Detailed Description

Render agnostic material.

See also
oe::render::ShaderBase::fillFromMaterial to understand which properties are automatically sent to shaders

Member Enumeration Documentation

◆ DrawMode

enum class oe::scene::Material::DrawMode : uint8_t
strong

Specify how the mesh vertices will be rendered.

Enumerator
TRIANGLES 

The mesh will be drawn with filled triangles (default value)

TRIANGLE_STRIP 

Generate triangles where each vertice added will make a new triangle with the last 2 previous ones

TRIANGLE_FAN 

Generate triangles where they are build around the inital vertex

Can be used to build pyramids or any structure where all vertices are tied around one

POINTS 

The mesh will be drawn without connecting vertices (like a "scatter plot")

LINES 

The mesh will be drawn with lines between vertices (like the "wireframe meshes" for example)

Member Function Documentation

◆ getNextAvailableTextureLayer()

uint32_t oe::scene::Material::getNextAvailableTextureLayer ( const uint32_t  start = 0) const

Get an available texture layer for this material.

Note
Material being rendering agnostic, there is no limit on textures layers
Parameters
startDo not search below this layer
Returns
id of next available layer
Exceptions
runtime_errorIf there are more than INT_MAX layers

◆ getTextures()

const auto & oe::scene::Material::getTextures ( ) const
inline

Get all material textures.

Returns
map where keys are textures names and values are std::pair<layer, std::shared_ptr<Texture>>

◆ setArray()

template<typename T >
Material * oe::scene::Material::setArray ( const std::string &  name,
const std::vector< T > &  value 
)
delete

Set a array of properties on a material.

Parameters
namearray name
valuevector of property values

◆ setProperty()

template<typename T >
Material * oe::scene::Material::setProperty ( const std::string &  name,
const T &  value 
)
delete

Set a property on a material.

Parameters
nameproperty name
valueproperty value

◆ setTexture()

void oe::scene::Material::setTexture ( const std::string &  name,
std::shared_ptr< oe::render::Texture texture,
const int32_t  layer = -1 
)

Set Texture at specified layer.

Parameters
nameTexture uniform name
texturetexture pointer
layerlayer (set to -1 to use the next available)

Member Data Documentation

◆ flags

uint32_t oe::scene::Material::flags = 0

General purpose user flags, may be used for collisions / sounds / etc...

Note
OxygenEngine won't touch those

◆ texture_offset

glm::vec2 oe::scene::Material::texture_offset = glm::vec2(0.f)

Apply an offset to the texture UV.

Note
Example effect: if moved with time, conveyor or waterfall

◆ texture_tiling

glm::vec2 oe::scene::Material::texture_tiling = glm::vec2(1.f)

Apply a tiling to the texture UV.

Note
Example effect: if moved with time, zoom-in / zoom-out texture

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