cgv
cgv::render::textured_material Class Reference

class that extends obj_material with the management of textures More...

#include <textured_material.h>

Inheritance diagram for cgv::render::textured_material:
cgv::media::illum::textured_surface_material cgv::media::illum::surface_material

Public Types

enum  AlphaTestFunc
 different test functions for alpha test
 
typedef color< float, RGB > color_type
 used color type
 

Public Member Functions

 textured_material ()
 initialize textures
 
virtual ~textured_material ()
 ensure that textures are destructed More...
 
 textured_material (const media::illum::textured_surface_material &mtl)
 construct from textured surface material More...
 
void set_alpha_test (AlphaTestFunc _alpha_test_func=AT_GREATER, float _alpha_threshold=0.0f)
 configure the alpha test that is performed in case alpha values are given in the textures
 
AlphaTestFunc get_alpha_test_func () const
 return the currently set alpha test function
 
float get_alpha_threshold () const
 return the currently used alpha threshold used by the comparison alpha test functions
 
AlphaTestFuncref_alpha_test_func ()
 return reference to currently set alpha test function
 
float & ref_alpha_threshold ()
 return reference to currently used alpha threshold used by the comparison alpha test functions
 
bool ensure_textures (context &ctx)
 call this to ensure that the textures specified by image files are loaded - typically done in the init_frame method of a drawable More...
 
int add_texture_reference (cgv::render::texture &tex)
 add a reference to a new texture that is managed outside of this class and return its index More...
 
size_t get_nr_textures () const
 virtual method to query number of textures
 
textureget_texture (int texture_index) const
 return pointer to ambient texture or 0 if non created
 
void enable_textures (context &ctx)
 enable all textures with their indices as texture unit More...
 
void disable_textures (context &ctx)
 disable material textures More...
 
void destruct_textures (context &ctx)
 destruct textures
 
void set_name (std::string o)
 set the name of the material
 
const std::string & get_name () const
 return name value
 
std::string & ref_name ()
 return reference to name value
 
void set_sRGBA_textures (bool do_set=true)
 set whether textures are interpreted in sRGB format
 
bool get_sRGBA_textures () const
 return whether textures are interpreted in sRGB format
 
bool & ref_sRGBA_textures ()
 return reference to whether textures are interpreted in sRGB format
 
unsigned get_nr_image_files () const
 return number of image files
 
int add_image_file (const std::string &file_name)
 add a new image and return its index
 
std::string get_image_file_name (int i) const
 return the name of the i-th image file
 
void set_image_file_name (int i, std::string image_file_name)
 set the image file name of i-th image file
 
std::string & ref_image_file_name (int i)
 return reference to image file name of i-th image file
 
void set_bump_scale (float bs)
 set scale of bumps
 
float get_bump_scale () const
 return bump scale
 
float & ref_bump_scale ()
 return reference to bump scale
 

Protected Attributes

std::string name
 name of material
 
bool sRGBA_textures
 whether textures are in sRGB format
 
std::vector< std::string > image_file_names
 vector of image file names
 
int diffuse_index
 index of image from which diffuse_reflectance should be mapped, -1 corresponds to no mapping
 
int roughness_index
 index of image from which roughness should be mapped, -1 corresponds to no mapping More...
 
int metalness_index
 index of image from which metalness should be mapped, -1 corresponds to no mapping More...
 
int ambient_index
 index of image from which ambient_occlusion should be mapped, -1 corresponds to no mapping More...
 
int emission_index
 index of image from which emission should be mapped, -1 corresponds to no mapping
 
int transparency_index
 index of image from which transparency should be mapped, -1 corresponds to no mapping More...
 
int propagation_slow_down_index
 index of image from which diffuse_reflectance should be mapped, -1 corresponds to no mapping
 
int specular_index
 index of image from which specular_reflectance should be mapped, -1 corresponds to no mapping
 
int normal_index
 index of image from which normals should be mapped, -1 corresponds to no mapping
 
int bump_index
 index of image from which bumps should be mapped, -1 corresponds to no mapping More...
 
float bump_scale
 scaling factor for bump map
 
BrdfType brdf_type
 store brdf type, defaults to BT_COOK_TORRANCE
 
color_type diffuse_reflectance
 diffuse reflectance of surface, defaults to 0.5,0.5,0.5
 
float roughness
 surface roughness in the range 0,1, defaults to 0.5
 
float metalness
 metalness of surface
 
float ambient_occlusion
 scalar factor to down scale ambient light, defaults to 1
 
color_type emission
 emissive color component, defaults to 0,0,0
 
float transparency
 modulation for transparency, defaults to 0
 
std::complex< float > propagation_slow_down
 complex fraction of complex interior over real exterior index of refraction, defaults to 1.5,0
 
float roughness_anisotropy
 difference of roughness matrix eigenvalues in range [0,1] relative to roughness, i.e. lambda_1 - lambda_2 = roughness_anisotropy*roughness, defaults to 0
 
float roughness_orientation
 orientation of roughness in range [0,1], where 0 corresponds to u-direction and 0.5 to v direction, defaults to 0
 
color_type specular_reflectance
 specular color used to modulate specular reflection component, should be 1,1,1
 

Detailed Description

class that extends obj_material with the management of textures

Constructor & Destructor Documentation

◆ ~textured_material()

cgv::render::textured_material::~textured_material ( )
virtual

ensure that textures are destructed

destruct textures

◆ textured_material()

cgv::render::textured_material::textured_material ( const media::illum::textured_surface_material mtl)

construct from textured surface material

construct from obj_material

Member Function Documentation

◆ add_texture_reference()

int cgv::render::textured_material::add_texture_reference ( cgv::render::texture tex)

add a reference to a new texture that is managed outside of this class and return its index

all image file based textures need to be added with add_image_file before calling this function.

◆ disable_textures()

void cgv::render::textured_material::disable_textures ( context ctx)

disable material textures

disable material

◆ enable_textures()

void cgv::render::textured_material::enable_textures ( context ctx)

enable all textures with their indices as texture unit

enable by modulating opacities of material with given opacity value

◆ ensure_textures()

bool cgv::render::textured_material::ensure_textures ( context ctx)

call this to ensure that the textures specified by image files are loaded - typically done in the init_frame method of a drawable

call this to ensure that the textures are loaded - typically done in the init_frame method of a drawable

Member Data Documentation

◆ ambient_index

int cgv::media::illum::textured_surface_material::ambient_index
protectedinherited

index of image from which ambient_occlusion should be mapped, -1 corresponds to no mapping

In case of 4 component textures ambient_occlusion is mapped from the w component.

◆ bump_index

int cgv::media::illum::textured_surface_material::bump_index
protectedinherited

index of image from which bumps should be mapped, -1 corresponds to no mapping

If no normal mapping is applies, bump map is also used for normal mapping.

◆ metalness_index

int cgv::media::illum::textured_surface_material::metalness_index
protectedinherited

index of image from which metalness should be mapped, -1 corresponds to no mapping

In case of 4 component textures metalness is mapped from the w component. For 2 component textures, metalness is mapped from the x-component.

◆ roughness_index

int cgv::media::illum::textured_surface_material::roughness_index
protectedinherited

index of image from which roughness should be mapped, -1 corresponds to no mapping

In case of 3 or 4 component textures roughness is mapped anisotropically from the xyz components. For 2 component textures, roughness is mapped from the y-component.

◆ transparency_index

int cgv::media::illum::textured_surface_material::transparency_index
protectedinherited

index of image from which transparency should be mapped, -1 corresponds to no mapping

In case of 4 component textures transparency is mapped from the w component.


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