|
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... | |
Public Types inherited from cgv::media::illum::surface_material | |
| using | color_type = cgv::rgb |
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 | |
Public Member Functions inherited from cgv::media::illum::textured_surface_material | |
| textured_surface_material () | |
| construct using default values | |
| textured_surface_material (const obj_material &obj_mat) | |
| construct from obj material | |
| 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 | |
Protected Attributes | |
| std::vector< texture * > | textures |
| context * | ctx_ptr |
| float | alpha_threshold |
| AlphaTestFunc | alpha_test_func |
Protected Attributes inherited from cgv::media::illum::textured_surface_material | |
| std::vector< std::string > | image_file_names |
| vector of image file names | |
Additional Inherited Members | |
Public Attributes inherited from cgv::media::illum::textured_surface_material | |
| std::string | name = "default" |
| name of material | |
| bool | sRGBA_textures = false |
| whether textures are in sRGB format | |
| int | diffuse_index = -1 |
| index of image from which diffuse_reflectance should be mapped, -1 corresponds to no mapping | |
| int | roughness_index = -1 |
| index of image from which roughness should be mapped, -1 corresponds to no mapping | |
| int | metalness_index = -1 |
| index of image from which metalness should be mapped, -1 corresponds to no mapping | |
| int | ambient_index = -1 |
| index of image from which ambient_occlusion should be mapped, -1 corresponds to no mapping | |
| int | emission_index = -1 |
| index of image from which emission should be mapped, -1 corresponds to no mapping | |
| int | transparency_index = -1 |
| index of image from which transparency should be mapped, -1 corresponds to no mapping | |
| int | propagation_slow_down_index = -1 |
| index of image from which diffuse_reflectance should be mapped, -1 corresponds to no mapping | |
| int | specular_index = -1 |
| index of image from which specular_reflectance should be mapped, -1 corresponds to no mapping | |
| int | normal_index = -1 |
| index of image from which normals should be mapped, -1 corresponds to no mapping | |
| int | bump_index = -1 |
| index of image from which bumps should be mapped, -1 corresponds to no mapping | |
| float | bump_scale = 0.1f |
| scaling factor for bump map | |
Public Attributes inherited from cgv::media::illum::surface_material | |
| BrdfType | brdf_type = BrdfType(BT_STRAUSS_DIFFUSE + BT_STRAUSS) |
| store brdf type, defaults to BT_STRAUSS_DIFFUSE + BT_STRAUSS | |
| color_type | diffuse_reflectance = { 0.5f } |
| diffuse reflectance of surface, defaults to 0.5,0.5,0.5 | |
| float | roughness = 0.5f |
| 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 = 0.0f |
| metalness of surface, defaults to 0 | |
| float | ambient_occlusion = 1.0f |
| scalar factor to down scale ambient light, defaults to 1 | |
| color_type | emission = { 0.0f } |
| emissive color component, defaults to 0,0,0 | |
| float | transparency = 0.0f |
| modulation for transparency, defaults to 0 | |
| std::complex< float > | propagation_slow_down = { 1.5f, 0.0f } |
| complex fraction of complex interior over real exterior index of refraction, defaults to 1.5,0 | |
| float | roughness_anisotropy = 0.0f |
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 = 0.0f |
| 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 = { 1.0f } |
| 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.
Referenced by cgv::render::shader_program::set_textured_material_uniform().
| 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.