Une MAJ de sécurité est nécessaire sur notre version actuelle. Elle sera effectuée lundi 02/08 entre 12h30 et 13h. L'interruption de service devrait durer quelques minutes (probablement moins de 5 minutes).

Commit 515e040f authored by MURRAY David's avatar MURRAY David
Browse files

testing full rework of optix material handling

parent 354f160d
......@@ -96,7 +96,7 @@ void OptixGeometryHandler::importMrfScene(
_optix_analytical_shapes.push_back(std::make_pair(gi, mat_index));
// ADD MATERIAL Dummy material for now
gi->addMaterial(material_handler.lambert());
gi->addMaterial(material_handler.getMaterialFromMRF(mat_index)[0]);
//TODO UPDATE aabb ?
......@@ -172,7 +172,13 @@ void OptixGeometryHandler::importMrfScene(
{
auto gi = createParallelogram(it->corner, it->v1, it->v2);
gi->addMaterial(material_handler.diffuseEmittance());
//gi->addMaterial(material_handler.diffuseEmittance());
int light_index = std::distance(optix_lights.cbegin(), it);
auto mat = light_handler.getUMatPointerQuadLight(light_index);
//gi->addMaterial(material_handler.diffuseEmittance());
gi->addMaterial(material_handler.getMaterialFromUMat(mat));
geometry_group->addChild(gi);
light_handler.addQuadLight(gi);
......@@ -184,7 +190,12 @@ void OptixGeometryHandler::importMrfScene(
{
auto gi = createSphere(it->position, it->radius);
gi->addMaterial(material_handler.diffuseEmittance());
//gi->addMaterial(material_handler.diffuseEmittance());
int light_index = std::distance(optix_sph_lights.cbegin(), it);
auto mat = light_handler.getUMatPointerSpereLight(light_index);
gi->addMaterial(material_handler.getMaterialFromUMat(mat));
geometry_group->addChild(gi);
light_handler.addSphereLight(gi);
......@@ -329,6 +340,7 @@ void OptixGeometryHandler::loadMeshFromMRF(
}
else
{
assert(mrf_mesh.materialPerFaces().size() == mesh.num_triangles);
memcpy(
mesh.mat_indices,
&mrf_mesh.materialPerFaces()[0], mrf_mesh.materialPerFaces().size() * sizeof(uint32_t));
......
......@@ -240,7 +240,10 @@ void OptixLightHandler::updateLights(OptixMaterialHandler &material_handler)
wavelengths);
#else
auto light_color = diffuse_emittance->getColor() * radiance;
material_handler.setCustomRadianceVariables(_optix_quad_light_geometries[i], variable_values, variable_names);
/* material_handler.setCustomRadianceVariables(
_optix_quad_light_geometries[i]),
variable_values,
variable_names);*/
_optix_quad_lights[i].emission = mrfToOptix(light_color);
#endif
......@@ -333,7 +336,7 @@ void OptixLightHandler::updateLights(OptixMaterialHandler &material_handler)
wavelengths);
#else
auto light_color = diffuse_emittance->getColor() * radiance;
material_handler.setCustomRadianceVariables(_optix_sphere_light_geometries[i], variable_values, variable_names);
//material_handler.setCustomRadianceVariables(_optix_sphere_light_geometries[i], variable_values, variable_names);
_optix_sphere_lights[i].emission = mrfToOptix(light_color);
#endif
_optix_sphere_light_geometries[i]["registered_as_light"]->setInt(1);
......
......@@ -52,13 +52,15 @@ public:
std::vector<QuadLight> const & optixQuadLights() const;
std::vector<SphereLight> const &optixSphereLights() const;
mrf::materials::UMat *getUMatPointerQuadLight(int index) { return _optix_quad_light_materials[index]; }
mrf::materials::UMat *getUMatPointerSpereLight(int index) { return _optix_sphere_light_materials[index]; }
private:
void createQuadLight(mrf::lighting::Light *mrf_light);
void createSphereLight(mrf::lighting::Light *mrf_light);
void createDirectionnalLight(mrf::lighting::Light *mrf_light);
private:
optix::Context & _context; /**< Need a context to create optix buffers*/
std::vector<mrf::lighting::Light *> const &_mrf_lights; /**< Light sources from the mrf scene*/
......
......@@ -47,6 +47,15 @@ public:
//optix::Material getMaterialFromMRF(unsigned int index);
std::vector<optix::Material> getMaterialFromMRF(unsigned int index) const;
optix::Material getMaterialFromUMat(mrf::materials::UMat *material) const { return _materials.at(material); }
//optix::Material & getMaterialFromUMat(mrf::materials::UMat *material) { return _materials.at(material); }
optix::Material createMaterialFromMRF(mrf::materials::UMat *material, std::vector<std::string> const &cuda_compile_options);
void compileBRDF(optix::Material &mat, std::vector<std::string> const &cuda_compile_options);
void compileBTDF(optix::Material &mat, std::vector<std::string> const &cuda_compile_options);
void compileEmittance(optix::Material &mat, std::vector<std::string> const &cuda_compile_options);
#ifdef MRF_RENDERING_MODE_SPECTRAL
/**
* Update all the Optix texture that holds the data of the PhongTextured materials
......@@ -82,39 +91,39 @@ public:
std::vector<mrf::materials::RADIANCE_TYPE> const &radiances,
std::vector<uint> const & wavelengths);
void setCustomRadianceVariables(
optix::GeometryInstance & optix_mesh,
optix::Material & optix_mat,
mrf::materials::UMat * material,
std::vector<mrf::materials::RADIANCE_TYPE> const &radiance_values,
std::vector<std::string> const & variable_names,
std::vector<uint> const & wavelengths);
#else
void setCustomRadianceVariables(
optix::GeometryInstance & optix_mesh,
optix::Material & optix_mat,
std::vector<mrf::materials::RADIANCE_TYPE> const &radiance_values,
std::vector<std::string> const & variable_names);
#endif
const optix::Material lambert() const { return _lambert; }
optix::Material lambert() { return _lambert; }
optix::Material perfectMirror() { return _microfacet_conductor; }
optix::Material fresnelMirror() { return _microfacet_conductor; }
optix::Material fresnelGlass() { return _microfacet_dielectric; }
optix::Material fresnelThinGlass() { return _microfacet_dielectric; }
optix::Material phong() { return _phong; }
optix::Material principled() { return _principled; }
optix::Material phongTextured() { return _phong; }
optix::Material ggx() { return _microfacet_conductor; }
optix::Material walter() { return _microfacet_dielectric; }
const optix::Material diffuseEmittance() const { return _diffuse_emittance; }
optix::Material diffuseEmittance() { return _diffuse_emittance; }
optix::Material measuredIsotropic() { return _measured_isotropic; }
optix::Material shadowCatcher() { return _shadow_catcher; }
optix::Material flatBRDF() { return _debug_shader; }
optix::Material normalShader() { return _debug_shader; }
optix::Material tangentShader() { return _debug_shader; }
optix::Material uvShader() { return _debug_shader; }
//const optix::Material lambert() const { return _lambert; }
//optix::Material lambert() { return _lambert; }
//optix::Material perfectMirror() { return _microfacet_conductor; }
//optix::Material fresnelMirror() { return _microfacet_conductor; }
//optix::Material fresnelGlass() { return _microfacet_dielectric; }
//optix::Material fresnelThinGlass() { return _microfacet_dielectric; }
//optix::Material phong() { return _phong; }
//optix::Material principled() { return _principled; }
//optix::Material phongTextured() { return _phong; }
//optix::Material ggx() { return _microfacet_conductor; }
//optix::Material walter() { return _microfacet_dielectric; }
//const optix::Material diffuseEmittance() const { return _diffuse_emittance; }
//optix::Material diffuseEmittance() { return _diffuse_emittance; }
//optix::Material measuredIsotropic() { return _measured_isotropic; }
//optix::Material shadowCatcher() { return _shadow_catcher; }
//optix::Material flatBRDF() { return _debug_shader; }
//optix::Material normalShader() { return _debug_shader; }
//optix::Material tangentShader() { return _debug_shader; }
//optix::Material uvShader() { return _debug_shader; }
private:
/**
......@@ -135,18 +144,20 @@ private:
/**
* All possible materials
**/
optix::Material _lambert;
optix::Material _checkerboard;
optix::Material _phong;
optix::Material _principled;
optix::Material _microfacet_conductor;
optix::Material _microfacet_dielectric;
optix::Material _walter;
optix::Material _measured_isotropic;
optix::Material _diffuse_emittance;
optix::Material _dirac_emittance;
optix::Material _debug_shader;
optix::Material _shadow_catcher;
//std::map<mrf::materials::UMat *,optix::Material> _lamberts;
//std::map<mrf::materials::UMat *,optix::Material> _checkerboards;
//std::map<mrf::materials::UMat *,optix::Material> _phongs;
//std::map<mrf::materials::UMat *,optix::Material> _principleds;
//std::map<mrf::materials::UMat *,optix::Material> _microfacet_conductors;
//std::map<mrf::materials::UMat *,optix::Material> _microfacet_dielectrics;
//std::map<mrf::materials::UMat *,optix::Material> _walters;
//std::map<mrf::materials::UMat *,optix::Material> _measured_isotropics;
//std::map<mrf::materials::UMat *,optix::Material> _diffuse_emittances;
//std::map<mrf::materials::UMat *,optix::Material> _dirac_emittances;
//std::map<mrf::materials::UMat *,optix::Material> _debug_shaders;
//std::map<mrf::materials::UMat *,optix::Material> _shadow_catchers;
//
std::map<mrf::materials::UMat *, optix::Material> _materials;
/**
* All the non-material specific textures
......
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