Commit 435fcdc8 authored by MURRAY David's avatar MURRAY David
Browse files

execute with multi_mat and texture, need check

parent bd80d0a6
......@@ -142,6 +142,7 @@ void OptixGeometryHandler::importMrfScene(
optix_mesh.bounds = _context->createProgramFromPTXString(ptx, "mesh_bounds");
//TODO !!! CHECK IF TEXTURED
loadMeshFromMRF(*mrf_mesh, optix_mesh, transform, optix_materials);
geometry_group->addChild(optix_mesh.geom_instance);
}
......
......@@ -424,6 +424,12 @@ optix::Material OptixMaterialHandler::createMaterialFromMRF(
optix_mat["_ks"]->setFloat(phong_textured->specularAlbedo());
optix_mat["_texture_repeat"]->setFloat(float(phong_textured->textureRepeat()));
#ifdef MRF_RENDERING_MODE_SPECTRAL
updateTexturesPhong(phong_textured, wavelengths);
#else
updateTexturesPhong(phong_textured);
#endif
auto it = _phong_diffuse_textures.find(material);
if (it != _phong_diffuse_textures.end())
{
......@@ -580,6 +586,12 @@ optix::Material OptixMaterialHandler::createMaterialFromMRF(
compile_options.push_back("-DUTIA");
optix_mat["_material_tex_id"]->setInt(-1);
#ifdef MRF_RENDERING_MODE_SPECTRAL
updateTextureUTIA(utia, wavelengths);
#else
updateTextureUTIA(utia);
#endif
auto &id_buffer = _utia_maps_indexes[material];
optix_mat["_utia_tex_ids"]->set(id_buffer);
......@@ -1193,7 +1205,7 @@ void OptixMaterialHandler::updateMaterialIndex(mrf::materials::MultiMaterial *mu
auto it = _mat_index_maps.find(multi_mat);
if (it == _mat_index_maps.end())
{
tex_sampler = mrf::optix_backend::createOptixTexture(
tex_sampler = mrf::optix_backend::createClampedOptixTexture(
_context,
RT_FORMAT_FLOAT4,
multi_mat->getIndexMap().width(),
......@@ -1724,8 +1736,11 @@ void OptixMaterialHandler::applyMaterial(/*OptiXMesh &optix_mesh,*/
geom_instance["index_tex_id"]->setInt(-1);
}
}
else { mrf_indices.push_back(material_index); }
geom_instance["index_tex_id"]->setInt(-1);
else
{
mrf_indices.push_back(material_index);
}
geom_instance["index_tex_id"]->setInt(-1);
for (unsigned int i = 0; i < mrf_indices.size(); ++i)
......
......@@ -45,6 +45,8 @@ rtBuffer<float3> tangent_buffer;
rtBuffer<int3> index_buffer;
rtBuffer<uint> material_buffer;
rtDeclareVariable(int, index_tex_id, , );
rtDeclareVariable(float3, tangent, attribute tangent, );
rtDeclareVariable(float3, bitangent, attribute bitangent, );
rtDeclareVariable(float3, texcoord, attribute texcoord, );
......@@ -134,8 +136,13 @@ static __device__ void meshIntersect(int primIdx)
back_hit_point = ray.origin + (t - 0.00001f) * ray.direction;
front_hit_point = back_hit_point;
}
rtReportIntersection(material_buffer[primIdx]);
uint index = material_buffer[primIdx];
if(index_tex_id > -1 && texcoord_buffer.size() == 0)
{
index = optix::rtTex2D<float>(index_tex_id, texcoord.x, texcoord.y);
}
rtReportIntersection(index);
}
}
}
......
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