MCPcopy Create free account
hub / github.com/RenderKit/embree / ExtObjMaterial

Class ExtObjMaterial

tutorials/common/scenegraph/obj_loader.cpp:279–336  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

277 }
278
279 struct ExtObjMaterial
280 {
281 public:
282
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;
309
310 int illum = 0; /*< illumination model */
311 float d = 1.0f; /*< dissolve factor, 1=opaque, 0=transparent */
312 float Ns = 1.0f; /*< specular exponent */
313 float Ni = 1.0f; /*< optical density for the surface (index of refraction) */
314
315 Vec3fa Ka = zero; /*< ambient reflectivity */
316 Vec3fa Kd = one; /*< diffuse reflectivity */
317 Vec3fa Ks = zero; /*< specular reflectivity */
318 Vec3fa Kt = zero; /*< transmission filter */
319
320 std::shared_ptr<Texture> map_d; /*< d texture */
321 std::shared_ptr<Texture> map_Ka; /*< Ka texture */
322 std::shared_ptr<Texture> map_Kd; /*< Kd texture */
323 std::shared_ptr<Texture> map_Ks; /*< Ks texture */
324 std::shared_ptr<Texture> map_Kt; /*< Kt texture */
325 std::shared_ptr<Texture> map_Ns; /*< Ns texture */
326 std::shared_ptr<Texture> map_Displ; /*< Displ texture */
327
328 float roughness = zero;
329 std::shared_ptr<Texture> roughnessMap;
330 float coat_eta = one;
331 float coat_roughness = zero;
332 std::shared_ptr<Texture> coat_roughnessMap;
333 float bump = zero;
334 Vec3f eta = Vec3f(1.4f);
335 Vec3f k = Vec3f(3.0f);
336 };

Callers 1

loadMTLMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected