Maj terminée. Pour consulter la release notes associée voici le lien :
https://about.gitlab.com/releases/2021/07/07/critical-security-release-gitlab-14-0-4-released/

Commit 0471b55b authored by MURRAY David's avatar MURRAY David
Browse files

changing geometry and material handler routine for better pre-association

parent 502f8a39
......@@ -137,8 +137,11 @@ void OptixGeometryHandler::importMrfScene(
//apply a default lambert material to avoid optix error due to loadMesh with a geometry
//that hasn't got any material or closesthit/
//optix_mesh.material = material_handler.lambert();
std::vector<optix::Material> optix_materials;
optix_materials.push_back(material_handler.lambert());
std::vector<optix::Material> optix_materials = material_handler.getMaterialFromMRF(material_id);
//std::vector<optix::Material> optix_materials;
//optix_materials.push_back(material_handler.lambert());
optix::Matrix4x4 transform = optix::Matrix4x4((*shape_it)->worldToObjectTransform().ptr());
......
......@@ -11,20 +11,7 @@
#include <mrf_core/geometry/quad.hpp>
#include <mrf_core/geometry/direction.hpp>
#include <mrf_core/materials/diffuse_emittance.hpp>
#include <mrf_core/materials/uniform_emittance.hpp>
#include <mrf_core/materials/conical_emittance.hpp>
#include <mrf_core/materials/dirac_emittance.hpp>
#include <mrf_core/materials/lambert.hpp>
#include <mrf_core/materials/fresnel_mirror.hpp>
#include <mrf_core/materials/checkerboard.hpp>
#include <mrf_core/materials/measured_isotropic.hpp>
#include <mrf_core/materials/principled.hpp>
#include <mrf_core/materials/flat.hpp>
#include <mrf_core/materials/normal_shader.hpp>
#include <mrf_core/materials/uv_shader.hpp>
#include <mrf_core/materials/tangent_shader.hpp>
#include <mrf_core/materials/shadow_catcher.hpp>
#include <mrf_core/materials/all_materials.hpp>
#include <mrf_optix/optix_material_handler.hpp>
#include <mrf_optix/optix_util.hpp>
......@@ -110,77 +97,90 @@ void OptixMaterialHandler::releaseMemory()
}
}
optix::Material OptixMaterialHandler::getMaterialFromMRF(unsigned int index)
std::vector<optix::Material> OptixMaterialHandler::getMaterialFromMRF(unsigned int index) const
{
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)
auto material = _mrf_materials[index];
std::vector<optix::Material> ret_vec;
std::vector<unsigned int> indices;
auto multi_mat = dynamic_cast<mrf::materials::MultiMaterial *>(material);
if (multi_mat)
{
return _microfacet_conductor;
indices = multi_mat->getAllId();
}
else
indices.push_back(index);
auto fresnel_glass = dynamic_cast<mrf::materials::FresnelGlass *>(material);
auto walter = dynamic_cast<mrf::materials::_WalterBSDF<mrf::materials::GGX> *>(material);
if (fresnel_glass || walter)
for (unsigned int i = 0; i < indices.size(); ++i)
{
return _microfacet_dielectric;
}
material = _mrf_materials[indices[i]];
//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 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)
{
ret_vec.push_back(_microfacet_conductor);
}
auto phong = dynamic_cast<mrf::materials::LPhysicalPhong *>(material);
auto phongTextured = dynamic_cast<mrf::materials::LPhysicalPhongTextured *>(material);
if (phong || phongTextured)
{
return _phong;
}
auto fresnel_glass = dynamic_cast<mrf::materials::FresnelGlass *>(material);
auto walter = dynamic_cast<mrf::materials::_WalterBSDF<mrf::materials::GGX> *>(material);
if (fresnel_glass || walter)
{
ret_vec.push_back(_microfacet_dielectric);
}
auto principled = dynamic_cast<mrf::materials::PrincipledDisney *>(material);
if (principled)
{
return _principled;
}
auto lambert = dynamic_cast<mrf::materials::Lambert *>(material);
auto checkerboard = dynamic_cast<mrf::materials::CheckerBoard *>(material);
if (lambert || checkerboard)
{
ret_vec.push_back(_lambert);
}
auto measured = dynamic_cast<mrf::materials::MeasuredIsotropic *>(material);
if (measured)
{
return _measured_isotropic;
}
auto phong = dynamic_cast<mrf::materials::LPhysicalPhong *>(material);
auto phongTextured = dynamic_cast<mrf::materials::LPhysicalPhongTextured *>(material);
if (phong || phongTextured)
{
ret_vec.push_back(_phong);
}
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 principled = dynamic_cast<mrf::materials::PrincipledDisney *>(material);
if (principled)
{
ret_vec.push_back(_principled);
}
auto shadow_catcher_mat = dynamic_cast<mrf::materials::ShadowCatcher *>(material);
if (shadow_catcher_mat)
{
return _shadow_catcher;
}
auto measured = dynamic_cast<mrf::materials::MeasuredIsotropic *>(material);
if (measured)
{
ret_vec.push_back(_measured_isotropic);
}
auto diffuse_emittance = dynamic_cast<mrf::materials::DiffuseEmittance *>(material);
if (diffuse_emittance)
{
return _diffuse_emittance;
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)
{
ret_vec.push_back(_debug_shader);
}
auto shadow_catcher_mat = dynamic_cast<mrf::materials::ShadowCatcher *>(material);
if (shadow_catcher_mat)
{
ret_vec.push_back(_shadow_catcher);
}
auto diffuse_emittance = dynamic_cast<mrf::materials::DiffuseEmittance *>(material);
if (diffuse_emittance)
{
ret_vec.push_back(_diffuse_emittance);
}
}
}
return ret_vec;
}
void OptixMaterialHandler::createMaterials(std::vector<std::string> const &cuda_compile_options)
{
try
......@@ -202,17 +202,21 @@ void OptixMaterialHandler::createMaterials(std::vector<std::string> const &cuda_
//Parse materials to compile only needed one.
for (auto &material : _mrf_materials)
{
mrf::materials::FresnelMirror *fresnel_mirror = dynamic_cast<mrf::materials::FresnelMirror *>(material);
mrf::materials::PerfectMirror *perfect_mirror = dynamic_cast<mrf::materials::PerfectMirror *>(material);
mrf::materials::GGX * ggx = dynamic_cast<mrf::materials::GGX *>(material);
//Multi material is a proxy, no need to compile a specific kernel.
//All its underlying materials are in general material list and will be compiled normally.
auto multi_mat = dynamic_cast<mrf::materials::MultiMaterial *>(material);
if (multi_mat) continue;
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) && refl_materials["-DMICROFACET_CONDUCTOR"] == nullptr)
{
refl_materials["-DMICROFACET_CONDUCTOR"] = &_microfacet_conductor;
}
mrf::materials::FresnelGlass *fresnel_glass = dynamic_cast<mrf::materials::FresnelGlass *>(material);
mrf::materials::_WalterBSDF<mrf::materials::GGX> *walter
= dynamic_cast<mrf::materials::_WalterBSDF<mrf::materials::GGX> *>(material);
auto fresnel_glass = dynamic_cast<mrf::materials::FresnelGlass *>(material);
auto walter = dynamic_cast<mrf::materials::_WalterBSDF<mrf::materials::GGX> *>(material);
if ((fresnel_glass || walter) && trans_materials["-DMICROFACET_DIELECTRIC"] == nullptr)
{
trans_materials["-DMICROFACET_DIELECTRIC"] = &_microfacet_dielectric;
......@@ -221,28 +225,27 @@ void OptixMaterialHandler::createMaterials(std::vector<std::string> const &cuda_
//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
//mrf::materials::Lambert * lambert = dynamic_cast<mrf::materials::Lambert *>(material);
//mrf::materials::CheckerBoard *checkerboard = dynamic_cast<mrf::materials::CheckerBoard *>(material);
//if ((lambert || checkerboard) && refl_materials["-DLAMBERT"] == nullptr)
//{
refl_materials["-DLAMBERT"] = &_lambert;
//}
mrf::materials::LPhysicalPhong * phong = dynamic_cast<mrf::materials::LPhysicalPhong *>(material);
mrf::materials::LPhysicalPhongTextured *phongTextured
= dynamic_cast<mrf::materials::LPhysicalPhongTextured *>(material);
auto lambert = dynamic_cast<mrf::materials::Lambert *>(material);
auto checkerboard = dynamic_cast<mrf::materials::CheckerBoard *>(material);
if ((lambert || checkerboard) && refl_materials["-DLAMBERT"] == nullptr)
{
refl_materials["-DLAMBERT"] = &_lambert;
}
auto phong = dynamic_cast<mrf::materials::LPhysicalPhong *>(material);
auto phongTextured = dynamic_cast<mrf::materials::LPhysicalPhongTextured *>(material);
if ((phong || phongTextured) && refl_materials["-DPHONG"] == nullptr)
{
refl_materials["-DPHONG"] = &_phong;
}
mrf::materials::PrincipledDisney *principled = dynamic_cast<mrf::materials::PrincipledDisney *>(material);
auto principled = dynamic_cast<mrf::materials::PrincipledDisney *>(material);
if (principled && refl_materials["-DPRINCIPLED"] == nullptr)
{
refl_materials["-DPRINCIPLED"] = &_principled;
}
mrf::materials::MeasuredIsotropic *measured = dynamic_cast<mrf::materials::MeasuredIsotropic *>(material);
auto measured = dynamic_cast<mrf::materials::MeasuredIsotropic *>(material);
if (measured && refl_materials["-DMEASURED_ISOTROPIC_REFL"] == nullptr)
{
refl_materials["-DMEASURED_ISOTROPIC_REFL"] = &_measured_isotropic;
......
......@@ -44,7 +44,8 @@ public:
void releaseMemory();
void createMaterials(std::vector<std::string> const &cuda_compile_options);
optix::Material getMaterialFromMRF(unsigned int index);
//optix::Material getMaterialFromMRF(unsigned int index);
std::vector<optix::Material> getMaterialFromMRF(unsigned int index) const;
#ifdef MRF_RENDERING_MODE_SPECTRAL
/**
......
......@@ -10,6 +10,7 @@
#include <mrf_core/materials/umat.hpp>
#include <mrf_core/materials/brdf_types.hpp>
#include <mrf_core/materials/brdf.hpp>
#include <mrf_core/materials/lambert.hpp>
#include <mrf_core/materials/l_phong.hpp>
#include <mrf_core/materials/l_phong_textured.hpp>
......
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