Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-add OSPRay pathtracer #766

Merged
merged 2 commits into from
Apr 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ Four renderers are currently supported:
| basic_simulation | Enhances ```basic``` with transparency and simulation rendering
| advanced_simulation | Enhances ```basic_simulation``` with reflection, refraction, volume rendering, shadows and ambient occlusion
| proximity | Displays information about element proximity in 3D space. Typically used to find touches between neurons.
| pathtracer | Path tracing renderer
| scivis | Scientific visualization example renderer provided by OSPRay


Expand Down
10 changes: 10 additions & 0 deletions engines/ospray/OSPRayEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,14 @@ void OSPRayEngine::_createRenderers()
addRendererType("raycast_Ng");
addRendererType("raycast_Ns");

{
PropertyMap properties;
properties.setProperty({"rouletteDepth", 5, 0, 20, {"Roulette depth"}});
properties.setProperty(
{"maxContribution", 100000.0, 0.0, 100000.0, {"Max contribution"}});

addRendererType("pathtracer", properties);
}
{
PropertyMap properties;
properties.setProperty(
Expand All @@ -165,6 +173,7 @@ void OSPRayEngine::_createRenderers()
{"electronShadingEnabled", false, {"Electron shading"}});
properties.setProperty(
{"surfaceShadingEnabled", true, {"Surface shading"}});

addRendererType("proximity", properties);
}
{
Expand All @@ -184,6 +193,7 @@ void OSPRayEngine::_createRenderers()
properties.setProperty(
{"oneSidedLighting", true, {"One-sided lighting"}});
properties.setProperty({"shadowsEnabled", false, {"Shadows"}});

addRendererType("scivis", properties);
}

Expand Down
6 changes: 5 additions & 1 deletion engines/ospray/OSPRayMaterial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,14 @@ void OSPRayMaterial::commit()

void OSPRayMaterial::commit(const std::string& renderer)
{
if (!isModified())
if (!isModified() && renderer == _renderer)
return;
ospRelease(_ospMaterial);
_ospMaterial = ospNewMaterial2(renderer.c_str(), "default_material");
if (!_ospMaterial)
throw std::runtime_error("Could not create material for renderer '" +
renderer + "'");
_renderer = renderer;
markModified(false); // Ensure commit recreates the ISPC object
commit();
}
Expand Down
1 change: 1 addition & 0 deletions engines/ospray/OSPRayMaterial.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class OSPRayMaterial : public Material
OSPTexture _createOSPTexture2D(Texture2DPtr texture);
OSPMaterial _ospMaterial{nullptr};
bool _isBackGroundMaterial{false};
std::string _renderer;
};
}

Expand Down
2 changes: 1 addition & 1 deletion tests/brayns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ BOOST_AUTO_TEST_CASE(defaults)
BOOST_CHECK_EQUAL(renderParams.getCurrentCamera(), "perspective");
BOOST_CHECK_EQUAL(renderParams.getCurrentRenderer(), "basic");
BOOST_CHECK_EQUAL(renderParams.getCameras().size(), 4);
BOOST_CHECK_EQUAL(renderParams.getRenderers().size(), 5);
BOOST_CHECK_EQUAL(renderParams.getRenderers().size(), 6);
BOOST_CHECK_EQUAL(renderParams.getSamplesPerPixel(), 1);
BOOST_CHECK_EQUAL(renderParams.getBackgroundColor(),
brayns::Vector3d(0, 0, 0));
Expand Down
5 changes: 3 additions & 2 deletions tests/myPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <brayns/pluginapi/PluginAPI.h>

#include "BasicRenderer_ispc.h"
#include <engines/ospray/ispc/render/DefaultMaterial.h>
#include <engines/ospray/ispc/render/utils/AbstractRenderer.h>

#include <boost/test/unit_test.hpp>
Expand Down Expand Up @@ -62,8 +63,7 @@ class MyPlugin : public brayns::ExtensionPlugin
brayns::RpcParameterDescription{"notify-param",
"A notification with property map",
"param", "a beautiful input param"},
input,
[&](const brayns::PropertyMap& prop) {
input, [&](const brayns::PropertyMap& prop) {
if (prop.hasProperty("value"))
BOOST_CHECK_EQUAL(prop.getProperty<int>("value"), 42);
else
Expand Down Expand Up @@ -142,6 +142,7 @@ class MyRenderer : public brayns::AbstractRenderer
};

OSP_REGISTER_RENDERER(MyRenderer, myrenderer);
OSP_REGISTER_MATERIAL(myrenderer, brayns::DefaultMaterial, default_material);

extern "C" brayns::ExtensionPlugin* brayns_plugin_create(int argc,
const char** argv)
Expand Down