better handling of scenes that don't contain any objects
parent
d40de22c32
commit
58d7c18644
|
@ -106,6 +106,4 @@
|
|||
<float name="intIOR" value="1.5"/>
|
||||
<float name="extIOR" value="1.0"/>
|
||||
</bsdf>
|
||||
|
||||
<camera type="perspective"/>
|
||||
</scene>
|
||||
|
|
|
@ -0,0 +1,111 @@
|
|||
<!-- This file defines a series of BSDF instances
|
||||
to be tested for consistency. This is done
|
||||
using the testcase 'test_chisquare' -->
|
||||
<scene>
|
||||
<!-- Test the lambertian model -->
|
||||
<bsdf type="lambertian"/>
|
||||
|
||||
<!-- Test the diffuse transmission model -->
|
||||
<bsdf type="difftrans"/>
|
||||
|
||||
<!-- Test the Phong model -->
|
||||
<bsdf type="phong">
|
||||
<float name="diffuseAmount" value="0.5"/>
|
||||
<float name="specularAmount" value="0.5"/>
|
||||
<float name="exponent" value="20"/>
|
||||
|
||||
<spectrum name="diffuseReflectance" value="1"/>
|
||||
<spectrum name="specularReflectance" value="1"/>
|
||||
</bsdf>
|
||||
|
||||
<!-- Test the anisotropic Ward model -->
|
||||
<bsdf type="ward">
|
||||
<float name="diffuseAmount" value="0.5"/>
|
||||
<float name="specularAmount" value="0.5"/>
|
||||
<float name="alphaX" value="0.1"/>
|
||||
<float name="alphaY" value="0.3"/>
|
||||
|
||||
<spectrum name="diffuseReflectance" value="1"/>
|
||||
<spectrum name="specularReflectance" value="1"/>
|
||||
</bsdf>
|
||||
|
||||
<!-- Test the two-sided BRDF adapter -->
|
||||
<bsdf type="twosided">
|
||||
<bsdf type="phong">
|
||||
<float name="diffuseAmount" value="0.5"/>
|
||||
<float name="specularAmount" value="0.5"/>
|
||||
<float name="exponent" value="20"/>
|
||||
|
||||
<spectrum name="diffuseReflectance" value="1"/>
|
||||
<spectrum name="specularReflectance" value="1"/>
|
||||
</bsdf>
|
||||
</bsdf>
|
||||
|
||||
<!-- Test the composite material adapter with
|
||||
a mix of two previously tested materials -->
|
||||
<bsdf type="composite">
|
||||
<string name="weights" value="0.4, 0.6"/>
|
||||
|
||||
<bsdf type="phong">
|
||||
<float name="diffuseAmount" value="0.5"/>
|
||||
<float name="specularAmount" value="0.5"/>
|
||||
<float name="exponent" value="20"/>
|
||||
|
||||
<spectrum name="diffuseReflectance" value="1"/>
|
||||
<spectrum name="specularReflectance" value="1"/>
|
||||
</bsdf>
|
||||
|
||||
<bsdf type="ward">
|
||||
<float name="diffuseAmount" value="0.5"/>
|
||||
<float name="specularAmount" value="0.5"/>
|
||||
<float name="alphaX" value="0.1"/>
|
||||
<float name="alphaY" value="0.3"/>
|
||||
|
||||
<spectrum name="diffuseReflectance" value="1"/>
|
||||
<spectrum name="specularReflectance" value="1"/>
|
||||
</bsdf>
|
||||
</bsdf>
|
||||
|
||||
<!-- Test the microfacet model -->
|
||||
<bsdf type="microfacet">
|
||||
<float name="diffuseAmount" value="0.5"/>
|
||||
<float name="specularAmount" value="0.5"/>
|
||||
<float name="alphaB" value="0.1"/>
|
||||
<spectrum name="diffuseReflectance" value="1"/>
|
||||
<spectrum name="specularReflectance" value="1"/>
|
||||
</bsdf>
|
||||
|
||||
<!-- Test the rough metal model -->
|
||||
<bsdf type="roughmetal">
|
||||
<float name="alphaB" value="0.1"/>
|
||||
</bsdf>
|
||||
|
||||
<!-- Test the rough glass model with the
|
||||
Beckmann microfacet distribution -->
|
||||
<bsdf type="roughglass">
|
||||
<string name="distribution" value="beckmann"/>
|
||||
<float name="alpha" value=".3"/>
|
||||
<float name="intIOR" value="1.5"/>
|
||||
<float name="extIOR" value="1.0"/>
|
||||
</bsdf>
|
||||
|
||||
<!-- Test the rough glass model with the
|
||||
GGX microfacet distribution -->
|
||||
<bsdf type="roughglass">
|
||||
<string name="distribution" value="ggx"/>
|
||||
<float name="alpha" value="0.4"/>
|
||||
<float name="intIOR" value="1.5"/>
|
||||
<float name="extIOR" value="1.0"/>
|
||||
</bsdf>
|
||||
|
||||
<!-- Test the rough glass model with the
|
||||
Phong microfacet distribution -->
|
||||
<bsdf type="roughglass">
|
||||
<string name="distribution" value="phong"/>
|
||||
<float name="alpha" value="0.3"/>
|
||||
<float name="intIOR" value="1.5"/>
|
||||
<float name="extIOR" value="1.0"/>
|
||||
</bsdf>
|
||||
|
||||
<camera type="perspective"/>
|
||||
</scene>
|
|
@ -225,26 +225,27 @@ void Scene::configure() {
|
|||
m_integrator->configure();
|
||||
}
|
||||
if (m_camera == NULL) {
|
||||
Log(EWarn, "No camera found! Adding a default camera.");
|
||||
|
||||
Properties props("perspective");
|
||||
/* Create a perspective camera with 45deg. FOV, which can see the whole scene */
|
||||
AABB aabb;
|
||||
for (size_t i=0; i<m_shapes.size(); ++i)
|
||||
aabb.expandBy(m_shapes[i]->getAABB());
|
||||
if (!aabb.isValid())
|
||||
Log(EError, "Unable to set up a default camera -- does the scene contain anything at all?");
|
||||
Point center = aabb.getCenter();
|
||||
Vector extents = aabb.getExtents();
|
||||
Float maxExtents = std::max(extents.x, extents.y);
|
||||
Float distance = maxExtents/(2.0f * std::tan(45 * .5f * M_PI/180));
|
||||
if (aabb.isValid()) {
|
||||
Log(EInfo, "No camera found! Adding a default camera.");
|
||||
Point center = aabb.getCenter();
|
||||
Vector extents = aabb.getExtents();
|
||||
Float maxExtents = std::max(extents.x, extents.y);
|
||||
Float distance = maxExtents/(2.0f * std::tan(45 * .5f * M_PI/180));
|
||||
|
||||
props.setTransform("toWorld", Transform::translate(Vector(center.x, center.y, aabb.min.z - distance)));
|
||||
props.setFloat("fov", 45.0f);
|
||||
props.setTransform("toWorld", Transform::translate(Vector(center.x, center.y, aabb.min.z - distance)));
|
||||
props.setFloat("fov", 45.0f);
|
||||
|
||||
m_camera = static_cast<Camera *> (PluginManager::getInstance()->createObject(MTS_CLASS(Camera), props));
|
||||
m_camera->configure();
|
||||
m_sampler = m_camera->getSampler();
|
||||
m_camera = static_cast<Camera *> (PluginManager::getInstance()->createObject(MTS_CLASS(Camera), props));
|
||||
m_camera->configure();
|
||||
m_sampler = m_camera->getSampler();
|
||||
} else {
|
||||
Log(EWarn, "Unable to set up a default camera -- does the scene contain anything at all?");
|
||||
}
|
||||
}
|
||||
|
||||
m_integrator->configureSampler(m_sampler);
|
||||
|
|
|
@ -350,6 +350,9 @@ int ubi_main(int argc, char **argv) {
|
|||
parser->parse(filename.file_string().c_str());
|
||||
ref<Scene> scene = handler->getScene();
|
||||
|
||||
if (scene->getCamera() == NULL)
|
||||
SLog(EError, "Scene does not contain a camera!");
|
||||
|
||||
scene->setSourceFile(filename);
|
||||
scene->setDestinationFile(destFile.length() > 0 ?
|
||||
fs::path(destFile) : (filePath / baseName));
|
||||
|
|
|
@ -98,13 +98,13 @@ void SceneLoader::run() {
|
|||
scene->initialize();
|
||||
|
||||
if (scene->getIntegrator() == NULL)
|
||||
SLog(EError, "The scene contains no integrator! Aborting..");
|
||||
SLog(EError, "Unable to load scene: no integrator found!");
|
||||
if (scene->getCamera() == NULL)
|
||||
SLog(EError, "The scene contains no camera! Aborting..");
|
||||
SLog(EError, "Unable to load scene: no camera found!");
|
||||
if (scene->getCamera()->getFilm() == NULL)
|
||||
SLog(EError, "The scene contains no film! Aborting..");
|
||||
SLog(EError, "Unable to load scene: no film found!");
|
||||
if (scene->getLuminaires().size() == 0)
|
||||
SLog(EError, "The scene contains no light sources! Aborting..");
|
||||
SLog(EError, "Unable to load scene: no light sources found!");
|
||||
|
||||
Vector2i size = scene->getFilm()->getSize();
|
||||
Camera *camera = scene->getCamera();
|
||||
|
|
Loading…
Reference in New Issue