| 283 | enum Type { NONE, MATTE, GLASS, METAL, METALLIC_PAINT }; |
| 284 | |
| 285 | Ref<SceneGraph::MaterialNode> select() const |
| 286 | { |
| 287 | std::shared_ptr<Texture> nulltex; |
| 288 | if (type == NONE) { |
| 289 | return new OBJMaterial(d,map_d,Ka,map_Ka,Kd,map_Kd,Ks,map_Ks,Kt,map_Kt,Ns,map_Ns,map_Displ); |
| 290 | } else if (type == MATTE) { |
| 291 | if (coat_eta != 1.0f) return new MetallicPaintMaterial (Kd,zero,0.0f,eta.x); |
| 292 | else return new OBJMaterial(1.0f,nulltex,zero,nulltex,Kd,map_Kd,Ks,nulltex,zero,nulltex,1.0f/(1E-6f+roughness),nulltex,nulltex); |
| 293 | } else if (type == GLASS) { |
| 294 | return new ThinDielectricMaterial(Vec3fa(1.0f),eta.x,0.1f); |
| 295 | } else if (type == METAL) { |
| 296 | if (roughness == 0.0f) { |
| 297 | if (eta == Vec3fa(1.0f) && k == Vec3fa(0.0f)) return new MirrorMaterial(Kd); |
| 298 | else return new MetalMaterial(Kd,eta,k); |
| 299 | } |
| 300 | else return new MetalMaterial(Kd,eta,k,roughness); |
| 301 | } else if (type == METALLIC_PAINT) { |
| 302 | return new MetallicPaintMaterial (Kd,Ks,0.0f,coat_eta); |
| 303 | } |
| 304 | return new MatteMaterial(Vec3fa(0.5f)); |
| 305 | } |
| 306 | |
| 307 | public: |
| 308 | Type type = NONE; |