提交 de901103 编写于 作者: M Matt Pharr

Ignore area lights with "interface" material.

Thus, "interface" is purely for specifying medium transitions.

Issue #112.
上级 30c5815a
......@@ -164,14 +164,21 @@ void CPURender(ParsedScene &parsedScene) {
Light area = nullptr;
if (sh.lightIndex != -1) {
CHECK_LT(sh.lightIndex, parsedScene.areaLights.size());
const auto &areaLightEntity = parsedScene.areaLights[sh.lightIndex];
area = Light::CreateArea(
areaLightEntity.name, areaLightEntity.parameters,
*sh.renderFromObject, mi, s, &areaLightEntity.loc, Allocator{});
if (area) {
std::lock_guard<std::mutex> lock(lightsMutex);
lights.push_back(area);
if (!mtl)
Warning(&sh.loc, "Ignoring area light specification for shape "
"with \"interface\" material.");
else {
const auto &areaLightEntity =
parsedScene.areaLights[sh.lightIndex];
area = Light::CreateArea(areaLightEntity.name,
areaLightEntity.parameters,
*sh.renderFromObject, mi, s,
&areaLightEntity.loc, Allocator{});
if (area) {
std::lock_guard<std::mutex> lock(lightsMutex);
lights.push_back(area);
}
}
}
if (area == nullptr && !mi.IsMediumTransition() && !alphaTex)
......
......@@ -347,12 +347,16 @@ OptixTraversableHandle GPUAccel::createGASForTriangles(
hgRecord.triRec.alphaTexture = alphaTexture;
hgRecord.triRec.areaLights = {};
if (shape.lightIndex != -1) {
// Note: this will hit if we try to have an instance as an area
// light.
auto iter = shapeIndexToAreaLights.find(shapeIndex);
CHECK(iter != shapeIndexToAreaLights.end());
CHECK_EQ(iter->second->size(), mesh->nTriangles);
hgRecord.triRec.areaLights = pstd::MakeSpan(*iter->second);
if (!material)
Warning(&shape.loc, "Ignoring area light specification for shape with \"interface\" material.");
else {
// Note: this will hit if we try to have an instance as an area
// light.
auto iter = shapeIndexToAreaLights.find(shapeIndex);
CHECK(iter != shapeIndexToAreaLights.end());
CHECK_EQ(iter->second->size(), mesh->nTriangles);
hgRecord.triRec.areaLights = pstd::MakeSpan(*iter->second);
}
}
hgRecord.triRec.mediumInterface = getMediumInterface(shape, media, alloc);
......@@ -428,12 +432,16 @@ OptixTraversableHandle GPUAccel::createGASForBLPs(
hgRecord.bilinearRec.alphaTexture = alphaTexture;
hgRecord.bilinearRec.areaLights = {};
if (shape.lightIndex != -1) {
auto iter = shapeIndexToAreaLights.find(shapeIndex);
// Note: this will hit if we try to have an instance as an area
// light.
CHECK(iter != shapeIndexToAreaLights.end());
CHECK_EQ(iter->second->size(), mesh->nPatches);
hgRecord.bilinearRec.areaLights = pstd::MakeSpan(*iter->second);
if (!material)
Warning(&shape.loc, "Ignoring area light specification for shape with \"interface\" material.");
else {
auto iter = shapeIndexToAreaLights.find(shapeIndex);
// Note: this will hit if we try to have an instance as an area
// light.
CHECK(iter != shapeIndexToAreaLights.end());
CHECK_EQ(iter->second->size(), mesh->nPatches);
hgRecord.bilinearRec.areaLights = pstd::MakeSpan(*iter->second);
}
}
hgRecord.bilinearRec.mediumInterface = getMediumInterface(shape, media, alloc);
......@@ -517,12 +525,16 @@ OptixTraversableHandle GPUAccel::createGASForQuadrics(
hgRecord.quadricRec.alphaTexture = alphaTexture;
hgRecord.quadricRec.areaLight = nullptr;
if (s.lightIndex != -1) {
auto iter = shapeIndexToAreaLights.find(shapeIndex);
// Note: this will hit if we try to have an instance as an area
// light.
CHECK(iter != shapeIndexToAreaLights.end());
CHECK_EQ(iter->second->size(), 1);
hgRecord.quadricRec.areaLight = (*iter->second)[0];
if (!material)
Warning(&s.loc, "Ignoring area light specification for shape with \"interface\" material.");
else {
auto iter = shapeIndexToAreaLights.find(shapeIndex);
// Note: this will hit if we try to have an instance as an area
// light.
CHECK(iter != shapeIndexToAreaLights.end());
CHECK_EQ(iter->second->size(), 1);
hgRecord.quadricRec.areaLight = (*iter->second)[0];
}
}
hgRecord.quadricRec.mediumInterface = getMediumInterface(s, media, alloc);
......
......@@ -120,6 +120,25 @@ GPUPathIntegrator::GPUPathIntegrator(Allocator alloc, const ParsedScene &scene)
const auto &shape = scene.shapes[i];
if (shape.lightIndex == -1)
continue;
auto isInterface = [&]() {
const SceneEntity *mtl = nullptr;
if (shape.materialIndex != -1)
mtl = &scene.materials[shape.materialIndex];
else {
for (auto iter = scene.namedMaterials.begin();
iter != scene.namedMaterials.end(); ++iter)
if (iter->first == shape.materialName) {
mtl = &iter->second;
break;
}
CHECK(mtl != nullptr);
}
return (mtl->name == "interface" || mtl->name == "none" || mtl->name.empty());
};
if (isInterface())
continue;
CHECK_LT(shape.lightIndex, scene.areaLights.size());
const auto &areaLightEntity = scene.areaLights[shape.lightIndex];
AnimatedTransform renderFromLight(*shape.renderFromObject);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册