cgv
|
class that extends obj_material with the management of textures More...
#include <textured_material.h>
Public Types | |
enum | AlphaTestFunc { AT_ALWAYS , AT_LESS , AT_EQUAL , AT_GREATER } |
different test functions for alpha test More... | |
![]() | |
typedef color< float, RGB > | color_type |
used color type | |
Public Member Functions | |
textured_material () | |
initialize textures | |
virtual | ~textured_material () |
ensure that textures are destructed | |
textured_material (const media::illum::textured_surface_material &mtl) | |
construct from textured surface material | |
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 | |
AlphaTestFunc & | ref_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 | |
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 | |
size_t | get_nr_textures () const |
virtual method to query number of textures | |
texture * | get_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 | |
void | disable_textures (context &ctx) |
disable material textures | |
void | destruct_textures (context &ctx) |
destruct textures | |
![]() | |
textured_surface_material (const std::string &_name="default", BrdfType _brdf_type=BrdfType(BT_STRAUSS_DIFFUSE+BT_STRAUSS), color_type _diffuse_reflectance=0.5f, float _roughness=0.5f, float _metalness=0.0f, float _ambient_occlusion=1.0f, color_type _emission=color_type(0, 0, 0), float _transparency=0.0f, const std::complex< float > &_propagation_slow_down=std::complex< float >(1.5f, 0.0f), float _roughness_anisotropy=0.0f, float _roughness_orientation=0.0f, color_type _specular_reflectance=color_type(1, 1, 1), float _bump_scale=0.1f) | |
define default material | |
textured_surface_material (const obj_material &obj_mat) | |
convert obj material | |
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_diffuse_index (int i) |
int | get_diffuse_index () const |
int & | ref_diffuse_index () |
void | set_roughness_index (int i) |
int | get_roughness_index () const |
int & | ref_roughness_index () |
void | set_metalness_index (int i) |
int | get_metalness_index () const |
int & | ref_metalness_index () |
void | set_ambient_index (int i) |
int | get_ambient_index () const |
int & | ref_ambient_index () |
void | set_emission_index (int i) |
int | get_emission_index () const |
int & | ref_emission_index () |
void | set_transparency_index (int i) |
int | get_transparency_index () const |
int & | ref_transparency_index () |
void | set_specular_index (int i) |
int | get_specular_index () const |
int & | ref_specular_index () |
void | set_normal_index (int i) |
int | get_normal_index () const |
int & | ref_normal_index () |
void | set_bump_index (int i) |
int | get_bump_index () const |
int & | ref_bump_index () |
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 | |
![]() | |
surface_material (BrdfType _brdf_type=BrdfType(BT_STRAUSS_DIFFUSE+BT_STRAUSS), color_type _diffuse_reflectance=color_type(0.5f, 0.5f, 0.5f), float _roughness=0.5f, float _metalness=0.0f, float _ambient_occlusion=1.0f, color_type _emission=color_type(0, 0, 0), float _transparency=0.0f, const std::complex< float > &_propagation_slow_down=std::complex< float >(1.5f, 0.0f), float _roughness_anisotropy=0.0f, float _roughness_orientation=0.0f, color_type _specular_reflectance=color_type(1, 1, 1)) | |
construct default material | |
void | set_brdf_type (BrdfType brdf_type) |
BrdfType | get_brdf_type () const |
BrdfType & | ref_brdf_type () |
void | set_ambient_occlusion (float ambient_occlusion) |
float | get_ambient_occlusion () const |
float & | ref_ambient_occlusion () |
void | set_diffuse_reflectance (color_type diffuse_reflectance) |
color_type | get_diffuse_reflectance () const |
color_type & | ref_diffuse_reflectance () |
void | set_specular_reflectance (color_type specular_reflectance) |
color_type | get_specular_reflectance () const |
color_type & | ref_specular_reflectance () |
void | set_emission (color_type emission) |
color_type | get_emission () const |
color_type & | ref_emission () |
void | set_transparency (float transparency) |
float | get_transparency () const |
float & | ref_transparency () |
void | set_roughness (float roughness) |
float | get_roughness () const |
float & | ref_roughness () |
void | set_metalness (float metalness) |
float | get_metalness () const |
float & | ref_metalness () |
void | set_roughness_anisotropy (float roughness_anisotropy) |
float | get_roughness_anisotropy () const |
float & | ref_roughness_anisotropy () |
void | set_roughness_orientation (float roughness_orientation) |
float | get_roughness_orientation () const |
float & | ref_roughness_orientation () |
void | set_propagation_slow_down (std::complex< float > propagation_slow_down) |
std::complex< float > | get_propagation_slow_down () const |
std::complex< float > & | ref_propagation_slow_down () |
Protected Attributes | |
std::vector< texture * > | textures |
context * | ctx_ptr |
float | alpha_threshold |
AlphaTestFunc | alpha_test_func |
![]() | |
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 | |
int | metalness_index |
index of image from which metalness should be mapped, -1 corresponds to no mapping | |
int | ambient_index |
index of image from which ambient_occlusion should be mapped, -1 corresponds to no mapping | |
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 | |
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 | |
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] (1/2 trace of symmetric 2x2 matrix for anisotropic case where directional roughness is represented in the uv-coordinate system of texcoords), 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 | |
class that extends obj_material with the management of textures
Definition at line 12 of file textured_material.h.
different test functions for alpha test
Definition at line 16 of file textured_material.h.
cgv::render::textured_material::textured_material | ( | ) |
initialize textures
Definition at line 8 of file textured_material.cxx.
|
virtual |
ensure that textures are destructed
destruct textures
Definition at line 26 of file textured_material.cxx.
References destruct_textures(), and cgv::render::context::make_current().
cgv::render::textured_material::textured_material | ( | const media::illum::textured_surface_material & | mtl | ) |
construct from textured surface material
construct from obj_material
Definition at line 17 of file textured_material.cxx.
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.
Definition at line 33 of file textured_material.cxx.
References cgv::media::illum::textured_surface_material::image_file_names.
Referenced by cgv::render::build_render_info().
void cgv::render::textured_material::destruct_textures | ( | context & | ctx | ) |
destruct textures
Definition at line 109 of file textured_material.cxx.
Referenced by ~textured_material().
void cgv::render::textured_material::disable_textures | ( | context & | ctx | ) |
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
Definition at line 122 of file textured_material.cxx.
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
Definition at line 42 of file textured_material.cxx.
References cgv::render::texture::create_from_image(), cgv::data::component_format::get_last_error(), cgv::media::illum::textured_surface_material::image_file_names, cgv::render::texture::set_wrap_s(), and cgv::render::texture::set_wrap_t().
textured_material::AlphaTestFunc cgv::render::textured_material::get_alpha_test_func | ( | ) | const |
return the currently set alpha test function
Definition at line 76 of file textured_material.cxx.
float cgv::render::textured_material::get_alpha_threshold | ( | ) | const |
return the currently used alpha threshold used by the comparison alpha test functions
Definition at line 83 of file textured_material.cxx.
|
inlinevirtual |
virtual method to query number of textures
Reimplemented from cgv::media::illum::textured_surface_material.
Definition at line 48 of file textured_material.h.
texture * cgv::render::textured_material::get_texture | ( | int | texture_index | ) | const |
return pointer to ambient texture or 0 if non created
Definition at line 140 of file textured_material.cxx.
textured_material::AlphaTestFunc & cgv::render::textured_material::ref_alpha_test_func | ( | ) |
return reference to currently set alpha test function
Definition at line 89 of file textured_material.cxx.
float & cgv::render::textured_material::ref_alpha_threshold | ( | ) |
return reference to currently used alpha threshold used by the comparison alpha test functions
Definition at line 94 of file textured_material.cxx.
void cgv::render::textured_material::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
Definition at line 68 of file textured_material.cxx.
Referenced by cgv::render::build_render_info().
|
protected |
Definition at line 23 of file textured_material.h.
|
protected |
Definition at line 22 of file textured_material.h.
|
protected |
Definition at line 20 of file textured_material.h.
|
protected |
Definition at line 18 of file textured_material.h.