1#include "textured_surface_material.h"
11 const std::string& _name,
16 float _ambient_occlusion,
19 const std::complex<float>& _propagation_slow_down,
20 float _roughness_anisotropy,
21 float _roughness_orientation,
23 float _bump_scale) : name(_name),
surface_material(_brdf_type, _diffuse_reflectance, _roughness, _metalness, _ambient_occlusion, _emission, _transparency, _propagation_slow_down, _roughness_anisotropy, _roughness_orientation, _specular_reflectance), bump_scale(1)
59 set_brdf_type(BrdfType(BT_LAMBERTIAN + BT_PHONG));
61 float la = sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2]);
62 float ld = sqrt(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]);
63 set_ambient_occlusion(la >= ld ? la : la/ld);
64 set_diffuse_reflectance(obj_mat.get_diffuse());
65 set_specular_reflectance(obj_mat.get_specular());
66 set_emission(obj_mat.get_emission());
67 set_roughness(std::max(0.0f, std::min(1.0f, 1.0f/(obj_mat.get_shininess()+0.992307f) - 0.0077524f)));
70 std::map<std::string, int> file_name_map;
int metalness_index
index of image from which metalness should be mapped, -1 corresponds to no mapping
std::vector< std::string > image_file_names
vector of image file names
int propagation_slow_down_index
index of image from which diffuse_reflectance should be mapped, -1 corresponds to no mapping
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
void set_name(std::string o)
set the name of the material
int transparency_index
index of image from which transparency should be mapped, -1 corresponds to no mapping
void set_sRGBA_textures(bool do_set=true)
set whether textures are interpreted in sRGB format
bool sRGBA_textures
whether textures are in sRGB format
void set_bump_scale(float bs)
set scale of bumps
int roughness_index
index of image from which roughness should be mapped, -1 corresponds to no mapping
int add_image_file(const std::string &file_name)
add a new image and return its index
int specular_index
index of image from which specular_reflectance 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 bump_index
index of image from which bumps should be mapped, -1 corresponds to no mapping
int diffuse_index
index of image from which diffuse_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