Commit 9e02b8cb authored by MURRAY David's avatar MURRAY David
Browse files

working on optix part

parent 7e843b04
...@@ -344,7 +344,7 @@ void OptixGeometryHandler::loadMeshFromMRF( ...@@ -344,7 +344,7 @@ void OptixGeometryHandler::loadMeshFromMRF(
geometry->setAttributeProgram(optix_mesh.attributes); geometry->setAttributeProgram(optix_mesh.attributes);
//Materials: TODO: per face //Materials: TODO: per face
geometry->setMaterialCount(1); geometry->setMaterialCount(optix_materials.size());
geometry->setMaterialIndices(buffers.mat_indices, 0, 0, RT_FORMAT_UNSIGNED_INT); geometry->setMaterialIndices(buffers.mat_indices, 0, 0, RT_FORMAT_UNSIGNED_INT);
......
...@@ -110,6 +110,76 @@ void OptixMaterialHandler::releaseMemory() ...@@ -110,6 +110,76 @@ void OptixMaterialHandler::releaseMemory()
} }
} }
optix::Material OptixMaterialHandler::getMaterialFromMRF(unsigned int index)
{
auto material = _mrf_materials[index];
auto fresnel_mirror = dynamic_cast<mrf::materials::FresnelMirror *>(material);
auto perfect_mirror = dynamic_cast<mrf::materials::PerfectMirror *>(material);
auto ggx = dynamic_cast<mrf::materials::GGX *>(material);
if (fresnel_mirror || perfect_mirror || ggx)
{
return _microfacet_conductor;
}
auto fresnel_glass = dynamic_cast<mrf::materials::FresnelGlass *>(material);
auto walter = dynamic_cast<mrf::materials::_WalterBSDF<mrf::materials::GGX> *>(material);
if (fresnel_glass || walter)
{
return _microfacet_dielectric;
}
//TEMP COMMENT -> ALWAYS COMPILE LAMBERT (used as proxy when create geometry instances)
//If not, error when loading scenes without lambert
//TODO modif in optix_geometry_handler to directly use the correct material
auto lambert = dynamic_cast<mrf::materials::Lambert *>(material);
auto checkerboard = dynamic_cast<mrf::materials::CheckerBoard *>(material);
if (lambert || checkerboard)
{
return _lambert;
}
auto phong = dynamic_cast<mrf::materials::LPhysicalPhong *>(material);
auto phongTextured = dynamic_cast<mrf::materials::LPhysicalPhongTextured *>(material);
if (phong || phongTextured)
{
return _phong;
}
auto principled = dynamic_cast<mrf::materials::PrincipledDisney *>(material);
if (principled)
{
return _principled;
}
auto measured = dynamic_cast<mrf::materials::MeasuredIsotropic *>(material);
if (measured)
{
return _measured_isotropic;
}
auto normal_mat = dynamic_cast<mrf::materials::NormalShader *>(material);
auto tangent_mat = dynamic_cast<mrf::materials::TangentShader *>(material);
auto uv_mat = dynamic_cast<mrf::materials::UVShader *>(material);
auto flat_mat = dynamic_cast<mrf::materials::FlatBRDF *>(material);
if (normal_mat || tangent_mat || uv_mat || flat_mat)
{
return _debug_shader;
}
auto shadow_catcher_mat = dynamic_cast<mrf::materials::ShadowCatcher *>(material);
if (shadow_catcher_mat)
{
return _shadow_catcher;
}
auto diffuse_emittance = dynamic_cast<mrf::materials::DiffuseEmittance *>(material);
if (diffuse_emittance)
{
return _diffuse_emittance;
}
}
}
void OptixMaterialHandler::createMaterials(std::vector<std::string> const &cuda_compile_options) void OptixMaterialHandler::createMaterials(std::vector<std::string> const &cuda_compile_options)
{ {
......
...@@ -44,7 +44,7 @@ public: ...@@ -44,7 +44,7 @@ public:
void releaseMemory(); void releaseMemory();
void createMaterials(std::vector<std::string> const &cuda_compile_options); void createMaterials(std::vector<std::string> const &cuda_compile_options);
void getMaterialFromMRF(); optix::Material getMaterialFromMRF(unsigned int index);
#ifdef MRF_RENDERING_MODE_SPECTRAL #ifdef MRF_RENDERING_MODE_SPECTRAL
/** /**
......
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