Skip to content

Commit c01ed85

Browse files
committed
Add some new materials
1 parent e664537 commit c01ed85

File tree

1 file changed

+234
-6
lines changed

1 file changed

+234
-6
lines changed

App/Scene/scene.cpp

Lines changed: 234 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -642,14 +642,207 @@ Scene* Scene::LoadFromObj(std::string const& filename, std::string const& basepa
642642
matmap[i] = scene->materials_.size() - 1;
643643
continue;
644644
}
645+
else if (objmaterials[i].name == "mirror")
646+
{
647+
Material specular;
648+
specular.kx = float3(1.f, 1.f, 1.f);
649+
specular.ni = 1.4f;
650+
specular.ns = 0.05f;
651+
specular.type = kIdealReflect;
652+
specular.fresnel = 0.f;
653+
654+
scene->materials_.push_back(specular);
655+
scene->material_names_.push_back(objmaterials[i].name);
656+
matmap[i] = scene->materials_.size() - 1;
657+
continue;
658+
}
659+
else if (objmaterials[i].name == "fabric")
660+
{
661+
Material specular;
662+
specular.kx = float3(0.6f, 0.6f, 0.6f);
663+
specular.ni = 1.3f;
664+
specular.ns = 0.3f;
665+
specular.type = kMicrofacetGGX;
666+
specular.fresnel = 1.f;
667+
668+
if (!objmaterials[i].normal_texname.empty())
669+
{
670+
auto iter = textures.find(objmaterials[i].normal_texname);
671+
if (iter != textures.end())
672+
{
673+
specular.nmapidx = iter->second;
674+
}
675+
else
676+
{
677+
Texture texture;
678+
679+
// Load texture
680+
LoadTexture(basepath + "/" + objmaterials[i].normal_texname, texture, scene->texturedata_);
681+
682+
// Add texture desc
683+
specular.nmapidx = (int)scene->textures_.size();
684+
scene->textures_.push_back(texture);
685+
686+
// Save in the map
687+
textures[objmaterials[i].normal_texname] = specular.nmapidx;
688+
}
689+
}
690+
691+
if (!objmaterials[i].diffuse_texname.empty())
692+
{
693+
auto iter = textures.find(objmaterials[i].diffuse_texname);
694+
if (iter != textures.end())
695+
{
696+
specular.kxmapidx = iter->second;
697+
}
698+
else
699+
{
700+
Texture texture;
701+
702+
// Load texture
703+
LoadTexture(basepath + "/" + objmaterials[i].diffuse_texname, texture, scene->texturedata_);
704+
705+
// Add texture desc
706+
specular.kxmapidx = (int)scene->textures_.size();
707+
scene->textures_.push_back(texture);
708+
709+
// Save in the map
710+
textures[objmaterials[i].diffuse_texname] = specular.kxmapidx;
711+
}
712+
}
713+
714+
scene->materials_.push_back(specular);
715+
scene->material_names_.push_back(objmaterials[i].name);
716+
matmap[i] = scene->materials_.size() - 1;
717+
continue;
718+
}
719+
else if (objmaterials[i].name == "leather")
720+
{
721+
Material specular;
722+
specular.kx = float3(0.7f, 0.7f, 0.7f);
723+
specular.ni = 1.1f;
724+
specular.ns = 0.03f;
725+
specular.type = kMicrofacetGGX;
726+
specular.fresnel = 1.f;
727+
728+
if (!objmaterials[i].normal_texname.empty())
729+
{
730+
auto iter = textures.find(objmaterials[i].normal_texname);
731+
if (iter != textures.end())
732+
{
733+
specular.nmapidx = iter->second;
734+
}
735+
else
736+
{
737+
Texture texture;
738+
739+
// Load texture
740+
LoadTexture(basepath + "/" + objmaterials[i].normal_texname, texture, scene->texturedata_);
741+
742+
// Add texture desc
743+
specular.nmapidx = (int)scene->textures_.size();
744+
scene->textures_.push_back(texture);
745+
746+
// Save in the map
747+
textures[objmaterials[i].normal_texname] = specular.nmapidx;
748+
}
749+
}
750+
if (!objmaterials[i].diffuse_texname.empty())
751+
{
752+
auto iter = textures.find(objmaterials[i].diffuse_texname);
753+
if (iter != textures.end())
754+
{
755+
specular.kxmapidx = iter->second;
756+
}
757+
else
758+
{
759+
Texture texture;
760+
761+
// Load texture
762+
LoadTexture(basepath + "/" + objmaterials[i].diffuse_texname, texture, scene->texturedata_);
763+
764+
// Add texture desc
765+
specular.kxmapidx = (int)scene->textures_.size();
766+
scene->textures_.push_back(texture);
767+
768+
// Save in the map
769+
textures[objmaterials[i].diffuse_texname] = specular.kxmapidx;
770+
}
771+
}
772+
773+
scene->materials_.push_back(specular);
774+
scene->material_names_.push_back(objmaterials[i].name);
775+
matmap[i] = scene->materials_.size() - 1;
776+
continue;
777+
}
778+
else if (objmaterials[i].name == "pillow")
779+
{
780+
Material specular;
781+
specular.kx = float3(0.95f, 0.95f, 0.95f);
782+
specular.ni = 1.3f;
783+
specular.ns = 0.3f;
784+
specular.type = kLambert;
785+
specular.fresnel = 0.f;
786+
787+
if (!objmaterials[i].normal_texname.empty())
788+
{
789+
auto iter = textures.find(objmaterials[i].normal_texname);
790+
if (iter != textures.end())
791+
{
792+
specular.nmapidx = iter->second;
793+
}
794+
else
795+
{
796+
Texture texture;
797+
798+
// Load texture
799+
LoadTexture(basepath + "/" + objmaterials[i].normal_texname, texture, scene->texturedata_);
800+
801+
// Add texture desc
802+
specular.nmapidx = (int)scene->textures_.size();
803+
scene->textures_.push_back(texture);
804+
805+
// Save in the map
806+
textures[objmaterials[i].normal_texname] = specular.nmapidx;
807+
}
808+
}
809+
810+
if (!objmaterials[i].diffuse_texname.empty())
811+
{
812+
auto iter = textures.find(objmaterials[i].diffuse_texname);
813+
if (iter != textures.end())
814+
{
815+
specular.kxmapidx = iter->second;
816+
}
817+
else
818+
{
819+
Texture texture;
820+
821+
// Load texture
822+
LoadTexture(basepath + "/" + objmaterials[i].diffuse_texname, texture, scene->texturedata_);
823+
824+
// Add texture desc
825+
specular.kxmapidx = (int)scene->textures_.size();
826+
scene->textures_.push_back(texture);
827+
828+
// Save in the map
829+
textures[objmaterials[i].diffuse_texname] = specular.kxmapidx;
830+
}
831+
}
832+
833+
scene->materials_.push_back(specular);
834+
scene->material_names_.push_back(objmaterials[i].name);
835+
matmap[i] = scene->materials_.size() - 1;
836+
continue;
837+
}
645838
else if (objmaterials[i].name == "chrome" || objmaterials[i].name == "wire_225143087" || objmaterials[i].name == "HeadlightChrome" || objmaterials[i].name == "Chrome")
646839
{
647840
Material specular;
648-
specular.kx = 1.3f * float3(0.58f, 0.58f, 0.58f);
649-
specular.ni = 580.5f;
650-
specular.ns = 0.0025f;
841+
specular.kx = float3(0.99f, 0.99f, 0.99f);
842+
specular.ni = 10.5f;
843+
specular.ns = 0.025f;
651844
specular.type = kMicrofacetGGX;
652-
//specular.fresnel = 1.f;
845+
specular.fresnel = 1.f;
653846

654847
scene->materials_.push_back(specular);
655848
scene->material_names_.push_back(objmaterials[i].name);
@@ -729,7 +922,7 @@ Scene* Scene::LoadFromObj(std::string const& filename, std::string const& basepa
729922
else if (objmaterials[i].name == "light" || objmaterials[i].name == "Emit" || objmaterials[i].name == "Light3" || objmaterials[i].name == "dayLight_portal")
730923
{
731924
Material emissive;
732-
emissive.kx = 5.f * float3(0.8f, 0.8f, 0.8f);
925+
emissive.kx = 5.f * float3(0.8f, 0.8f, 0.7f);
733926
emissive.type = kEmissive;
734927

735928
if (!objmaterials[i].diffuse_texname.empty())
@@ -760,7 +953,42 @@ Scene* Scene::LoadFromObj(std::string const& filename, std::string const& basepa
760953
scene->material_names_.push_back(objmaterials[i].name);
761954
matmap[i] = scene->materials_.size() - 1;
762955
continue;
763-
}
956+
} //
957+
else if (objmaterials[i].name == "wire_138008110")
958+
{
959+
Material emissive;
960+
emissive.kx = 5.f * float3(0.8f, 0.8f, 0.7f);
961+
emissive.type = kEmissive;
962+
963+
if (!objmaterials[i].diffuse_texname.empty())
964+
{
965+
auto iter = textures.find(objmaterials[i].diffuse_texname);
966+
if (iter != textures.end())
967+
{
968+
emissive.kxmapidx = iter->second;
969+
}
970+
else
971+
{
972+
Texture texture;
973+
974+
// Load texture
975+
LoadTexture(basepath + "/" + objmaterials[i].diffuse_texname, texture, scene->texturedata_);
976+
977+
// Add texture desc
978+
emissive.kxmapidx = (int)scene->textures_.size();
979+
scene->textures_.push_back(texture);
980+
981+
// Save in the map
982+
textures[objmaterials[i].diffuse_texname] = emissive.nmapidx;
983+
}
984+
}
985+
986+
987+
scene->materials_.push_back(emissive);
988+
scene->material_names_.push_back(objmaterials[i].name);
989+
matmap[i] = scene->materials_.size() - 1;
990+
continue;
991+
} // wire_138008110
764992
else if (objmaterials[i].name == "HeadLightAngelEye")
765993
{
766994
Material emissive;

0 commit comments

Comments
 (0)