Commit eac62b1e authored by Michael Migliore's avatar Michael Migliore
Browse files

Add glTF Unlit extension support

parent d8462805
Pipeline #217656 running with stage
......@@ -149,9 +149,8 @@ void GenerateIndicesForPrimitive(vtkGLTFDocumentLoader::Primitive& primitive)
}
//------------------------------------------------------------------------------
const std::vector<std::string> vtkGLTFDocumentLoader::SupportedExtensions = {
"KHR_lights_punctual"
};
const std::vector<std::string> vtkGLTFDocumentLoader::SupportedExtensions = { "KHR_lights_punctual",
"KHR_materials_unlit" };
//------------------------------------------------------------------------------
vtkStandardNewMacro(vtkGLTFDocumentLoader);
......
......@@ -322,6 +322,9 @@ public:
bool DoubleSided;
std::string Name;
// extension KHR_materials_unlit
bool Unlit;
};
/**
......
......@@ -744,6 +744,14 @@ bool vtkGLTFDocumentLoaderInternals::LoadMaterial(
material.Name = "";
vtkGLTFUtils::GetStringValue(root["name"], material.Name);
material.Unlit = false;
const auto& extRoot = root["extensions"];
if (!extRoot.empty())
{
material.Unlit = extRoot.isMember("KHR_materials_unlit");
}
return true;
}
......
......@@ -80,6 +80,10 @@ vtk_add_test_cxx(vtkIOImportCxxTests tests
TestGLTFImporterCamera,TestGLTFImporter.cxx DATA{../Data/glTF/Cameras/Cameras.gltf} 1
)
vtk_add_test_cxx(vtkIOImportCxxTests tests
TestGLTFImporterUnlit,TestGLTFImporter.cxx DATA{../Data/glTF/UnlitTest/UnlitTest.glb} -1
)
vtk_add_test_cxx(vtkIOImportCxxTests tests
NO_VALID
TestImportGLFTExportOBJ,TestImportExportOBJ.cxx
......
bcb58ac78fadd7c230999a346a31be12bdad9767e090f046752aaad496ccc23f6f114236dbf76f515bc62f5d0d557f6d0dfef6929dcd0505b6c5fc82036c0443
15cbfb880106ab29f452f9f702dd1c8b550d5e9352e372445ef7adac36a2e30af7137a9a973a6c30cd326ddd54c6660fb2cc15e17d30f6d8145b6281e31679b8
......@@ -311,6 +311,19 @@ void ApplyGLTFMaterialToVTKActor(std::shared_ptr<vtkGLTFDocumentLoader::Model> m
property->SetNormalTexture(normalTex);
}
}
// extension KHR_materials_unlit
actor->GetProperty()->SetLighting(!material.Unlit);
if (material.Unlit)
{
// the polydata mapper does not convert to sRGB when Unlit, so convert it there
double r, g, b;
actor->GetProperty()->GetColor(r, g, b);
r = pow(r, 1.f / 2.2f);
g = pow(g, 1.f / 2.2f);
b = pow(b, 1.f / 2.2f);
actor->GetProperty()->SetColor(r, g, b);
}
};
//------------------------------------------------------------------------------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment