MEPP2 Project
Material.h
Go to the documentation of this file.
1 // Copyright (c) 2012-2019 University of Lyon and CNRS (France).
2 // All rights reserved.
3 //
4 // This file is part of MEPP2; you can redistribute it and/or modify
5 // it under the terms of the GNU Lesser General Public License as
6 // published by the Free Software Foundation; either version 3 of
7 // the License, or (at your option) any later version.
8 //
9 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
10 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
11 #pragma once
12 
13 #include <string>
14 #include <memory>
15 #include <map>
16 
17 
18 #ifdef FEVV_USE_JPEG
19 #define cimg_use_jpeg
20 #endif
21 #ifdef FEVV_USE_PNG
22 #define cimg_use_png
23 #endif
24 #ifdef FEVV_USE_TIFF
25 #define cimg_use_tiff
26 #endif
27 
28 #pragma push_macro("_PTHREAD_H")
29 #undef _PTHREAD_H // to avoid linking with pthread
30 #define cimg_display 0 // no CImg display
31 #include <CImg.h>
32 
33 
34 namespace FEVV {
35 namespace Types {
36 
37 
38 enum class MaterialType { MATERIAL_TYPE_STANDARD, MATERIAL_TYPE_PBR };
39 
40 #if 1
41 typedef cimg_library::CImg< unsigned char > Image;
42 #else
43 // debug
44 class Image
45 {
46 public:
47  Image(const char *name): name(name)
48  {
49  std::cout << "*** Image '" << name << "' created." << std::endl;
50  }
51 
52  ~Image()
53  {
54  std::cout << "*** Image '" << name << "' destroyed." << std::endl;
55  }
56 
57  std::string name;
58 };
59 #endif
60 
61 
65 struct Material
66 {
67  std::string name{};
68  MaterialType type = MaterialType::MATERIAL_TYPE_STANDARD;
69 
70  // Standard factors fields
71  double ambient_red_component = 1.0;
73  double ambient_blue_component = 1.0;
74 
75  double diffuse_red_component = 1.0; // Diffuse used for albedo factor if PBR
77  double diffuse_blue_component = 1.0;
78 
79  double specular_red_component = 0.0;
82 
83  double emissive_red_component = 0.0;
86 
87  double transparency = 1.0;
88 
89  // PBR factors fields
90  // albedo*Component = diffuse_*Component
91  double metallic_factor = 1.0;
92  double roughness_factor = 1.0;
93 
94  // Standard textures fields
95  std::string ambient_texture_filename{}; // Used for ambient occlusion map if
96  // PBR
97  std::string diffuse_texture_filename{}; // Used for albedo map if PBR
101  std::string normal_map_filename{}; // Used for normal map if PBR, and
102  // bump map if needed
103 
104  // PBR maps fields
105  // albedo_map_filename = diffuse_texture_filename
106  std::string metallic_map_filename{};
107  std::string roughness_map_filename{};
108  // ambient_occlusion_map_filename = ambient_texture_filename
109 
110  bool has_normal_map = false;
111 
112  // storage for texture images
113  std::map<std::string, std::shared_ptr< Image > > images;
114 };
115 
116 
117 } // namespace Types
118 } // namespace FEVV
119 
120 #pragma pop_macro("_PTHREAD_H")
FEVV::Types::Material::diffuse_blue_component
double diffuse_blue_component
Definition: Material.h:77
FEVV::Types::Material::ambient_texture_filename
std::string ambient_texture_filename
Definition: Material.h:95
FEVV::Types::Material::emissive_texture_filename
std::string emissive_texture_filename
Definition: Material.h:99
FEVV::Types::Material::emissive_red_component
double emissive_red_component
Definition: Material.h:83
FEVV::Types::Material::roughness_factor
double roughness_factor
Definition: Material.h:92
FEVV::Types::MaterialType
MaterialType
Definition: Material.h:38
FEVV::Types::Material::diffuse_texture_filename
std::string diffuse_texture_filename
Definition: Material.h:97
FEVV::Types::Material::diffuse_red_component
double diffuse_red_component
Definition: Material.h:75
FEVV::Types::Material::specular_blue_component
double specular_blue_component
Definition: Material.h:81
FEVV::Types::Material::specular_green_component
double specular_green_component
Definition: Material.h:80
FEVV::Types::Image
cimg_library::CImg< unsigned char > Image
Definition: Material.h:41
FEVV::Types::Material::metallic_map_filename
std::string metallic_map_filename
Definition: Material.h:106
FEVV::Types::MaterialType::MATERIAL_TYPE_STANDARD
@ MATERIAL_TYPE_STANDARD
FEVV::Types::Material::transparency
double transparency
Definition: Material.h:87
FEVV
Interfaces for plugins These interfaces will be used for different plugins.
Definition: Assert.h:16
FEVV::Types::Material::images
std::map< std::string, std::shared_ptr< Image > > images
Definition: Material.h:113
FEVV::Types::Material::name
std::string name
Definition: Material.h:67
FEVV::Types::Material::normal_map_filename
std::string normal_map_filename
Definition: Material.h:101
FEVV::Types::Material::emissive_green_component
double emissive_green_component
Definition: Material.h:84
FEVV::Types::Material
Definition: Material.h:66
FEVV::Types::Material::type
MaterialType type
Definition: Material.h:68
FEVV::Types::Material::specular_red_component
double specular_red_component
Definition: Material.h:79
FEVV::Types::Material::transparency_texture_filename
std::string transparency_texture_filename
Definition: Material.h:100
FEVV::Types::Material::roughness_map_filename
std::string roughness_map_filename
Definition: Material.h:107
FEVV::Types::Material::ambient_green_component
double ambient_green_component
Definition: Material.h:72
FEVV::Types::Material::specular_texture_filename
std::string specular_texture_filename
Definition: Material.h:98
FEVV::Types::Material::ambient_red_component
double ambient_red_component
Definition: Material.h:71
FEVV::Types::Material::diffuse_green_component
double diffuse_green_component
Definition: Material.h:76
FEVV::Types::Material::metallic_factor
double metallic_factor
Definition: Material.h:91
FEVV::Types::Material::ambient_blue_component
double ambient_blue_component
Definition: Material.h:73
FEVV::Types::Material::emissive_blue_component
double emissive_blue_component
Definition: Material.h:85
FEVV::Types::Material::has_normal_map
bool has_normal_map
Definition: Material.h:110