Skip to content

Commit

Permalink
Merge pull request #1458 from iaomw/fallback
Browse files Browse the repository at this point in the history
Fallback material
  • Loading branch information
zhouhang95 authored Oct 10, 2023
2 parents 3c27d3a + 32f4f3f commit 02e7cae
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
30 changes: 26 additions & 4 deletions zenovis/src/optx/RenderEngineOptx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -928,8 +928,8 @@ struct RenderEngineOptx : RenderEngine, zeno::disable_copy {

tmp->mark = ShaderMaker::Mesh;
tmp->matid = "Default";
tmp->source = _light_shader_template.shadtmpl;
tmp->fallback = std::make_shared<std::string>("");
tmp->source = _default_shader_template.shadtmpl;
tmp->fallback = _default_shader_fallback;

_mesh_shader_list.push_back(tmp);
}
Expand All @@ -939,8 +939,8 @@ struct RenderEngineOptx : RenderEngine, zeno::disable_copy {

tmp->mark = ShaderMaker::Sphere;
tmp->matid = "Default";
tmp->source = _light_shader_template.shadtmpl;
tmp->fallback = std::make_shared<std::string>("");
tmp->source = _default_shader_template.shadtmpl;
tmp->fallback = _default_shader_fallback;

_sphere_shader_list.push_back(tmp);
}
Expand Down Expand Up @@ -1083,6 +1083,28 @@ struct RenderEngineOptx : RenderEngine, zeno::disable_copy {
}
}

{
auto tmp = std::make_shared<ShaderPrepared>();

tmp->mark = ShaderMaker::Mesh;
tmp->matid = "Light";
tmp->source = _light_shader_template.shadtmpl;
tmp->fallback = _default_shader_fallback;

_mesh_shader_list.push_back(tmp);
}

{
auto tmp = std::make_shared<ShaderPrepared>();

tmp->mark = ShaderMaker::Sphere;
tmp->matid = "Light";
tmp->source = _light_shader_template.shadtmpl;
tmp->fallback = _default_shader_fallback;

_sphere_shader_list.push_back(tmp);
}

std::vector<std::shared_ptr<ShaderPrepared>> allShaders{};
allShaders.reserve(_mesh_shader_list.size()+_sphere_shader_list.size()+_volume_shader_list.size());

Expand Down
9 changes: 6 additions & 3 deletions zenovis/xinxinoptix/optixPathTracer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -992,9 +992,12 @@ void buildRootIAS()
++optix_instance_idx;
OptixInstance opinstance {};

auto combinedID = std::string("Light") + ":" + std::to_string(ShaderMaker::Mesh);
auto shader_index = OptixUtil::matIDtoShaderIndex[combinedID];

opinstance.flags = OPTIX_INSTANCE_FLAG_NONE;
opinstance.instanceId = OPTIX_DEVICE_PROPERTY_LIMIT_MAX_INSTANCE_ID-1;
opinstance.sbtOffset = 0;
opinstance.sbtOffset = shader_index * RAY_TYPE_COUNT;
opinstance.visibilityMask = LightMatMask;
opinstance.traversableHandle = lightsWrapper.lightPlanesGas;
memcpy(opinstance.transform, mat3r4c, sizeof(float) * 12);
Expand All @@ -1007,12 +1010,12 @@ void buildRootIAS()
++optix_instance_idx;
OptixInstance opinstance {};

auto combinedID = std::string("Default") + ":" + std::to_string(ShaderMaker::Sphere);
auto combinedID = std::string("Light") + ":" + std::to_string(ShaderMaker::Sphere);
auto shader_index = OptixUtil::matIDtoShaderIndex[combinedID];

opinstance.flags = OPTIX_INSTANCE_FLAG_NONE;
opinstance.instanceId = OPTIX_DEVICE_PROPERTY_LIMIT_MAX_INSTANCE_ID;
opinstance.sbtOffset = shader_index * RAY_TYPE_COUNT;;
opinstance.sbtOffset = shader_index * RAY_TYPE_COUNT;
opinstance.visibilityMask = LightMatMask;
opinstance.traversableHandle = lightsWrapper.lightSpheresGas;
memcpy(opinstance.transform, mat3r4c, sizeof(float) * 12);
Expand Down

0 comments on commit 02e7cae

Please sign in to comment.