From 36fce755f7b2c77ceec2bd3fe7a85bda9dd7e2dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20G=C3=BCnther?= Date: Mon, 14 Sep 2020 15:33:12 +0200 Subject: [PATCH 01/44] Bump version --- README.md | 10 +++++----- cmake/ospray_version.cmake | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 731aa8ade1..522e6ee38a 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ OSPRay ====== -This is release v2.3.0 of Intel® OSPRay. For changes and new features -see the [changelog](CHANGELOG.md). Visit http://www.ospray.org for more -information. +This is release v2.4.0 (devel) of Intel® OSPRay. For changes and new +features see the [changelog](CHANGELOG.md). Visit http://www.ospray.org +for more information. OSPRay Overview =============== @@ -334,9 +334,9 @@ Documentation ============= The following [API -documentation](http://www.sdvis.org/ospray/download/OSPRay_readme.pdf "OSPRay Documentation") +documentation](http://www.sdvis.org/ospray/download/OSPRay_readme_devel.pdf "OSPRay Documentation") of OSPRay can also be found as a [pdf -document](http://www.sdvis.org/ospray/download/OSPRay_readme.pdf "OSPRay Documentation"). +document](http://www.sdvis.org/ospray/download/OSPRay_readme_devel.pdf "OSPRay Documentation"). For a deeper explanation of the concepts, design, features and performance of OSPRay also have a look at the IEEE Vis 2016 paper diff --git a/cmake/ospray_version.cmake b/cmake/ospray_version.cmake index 072297fe80..8d6279f0f6 100644 --- a/cmake/ospray_version.cmake +++ b/cmake/ospray_version.cmake @@ -2,7 +2,7 @@ ## SPDX-License-Identifier: Apache-2.0 set(OSPRAY_VERSION_MAJOR 2) -set(OSPRAY_VERSION_MINOR 3) +set(OSPRAY_VERSION_MINOR 4) set(OSPRAY_VERSION_PATCH 0) set(OSPRAY_SOVERSION 2) set(OSPRAY_VERSION_GITHASH 0) From 91f94754dc4f75c4a2671f69d10e07e2ee7c8bcf Mon Sep 17 00:00:00 2001 From: Carson Brownlee Date: Mon, 14 Sep 2020 05:09:45 -0700 Subject: [PATCH 02/44] correcting ns direction for gradient shading --- ospray/render/scivis/volumes.ispc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ospray/render/scivis/volumes.ispc b/ospray/render/scivis/volumes.ispc index 16ec921953..eef8378cdd 100644 --- a/ospray/render/scivis/volumes.ispc +++ b/ospray/render/scivis/volumes.ispc @@ -89,7 +89,7 @@ static void sampleVolume( // compute gradient shading lighting if (gsc > 0.0f) { - vec3f ns = Volume_getGradient(m->volume, p); + vec3f ns = Volume_getGradient(m->volume, p) * -1.f; if (dot(ns, ns) > 1e-6f) { ns = normalize(ns); From 1c90fc431cb33b813d61fe4739c2e7bd41ac5611 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20G=C3=BCnther?= Date: Wed, 16 Sep 2020 03:50:51 +0200 Subject: [PATCH 03/44] Clarify flipping of gradient --- ospray/render/scivis/volumes.ispc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ospray/render/scivis/volumes.ispc b/ospray/render/scivis/volumes.ispc index eef8378cdd..f808568036 100644 --- a/ospray/render/scivis/volumes.ispc +++ b/ospray/render/scivis/volumes.ispc @@ -89,9 +89,12 @@ static void sampleVolume( // compute gradient shading lighting if (gsc > 0.0f) { - vec3f ns = Volume_getGradient(m->volume, p) * -1.f; + vec3f ns = Volume_getGradient(m->volume, p); if (dot(ns, ns) > 1e-6f) { - ns = normalize(ns); + // assume that opacity directly correlates to volume scalar field, i.e. + // that "outside" has lower values; because the gradient point towards + // increasing values we need to flip it + ns = neg(normalize(ns)); // use scivis shading function // Prepare differential geometry structure From 7f017b33164a3d6f96bd722340626030e6e37515 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20G=C3=BCnther?= Date: Wed, 16 Sep 2020 03:51:09 +0200 Subject: [PATCH 04/44] Formatting --- ospray/render/scivis/SciVis.ih | 8 ++++---- ospray/render/scivis/lightAlpha.ispc | 2 +- ospray/render/scivis/surfaces.ih | 1 - ospray/render/scivis/volumes.ih | 3 +-- ospray/render/scivis/volumes.ispc | 24 +++++++++++++----------- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/ospray/render/scivis/SciVis.ih b/ospray/render/scivis/SciVis.ih index fbd8046b7a..2d1c25bbdb 100644 --- a/ospray/render/scivis/SciVis.ih +++ b/ospray/render/scivis/SciVis.ih @@ -4,8 +4,8 @@ #pragma once #include "common/World.ih" -#include "render/Renderer.ih" #include "math/random.ih" +#include "render/Renderer.ih" struct SciVis { @@ -18,9 +18,9 @@ struct SciVis struct SciVisRenderContext { - const SciVis* uniform renderer; - const FrameBuffer* uniform fb; - const World* uniform world; + const SciVis *uniform renderer; + const FrameBuffer *uniform fb; + const World *uniform world; ScreenSample sample; varying LDSampler *uniform ldSampler; }; diff --git a/ospray/render/scivis/lightAlpha.ispc b/ospray/render/scivis/lightAlpha.ispc index a87c431ddc..5e088d11b3 100644 --- a/ospray/render/scivis/lightAlpha.ispc +++ b/ospray/render/scivis/lightAlpha.ispc @@ -48,7 +48,7 @@ float lightAlpha(const uniform SciVis *uniform self, rc.sample = sample; rc.ldSampler = ldSampler; vec4f volumeColor = integrateVolumeIntervalsGradient(rc, - volumeIntervals, + volumeIntervals, rayIntervals, volumeRay, ldSampler, diff --git a/ospray/render/scivis/surfaces.ih b/ospray/render/scivis/surfaces.ih index 6e6ff350ed..b590495810 100644 --- a/ospray/render/scivis/surfaces.ih +++ b/ospray/render/scivis/surfaces.ih @@ -71,4 +71,3 @@ inline SciVisBSDF evalMaterial(const DifferentialGeometry &dg) return res; } - diff --git a/ospray/render/scivis/volumes.ih b/ospray/render/scivis/volumes.ih index f0c9706ce0..26e69f9746 100644 --- a/ospray/render/scivis/volumes.ih +++ b/ospray/render/scivis/volumes.ih @@ -12,8 +12,7 @@ struct LDSampler; struct RandomSampler; -vec4f integrateVolumeIntervalsGradient( - SciVisRenderContext & rc, +vec4f integrateVolumeIntervalsGradient(SciVisRenderContext &rc, const VolumeIntervals &intervals, const RayIntervals &rayIntervals, Ray &ray, diff --git a/ospray/render/scivis/volumes.ispc b/ospray/render/scivis/volumes.ispc index f808568036..bf6a6d2abb 100644 --- a/ospray/render/scivis/volumes.ispc +++ b/ospray/render/scivis/volumes.ispc @@ -25,8 +25,7 @@ struct VolumeContext uint32 ready; // 1 if sample is ready to be used }; -static void sampleVolume( - SciVisRenderContext & rc, +static void sampleVolume(SciVisRenderContext &rc, VolumeContext &vc, VolumetricModel *uniform m, const uniform float samplingRate, @@ -104,8 +103,14 @@ static void sampleVolume( dg.Ns = dg.Ng = ns; dg.P = p; dg.epsilon = dt / 2.f; - SSI shading = computeShading( - rc.renderer, rc.fb, rc.world, dg, rc.sample, rc.ldSampler, vc.dir, 0.f); + SSI shading = computeShading(rc.renderer, + rc.fb, + rc.world, + dg, + rc.sample, + rc.ldSampler, + vc.dir, + 0.f); vc.sample = lerp(gsc, vc.sample, shading.shadedColor); } } @@ -114,8 +119,7 @@ static void sampleVolume( vc.sample.w = 1.f - exp(-vc.sample.w * dt * m->densityScale); } -static float sampleAllVolumes( - SciVisRenderContext & rc, +static float sampleAllVolumes(SciVisRenderContext &rc, const VolumeIntervals &volumeIntervals, varying VolumeContext *uniform volumeContexts, const uniform float samplingRate, @@ -135,8 +139,7 @@ static float sampleAllVolumes( if (vc.ready == 0) { const VolumeInterval &vi = volumeIntervals.intervals[i]; foreach_unique (m in vi.volumetricModel) { - sampleVolume( - rc, vc, m, samplingRate, shade); + sampleVolume(rc, vc, m, samplingRate, shade); } vc.ready = 1; } @@ -158,8 +161,7 @@ static float sampleAllVolumes( return minDist; } -vec4f integrateVolumeIntervalsGradient( - SciVisRenderContext & rc, +vec4f integrateVolumeIntervalsGradient(SciVisRenderContext &rc, const VolumeIntervals &volumeIntervals, const RayIntervals &rayIntervals, Ray &ray, @@ -263,7 +265,7 @@ vec4f integrateVolumeIntervalsGradient( // Alpha blend sampled color color = color + ((1.f - alpha) * sampledColorOpacity.w - * make_vec3f(sampledColorOpacity)); + * make_vec3f(sampledColorOpacity)); alpha = alpha + ((1.f - alpha) * sampledColorOpacity.w); } } From 9cd3e1e8ad2588aa2898422e6a6d14e8cbc3ac65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20G=C3=BCnther?= Date: Wed, 16 Sep 2020 05:11:44 +0200 Subject: [PATCH 05/44] Fix gradient shading to happen in world coordinates --- ospray/render/scivis/volumes.ispc | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/ospray/render/scivis/volumes.ispc b/ospray/render/scivis/volumes.ispc index bf6a6d2abb..fbee293f35 100644 --- a/ospray/render/scivis/volumes.ispc +++ b/ospray/render/scivis/volumes.ispc @@ -28,6 +28,8 @@ struct VolumeContext static void sampleVolume(SciVisRenderContext &rc, VolumeContext &vc, VolumetricModel *uniform m, + Ray &ray, + const VolumeInterval &vi, const uniform float samplingRate, const uniform bool shade) { @@ -35,7 +37,7 @@ static void sampleVolume(SciVisRenderContext &rc, float dt; float sampleVal = nan; const uniform float gsc = shade ? m->gradientShadingScale : 0.f; - vec3f p; + vec3f p; // in volume local coords while (isnan(sampleVal)) { // Iterate till sampling position is within interval float emptySpace = 0.f; @@ -93,23 +95,24 @@ static void sampleVolume(SciVisRenderContext &rc, // assume that opacity directly correlates to volume scalar field, i.e. // that "outside" has lower values; because the gradient point towards // increasing values we need to flip it - ns = neg(normalize(ns)); + ns = neg(ns); // use scivis shading function // Prepare differential geometry structure DifferentialGeometry dg; dg.color = vc.sample; dg.material = NULL; - dg.Ns = dg.Ng = ns; - dg.P = p; dg.epsilon = dt / 2.f; + // transform to world coords + dg.Ns = dg.Ng = normalize(xfmVector(transposed(vi.xfm.l), ns)); + dg.P = ray.org + vc.distance * ray.dir; SSI shading = computeShading(rc.renderer, rc.fb, rc.world, dg, rc.sample, rc.ldSampler, - vc.dir, + ray.dir, 0.f); vc.sample = lerp(gsc, vc.sample, shading.shadedColor); } @@ -122,6 +125,7 @@ static void sampleVolume(SciVisRenderContext &rc, static float sampleAllVolumes(SciVisRenderContext &rc, const VolumeIntervals &volumeIntervals, varying VolumeContext *uniform volumeContexts, + Ray &ray, const uniform float samplingRate, vec4f &sampledColor, const uniform bool shade) @@ -139,7 +143,7 @@ static float sampleAllVolumes(SciVisRenderContext &rc, if (vc.ready == 0) { const VolumeInterval &vi = volumeIntervals.intervals[i]; foreach_unique (m in vi.volumetricModel) { - sampleVolume(rc, vc, m, samplingRate, shade); + sampleVolume(rc, vc, m, ray, vi, samplingRate, shade); } vc.ready = 1; } @@ -254,6 +258,7 @@ vec4f integrateVolumeIntervalsGradient(SciVisRenderContext &rc, float dist = sampleAllVolumes(rc, volumeIntervals, volumeContexts, + ray, samplingRate, sampledColorOpacity, shade); From 47e1ca5993f9bd72eabb2ea3d8c4a9f518a9ebd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20G=C3=BCnther?= Date: Thu, 17 Sep 2020 12:30:28 +0200 Subject: [PATCH 06/44] Fix boxes_lit test --- apps/common/ospray_testing/builders/Boxes.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/common/ospray_testing/builders/Boxes.cpp b/apps/common/ospray_testing/builders/Boxes.cpp index d291915e83..eedf86d264 100644 --- a/apps/common/ospray_testing/builders/Boxes.cpp +++ b/apps/common/ospray_testing/builders/Boxes.cpp @@ -69,8 +69,10 @@ cpp::Group Boxes::buildGroup() const if (rendererType == "pathtracer" || rendererType == "scivis" || rendererType == "ao") { cpp::Material material(rendererType, "obj"); - material.setParam("ks", vec3f(0.3f)); - material.setParam("ns", 10.f); + if (rendererType == "pathtracer" || rendererType == "scivis") { + material.setParam("ks", vec3f(0.3f)); + material.setParam("ns", 10.f); + } material.commit(); model.setParam("material", material); } @@ -97,6 +99,7 @@ cpp::World Boxes::buildWorld() const light.commit(); cpp::Light ambient("ambient"); ambient.setParam("intensity", 0.35f); + ambient.setParam("visible", false); ambient.commit(); std::vector lights{light, ambient}; world.setParam("light", cpp::CopiedData(lights)); From 43fa5d96f834f2617cfd4283f32fece94b5f4368 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20G=C3=BCnther?= Date: Thu, 17 Sep 2020 21:57:49 +0200 Subject: [PATCH 07/44] Add transformed volume test --- .../builders/UnstructuredVolumeGen.cpp | 93 +++++++++++++++++-- apps/ospExamples/GLFWOSPRayWindow.cpp | 4 +- apps/ospTestSuite/test_geometry.cpp | 3 +- ..._TestScenesGeometry_test_scenes_27.png.md5 | 1 + ..._TestScenesGeometry_test_scenes_28.png.md5 | 1 + ..._TestScenesGeometry_test_scenes_29.png.md5 | 1 + 6 files changed, 91 insertions(+), 12 deletions(-) create mode 100644 test_image_data/baseline/FromOsprayTesting_TestScenesGeometry_test_scenes_27.png.md5 create mode 100644 test_image_data/baseline/FromOsprayTesting_TestScenesGeometry_test_scenes_28.png.md5 create mode 100644 test_image_data/baseline/FromOsprayTesting_TestScenesGeometry_test_scenes_29.png.md5 diff --git a/apps/common/ospray_testing/builders/UnstructuredVolumeGen.cpp b/apps/common/ospray_testing/builders/UnstructuredVolumeGen.cpp index 14381448e5..3466d416dc 100644 --- a/apps/common/ospray_testing/builders/UnstructuredVolumeGen.cpp +++ b/apps/common/ospray_testing/builders/UnstructuredVolumeGen.cpp @@ -138,16 +138,21 @@ namespace testing { struct UnstructuredVolumeGen : public detail::Builder { - UnstructuredVolumeGen() = default; + UnstructuredVolumeGen(bool transform = false, bool isosurface = false) + : transform(transform), isosurface(isosurface) + {} ~UnstructuredVolumeGen() override = default; void commit() override; cpp::Group buildGroup() const override; + cpp::World buildWorld() const override; private: bool showCells{false}; float densityScale{1.f}; + bool transform{false}; + bool isosurface{false}; }; // Inlined definitions //////////////////////////////////////////////////// @@ -178,8 +183,10 @@ cpp::Group UnstructuredVolumeGen::buildGroup() const vec3f i_f = static_cast(i); vec3f p = size * (i_f / (dimensions - 1) - .5f); uint32_t id = numVertices.flatten(i); - positions[id] = p; values[id] = sdf(p); + if (transform) + p.z *= 0.25f; + positions[id] = p; } // Initialize primitive arrays @@ -294,20 +301,88 @@ cpp::Group UnstructuredVolumeGen::buildGroup() const volume.setParam("hexIterative", true); volume.commit(); - cpp::VolumetricModel model(volume); - model.setParam("transferFunction", - makeTransferFunction(showCells ? vec2f{0.f, 1.f} : vec2f{-.4f, -.05f})); - model.setParam("densityScale", densityScale); - model.commit(); - cpp::Group group; - group.setParam("volume", cpp::CopiedData(model)); + + if (isosurface) { + cpp::Geometry isoGeom("isosurface"); + + std::vector isovalues = {-0.2f}; + isoGeom.setParam("isovalue", cpp::CopiedData(isovalues)); + isoGeom.setParam("volume", volume); + isoGeom.commit(); + + cpp::GeometricModel isoModel(isoGeom); + + if (rendererType == "pathtracer" || rendererType == "scivis" + || rendererType == "ao") { + cpp::Material mat(rendererType, "obj"); + mat.setParam("kd", vec3f(0.8f)); + if (rendererType == "pathtracer" || rendererType == "scivis") + mat.setParam("ks", vec3f(0.2f)); + mat.commit(); + + isoModel.setParam("material", mat); + } + + isoModel.commit(); + + group.setParam("geometry", cpp::CopiedData(isoModel)); + } else { + cpp::VolumetricModel model(volume); + model.setParam("transferFunction", + makeTransferFunction(showCells ? vec2f{0.f, 1.f} : vec2f{-.4f, -.05f})); + model.setParam("densityScale", densityScale); + model.commit(); + + group.setParam("volume", cpp::CopiedData(model)); + } + group.commit(); return group; } +cpp::World UnstructuredVolumeGen::buildWorld() const +{ + if (!transform) + return Builder::buildWorld(); + + auto group = buildGroup(); + cpp::Instance instance(group); + + AffineSpace3f xform(LinearSpace3f::rotate(vec3f(2.2f, 1.0f, -0.35f), 0.4f) + * LinearSpace3f::scale(vec3f(1.0f, 1.0f, 4.0f)), + vec3f(0.1f, -0.3, 2.f)); + instance.setParam("xfm", xform); + instance.commit(); + + std::vector inst; + inst.push_back(instance); + + cpp::Light light("distant"); + light.setParam("direction", vec3f(-0.8f, -0.6f, 0.3f)); + light.setParam("color", vec3f(0.78f, 0.551f, 0.483f)); + light.setParam("intensity", 3.14f); + light.setParam("angularDiameter", 1.f); + light.commit(); + cpp::Light ambient("ambient"); + ambient.setParam("intensity", 0.35f); + ambient.setParam("visible", false); + ambient.commit(); + std::vector lights{light, ambient}; + + cpp::World world; + world.setParam("instance", cpp::CopiedData(inst)); + world.setParam("light", cpp::CopiedData(lights)); + + return world; +} + OSP_REGISTER_TESTING_BUILDER(UnstructuredVolumeGen, unstructured_volume); +OSP_REGISTER_TESTING_BUILDER( + UnstructuredVolumeGen(true), unstructured_volume_transformed); +OSP_REGISTER_TESTING_BUILDER( + UnstructuredVolumeGen(true, true), unstructured_volume_isosurface); } // namespace testing } // namespace ospray diff --git a/apps/ospExamples/GLFWOSPRayWindow.cpp b/apps/ospExamples/GLFWOSPRayWindow.cpp index 85bb619f58..75d2575d99 100644 --- a/apps/ospExamples/GLFWOSPRayWindow.cpp +++ b/apps/ospExamples/GLFWOSPRayWindow.cpp @@ -27,8 +27,7 @@ static bool g_quitNextFrame = false; -static const std::vector g_scenes = { - "boxes_lit", +static const std::vector g_scenes = {"boxes_lit", "boxes", "cornell_box", "curves", @@ -39,6 +38,7 @@ static const std::vector g_scenes = { "streamlines", "subdivision_cube", "unstructured_volume", + "unstructured_volume_isosurface", "planes", "clip_with_spheres", "clip_with_planes", diff --git a/apps/ospTestSuite/test_geometry.cpp b/apps/ospTestSuite/test_geometry.cpp index 5a0f2613c1..b181605f2e 100644 --- a/apps/ospTestSuite/test_geometry.cpp +++ b/apps/ospTestSuite/test_geometry.cpp @@ -117,7 +117,8 @@ INSTANTIATE_TEST_SUITE_P(TestScenesGeometry, "streamlines", "subdivision_cube", "cornell_box_photometric", - "planes"), + "planes", + "unstructured_volume_isosurface"), ::testing::Values("scivis", "pathtracer", "ao"))); INSTANTIATE_TEST_SUITE_P(TestScenesClipping, diff --git a/test_image_data/baseline/FromOsprayTesting_TestScenesGeometry_test_scenes_27.png.md5 b/test_image_data/baseline/FromOsprayTesting_TestScenesGeometry_test_scenes_27.png.md5 new file mode 100644 index 0000000000..e95c567706 --- /dev/null +++ b/test_image_data/baseline/FromOsprayTesting_TestScenesGeometry_test_scenes_27.png.md5 @@ -0,0 +1 @@ +2784c3a40b4c304f2dd67a0d226de309 diff --git a/test_image_data/baseline/FromOsprayTesting_TestScenesGeometry_test_scenes_28.png.md5 b/test_image_data/baseline/FromOsprayTesting_TestScenesGeometry_test_scenes_28.png.md5 new file mode 100644 index 0000000000..ae1ce203ff --- /dev/null +++ b/test_image_data/baseline/FromOsprayTesting_TestScenesGeometry_test_scenes_28.png.md5 @@ -0,0 +1 @@ +0ee84a9176088792016e39e64ac96105 diff --git a/test_image_data/baseline/FromOsprayTesting_TestScenesGeometry_test_scenes_29.png.md5 b/test_image_data/baseline/FromOsprayTesting_TestScenesGeometry_test_scenes_29.png.md5 new file mode 100644 index 0000000000..a0002502ca --- /dev/null +++ b/test_image_data/baseline/FromOsprayTesting_TestScenesGeometry_test_scenes_29.png.md5 @@ -0,0 +1 @@ +0597b0908477057233b26fdac50f8c30 From 8be7e5dfb1d3f79309d79f718a5b76f0ef79111a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20G=C3=BCnther?= Date: Thu, 17 Sep 2020 12:44:02 +0200 Subject: [PATCH 08/44] Fix normals of (transformed) isosurfaces, closes #446 --- CHANGELOG.md | 4 ++++ ospray/geometry/Isosurfaces.ispc | 15 ++++----------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 86a1b42eac..f273533f22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ Version History --------------- +### Changes in v2.4.0: + +- Fixed normals of (transformed) isosurfaces + ### Changes in v2.3.0: - Re-add SciVis renderer features (the previous version is still diff --git a/ospray/geometry/Isosurfaces.ispc b/ospray/geometry/Isosurfaces.ispc index bf5530465e..6009cbb374 100644 --- a/ospray/geometry/Isosurfaces.ispc +++ b/ospray/geometry/Isosurfaces.ispc @@ -90,11 +90,8 @@ void Isosurfaces_intersect_kernel( ray->primID = Isosurfaces_primID(self, hit.sample); ray->t = hit.t; ray->u = hit.epsilon; // transport epsilon to postIntersect - - // NOTE(jda) - Initialize ray.Ng with something, even if it's wrong - // (better than garbage). Real normals are computed if DG_NS - // flag is specified to postIntersect() - ray->Ng = negate(ray->dir); + // transport hit point in *volume local coords* to postIntersect + ray->Ng = ray->org + ray->dir * hit.t; } } } @@ -120,13 +117,9 @@ static void Isosurfaces_postIntersect(const Geometry *uniform geometry, Isosurfaces *uniform self = (Isosurfaces * uniform) geometry; Volume *uniform volume = Isosurfaces_getVolume(self); - if (flags & DG_NS) { - dg.Ns = Volume_getGradient(volume, dg.P); - if (dot(dg.Ns, dg.Ns) < 1e-6f) - dg.Ns = neg(ray.dir); // make_vec3f(1.f,0.f,0.f); - } + if (flags & (DG_NS | DG_NG)) + dg.Ng = dg.Ns = Volume_getGradient(volume, ray.Ng /* actually local hit */); - dg.Ng = dg.Ns; // convert ray-space epsilon (in ray.u) to object-/world-space using max(dir) // instead of costly length; the error is at most sqrt(3)~1.7, quite // acceptable for eps From 19a2f2b5797912a4e74d4460079da5771c1cc135 Mon Sep 17 00:00:00 2001 From: Jefferson Amstutz Date: Thu, 17 Sep 2020 14:26:45 -0500 Subject: [PATCH 09/44] keep renderers around in ospExamples to keep UI valid on change --- apps/ospExamples/GLFWOSPRayWindow.cpp | 130 ++++++++++++++++---------- apps/ospExamples/GLFWOSPRayWindow.h | 6 +- 2 files changed, 86 insertions(+), 50 deletions(-) diff --git a/apps/ospExamples/GLFWOSPRayWindow.cpp b/apps/ospExamples/GLFWOSPRayWindow.cpp index 75d2575d99..07c09e3467 100644 --- a/apps/ospExamples/GLFWOSPRayWindow.cpp +++ b/apps/ospExamples/GLFWOSPRayWindow.cpp @@ -187,7 +187,7 @@ GLFWOSPRayWindow::GLFWOSPRayWindow(const vec2i &windowSize, bool denoiser) 1.f - mouse.y / static_cast(windowSize.y)); auto res = - w.framebuffer.pick(w.renderer, w.camera, w.world, pos.x, pos.y); + w.framebuffer.pick(*w.renderer, w.camera, w.world, pos.x, pos.y); if (res.hasHit) { std::cout << "Picked geometry [inst: " << res.instance @@ -199,6 +199,19 @@ GLFWOSPRayWindow::GLFWOSPRayWindow(const vec2i &windowSize, bool denoiser) // OSPRay setup // + // set up backplate texture + std::vector backplate; + backplate.push_back(vec4f(0.8f, 0.2f, 0.2f, 1.0f)); + backplate.push_back(vec4f(0.2f, 0.8f, 0.2f, 1.0f)); + backplate.push_back(vec4f(0.2f, 0.2f, 0.8f, 1.0f)); + backplate.push_back(vec4f(0.4f, 0.2f, 0.4f, 1.0f)); + + OSPTextureFormat texFmt = OSP_TEXTURE_RGBA32F; + backplateTex.setParam( + "data", cpp::CopiedData(backplate.data(), vec2ul(2, 2))); + backplateTex.setParam("format", OSP_INT, &texFmt); + addObjectToCommit(backplateTex.handle()); + refreshScene(true); // trigger window reshape events with current window size @@ -388,7 +401,7 @@ void GLFWOSPRayWindow::startNewOSPRayFrame() refreshFrameOperations(); updateFrameOpsNextFrame = false; } - currentFrame = framebuffer.renderFrame(renderer, camera, world); + currentFrame = framebuffer.renderFrame(*renderer, camera, world); } void GLFWOSPRayWindow::waitOnOSPRayFrame() @@ -488,8 +501,8 @@ void GLFWOSPRayWindow::buildUI() debugTypeUI_callback, nullptr, g_debugRendererTypes.size())) { - renderer.setParam("method", g_debugRendererTypes[whichDebuggerType]); - addObjectToCommit(renderer.handle()); + renderer->setParam("method", g_debugRendererTypes[whichDebuggerType]); + addObjectToCommit(renderer->handle()); } } @@ -529,31 +542,46 @@ void GLFWOSPRayWindow::buildUI() else if (pixelFilterTypeStr == "blackmanHarris") pixelFilterType = OSPPixelFilterTypes::OSP_PIXELFILTER_BLACKMAN_HARRIS; - renderer.setParam("pixelFilter", pixelFilterType); - addObjectToCommit(renderer.handle()); + rendererPT.setParam("pixelFilter", pixelFilterType); + rendererSV.setParam("pixelFilter", pixelFilterType); + rendererAO.setParam("pixelFilter", pixelFilterType); + rendererDBG.setParam("pixelFilter", pixelFilterType); + addObjectToCommit(renderer->handle()); } ImGui::Separator(); static int spp = 1; if (ImGui::SliderInt("pixelSamples", &spp, 1, 64)) { - renderer.setParam("pixelSamples", spp); - addObjectToCommit(renderer.handle()); + rendererPT.setParam("pixelSamples", spp); + rendererSV.setParam("pixelSamples", spp); + rendererAO.setParam("pixelSamples", spp); + rendererDBG.setParam("pixelSamples", spp); + addObjectToCommit(renderer->handle()); } if (ImGui::ColorEdit3("backgroundColor", bgColor)) { - renderer.setParam("backgroundColor", bgColor); - addObjectToCommit(renderer.handle()); + rendererPT.setParam("backgroundColor", bgColor); + rendererSV.setParam("backgroundColor", bgColor); + rendererAO.setParam("backgroundColor", bgColor); + rendererDBG.setParam("backgroundColor", bgColor); + addObjectToCommit(renderer->handle()); } static bool useTestTex = false; if (ImGui::Checkbox("backplate texture", &useTestTex)) { if (useTestTex) { - renderer.setParam("map_backplate", backplateTex); + rendererPT.setParam("map_backplate", backplateTex); + rendererSV.setParam("map_backplate", backplateTex); + rendererAO.setParam("map_backplate", backplateTex); + rendererDBG.setParam("map_backplate", backplateTex); } else { - renderer.removeParam("map_backplate"); + rendererPT.removeParam("map_backplate"); + rendererSV.removeParam("map_backplate"); + rendererAO.removeParam("map_backplate"); + rendererDBG.removeParam("map_backplate"); } - addObjectToCommit(renderer.handle()); + addObjectToCommit(renderer->handle()); } if (rendererType == OSPRayRendererType::PATHTRACER) { @@ -582,56 +610,56 @@ void GLFWOSPRayWindow::buildUI() } static int maxDepth = 20; if (ImGui::SliderInt("maxPathLength", &maxDepth, 1, 64)) { - renderer.setParam("maxPathLength", maxDepth); - addObjectToCommit(renderer.handle()); + renderer->setParam("maxPathLength", maxDepth); + addObjectToCommit(renderer->handle()); } static int rouletteDepth = 1; if (ImGui::SliderInt("roulettePathLength", &rouletteDepth, 1, 64)) { - renderer.setParam("roulettePathLength", rouletteDepth); - addObjectToCommit(renderer.handle()); + renderer->setParam("roulettePathLength", rouletteDepth); + addObjectToCommit(renderer->handle()); } static float minContribution = 0.001f; if (ImGui::SliderFloat("minContribution", &minContribution, 0.f, 1.f)) { - renderer.setParam("minContribution", minContribution); - addObjectToCommit(renderer.handle()); + renderer->setParam("minContribution", minContribution); + addObjectToCommit(renderer->handle()); } } else if (rendererType == OSPRayRendererType::SCIVIS) { static bool shadowsEnabled = false; if (ImGui::Checkbox("shadows", &shadowsEnabled)) { - renderer.setParam("shadows", shadowsEnabled); - addObjectToCommit(renderer.handle()); + renderer->setParam("shadows", shadowsEnabled); + addObjectToCommit(renderer->handle()); } static int aoSamples = 0; if (ImGui::SliderInt("aoSamples", &aoSamples, 0, 64)) { - renderer.setParam("aoSamples", aoSamples); - addObjectToCommit(renderer.handle()); + renderer->setParam("aoSamples", aoSamples); + addObjectToCommit(renderer->handle()); } static float samplingRate = 1.f; if (ImGui::SliderFloat("volumeSamplingRate", &samplingRate, 0.001f, 2.f)) { - renderer.setParam("volumeSamplingRate", samplingRate); - addObjectToCommit(renderer.handle()); + renderer->setParam("volumeSamplingRate", samplingRate); + addObjectToCommit(renderer->handle()); } } else if (rendererType == OSPRayRendererType::AO) { static int aoSamples = 1; if (ImGui::SliderInt("aoSamples", &aoSamples, 0, 64)) { - renderer.setParam("aoSamples", aoSamples); - addObjectToCommit(renderer.handle()); + renderer->setParam("aoSamples", aoSamples); + addObjectToCommit(renderer->handle()); } static float aoIntensity = 1.f; if (ImGui::SliderFloat("aoIntensity", &aoIntensity, 0.f, 1.f)) { - renderer.setParam("aoIntensity", aoIntensity); - addObjectToCommit(renderer.handle()); + renderer->setParam("aoIntensity", aoIntensity); + addObjectToCommit(renderer->handle()); } static float samplingRate = 1.f; if (ImGui::SliderFloat("volumeSamplingRate", &samplingRate, 0.001f, 2.f)) { - renderer.setParam("volumeSamplingRate", samplingRate); - addObjectToCommit(renderer.handle()); + renderer->setParam("volumeSamplingRate", samplingRate); + addObjectToCommit(renderer->handle()); } } @@ -655,7 +683,6 @@ void GLFWOSPRayWindow::commitOutstandingHandles() void GLFWOSPRayWindow::refreshScene(bool resetCamera) { - renderSunSky = false; auto builder = testing::newBuilder(scene); testing::setParam(builder, "rendererType", rendererTypeStr); if (scene == "curves") { @@ -668,25 +695,30 @@ void GLFWOSPRayWindow::refreshScene(bool resetCamera) world = testing::buildWorld(builder); testing::release(builder); - world.commit(); - - renderer = cpp::Renderer(rendererTypeStr); + switch (rendererType) { + case OSPRayRendererType::PATHTRACER: { + renderer = &rendererPT; + if (renderSunSky) + world.setParam("light", cpp::CopiedData(sunSky)); + break; + } + case OSPRayRendererType::SCIVIS: + renderer = &rendererSV; + break; + case OSPRayRendererType::AO: + renderer = &rendererAO; + break; + case OSPRayRendererType::DEBUGGER: + renderer = &rendererDBG; + break; + default: + throw std::runtime_error("invalid renderer chosen!"); + } // retains a set background color on renderer change - renderer.setParam("backgroundColor", bgColor); - addObjectToCommit(renderer.handle()); + renderer->setParam("backgroundColor", bgColor); + addObjectToCommit(renderer->handle()); - // set up backplate texture - std::vector backplate; - backplate.push_back(vec4f(0.8f, 0.2f, 0.2f, 1.0f)); - backplate.push_back(vec4f(0.2f, 0.8f, 0.2f, 1.0f)); - backplate.push_back(vec4f(0.2f, 0.2f, 0.8f, 1.0f)); - backplate.push_back(vec4f(0.4f, 0.2f, 0.4f, 1.0f)); - - OSPTextureFormat texFmt = OSP_TEXTURE_RGBA32F; - backplateTex.setParam( - "data", cpp::CopiedData(backplate.data(), vec2ul(2, 2))); - backplateTex.setParam("format", OSP_INT, &texFmt); - addObjectToCommit(backplateTex.handle()); + world.commit(); if (resetCamera) { // create the arcball camera model diff --git a/apps/ospExamples/GLFWOSPRayWindow.h b/apps/ospExamples/GLFWOSPRayWindow.h index 47e8bd34ea..51bcadb80f 100644 --- a/apps/ospExamples/GLFWOSPRayWindow.h +++ b/apps/ospExamples/GLFWOSPRayWindow.h @@ -72,7 +72,11 @@ class GLFWOSPRayWindow std::unique_ptr arcballCamera; // OSPRay objects managed by this class - cpp::Renderer renderer; + cpp::Renderer rendererPT{"pathtracer"}; + cpp::Renderer rendererSV{"scivis"}; + cpp::Renderer rendererAO{"ao"}; + cpp::Renderer rendererDBG{"debug"}; + cpp::Renderer *renderer{nullptr}; cpp::Camera camera{"perspective"}; cpp::World world; cpp::Light sunSky{"sunSky"}; From 43ca43975073722fa2f011f416ac8e112ec48eb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20G=C3=BCnther?= Date: Fri, 18 Sep 2020 10:42:18 +0200 Subject: [PATCH 10/44] Rename examples to tutorials, add links to code --- doc/Makefile | 10 ++++---- doc/links.md | 4 ++-- doc/readme.tex | 2 +- doc/{examples.md => tutorials.md} | 40 ++++++++++++++++++------------- doc/webtemplate.html | 4 ++-- 5 files changed, 34 insertions(+), 26 deletions(-) rename doc/{examples.md => tutorials.md} (74%) diff --git a/doc/Makefile b/doc/Makefile index c5770051a4..c1cdadfd15 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -1,8 +1,8 @@ SHELL := /bin/bash -webpages := $(addprefix www/, $(addsuffix .html, index examples documentation gallery downloads related_projects displaywall ospray2_porting_guide legal)) -process_version := $(addprefix tmp/, $(addsuffix .md, examples getting_ospray readme_head)) -tmptexfiles := $(addprefix tmp/, $(addsuffix .tex, overview changelog compilation api examples)) +webpages := $(addprefix www/, $(addsuffix .html, index tutorials documentation gallery downloads related_projects displaywall ospray2_porting_guide legal)) +process_version := $(addprefix tmp/, $(addsuffix .md, tutorials getting_ospray readme_head)) +tmptexfiles := $(addprefix tmp/, $(addsuffix .tex, overview changelog compilation api tutorials)) images_jpg := $(addprefix images/, $(addsuffix .jpg, exampleViewer $(addprefix camera_, perspective architectural stereo orthographic panoramic) $(addprefix material_, OBJ Principled CarPaint Metal Alloy Glass ThinGlass MetallicPaint Luminous) ColoredWindow)) images_png := $(addprefix images/, $(addsuffix .png, diffuse_rooms normalmap_frustum tutorial_accumulatedframe tutorial_firstframe ospExamples renderSunSky)) images_fig := spot_light spot_coords quad_light hdri_light @@ -120,7 +120,7 @@ tmp/changelog.md: filter-sectionnumbers.py ../CHANGELOG.md echo -e '\nFor the complete history of changes have a look at the [CHANGELOG](https://github.com/ospray/ospray/blob/master/CHANGELOG.md).' >> $@ www/index.html: teaser.html overview.md tmp/changelog.md -www/examples.html: examples.md +www/tutorials.html: tutorials.md www/gallery.html: gallery.md www/downloads.html: tmp/getting_ospray.md tmp/compilation_web.md www/related_projects.html: related_projects.md @@ -172,7 +172,7 @@ tmp/api.md: api.md tmp/links_local.md tmp/images_web.md tmp/compilation.md: compilation.md tmp/links_local.md $(PANDOC) $+ --indented-code-classes=sh -t markdown-fenced_code_attributes -o $@ -../README.md: tmp/readme_head.md tmp/overview.md gitter.md tmp/compilation.md tmp/documentation.md tmp/api.md tmp/examples.md +../README.md: tmp/readme_head.md tmp/overview.md gitter.md tmp/compilation.md tmp/documentation.md tmp/api.md tmp/tutorials.md $(PANDOC) --file-scope $+ -t markdown-smart+pipe_tables-simple_tables-multiline_tables-grid_tables-link_attributes | $(convert_nbsp_width) > $@ ### pdf diff --git a/doc/links.md b/doc/links.md index 1f75bcf484..85a5db03d8 100644 --- a/doc/links.md +++ b/doc/links.md @@ -20,7 +20,7 @@ [OBJ material]: documentation.html#obj-material [point light]: documentation.html#point-light-sphere-light -[example applications]: examples.html#examples -[tutorial]: examples.html#tutorial +[example applications]: tutorials.html#tutorials +[tutorial]: tutorials.html#osptutorial [report bugs]: index.html#ospray-support-and-contact diff --git a/doc/readme.tex b/doc/readme.tex index e32212f225..30ae5a4339 100644 --- a/doc/readme.tex +++ b/doc/readme.tex @@ -30,7 +30,7 @@ \input{tmp/api} \addtocontents{toc}{\protect\setcounter{tocdepth}{1}} \hypersetup{bookmarksdepth=1} -\input{tmp/examples} +\input{tmp/tutorials} \makedisclaimers diff --git a/doc/examples.md b/doc/tutorials.md similarity index 74% rename from doc/examples.md rename to doc/tutorials.md index 8df946e881..12ff9d8ec5 100644 --- a/doc/examples.md +++ b/doc/tutorials.md @@ -1,17 +1,20 @@ -Examples -======== +Tutorials +========= -Tutorial --------- +ospTutorial +----------- A minimal working example demonstrating how to use OSPRay can be found -at `apps/tutorials/ospTutorial.c`^[A C++ version that uses the C++ -convenience wrappers of OSPRay's C99 API via -`include/ospray/ospray_cpp.h` is available at -`apps/tutorials/ospTutorial.cpp`.]. +at +[`apps/tutorials/ospTutorial.c`](https://github.com/ospray/ospray/blob/master/apps/ospTutorial/ospTutorial.c)^[A +C++ version that uses the C++ convenience wrappers of OSPRay's C99 API +via +[`include/ospray/ospray_cpp.h`](https://github.com/ospray/ospray/blob/master/ospray/include/ospray/ospray_cpp.h) +is available at +[`apps/tutorials/ospTutorial.cpp`](https://github.com/ospray/ospray/blob/master/apps/ospTutorial/ospTutorial.cpp).]. An example of building `ospTutorial.c` with CMake can be found in -`apps/tutorials/ospTutorialFindospray/`. +[`apps/tutorials/ospTutorialFindospray/`](https://github.com/ospray/ospray/tree/master/apps/ospTutorial/ospTutorialFindospray). To build the tutorial on Linux, build it in a build directory with @@ -39,7 +42,8 @@ frames in the second image `accumulatedFrames.ppm`. ospExamples ----------- -Apart from tutorials, `OSPRay` comes with a C++ app called `ospExamples` +Apart from tutorials, `OSPRay` comes with a C++ app called +[`ospExamples`](https://github.com/ospray/ospray/tree/master/apps/ospExamples) which is an elaborate easy-to-use tutorial, with a single interface to try various `OSPRay` features. It is aimed at providing users with multiple simple scenes composed of basic geometry types, lights, volumes @@ -51,8 +55,10 @@ necessary to render an interactive scene. The scene is rendered on a `GLFW` window with an `imgui` GUI controls panel for the user to manipulate the scene at runtime. -The application is located in `apps/ospExamples/` directory and can be -built with CMake. It can be run from the build directory via: +The application is located in +[`apps/ospExamples/`](https://github.com/ospray/ospray/tree/master/apps/ospExamples) +directory and can be built with CMake. It can be run from the build +directory via: ``` ./ospExamples ``` @@ -64,7 +70,8 @@ The command line parameter is optional however. Different scenes can be selected from the `scenes` dropdown and each scene corresponds to an instance of a special `detail::Builder` struct. -Example builders are located in `apps/common/ospray_testing/builders/`. +Example builders are located in +[`apps/common/ospray_testing/builders/`](https://github.com/ospray/ospray/tree/master/apps/common/ospray_testing/builders). These builders provide a usage guide for the OSPRay scene hierarchy and OSPRay API in the form of `cpp` wrappers. They instantiate and manage objects for the specific scene like `cpp::Geometry`, `cpp::Volume`, @@ -116,10 +123,11 @@ unstructured_volume ### Renderer -This app comes with three [renderer] options: `scivis`, `pathtracer` and -`debug`. The app provides some common rendering controls like +This app comes with four [renderer] options: `scivis`, `pathtracer`, +`ao` and `debug`. The app provides some common rendering controls like `pixelSamples` and other more specific to the renderer type like -`aoIntensity` for `scivis` renderer. +`aoSamples` for the `scivis` and `ao` renderer or `maxPathLength` for +the `pathtracer`. The sun-sky lighting can be used in a sample scene by enabling the `renderSunSky` option of the `pathtracer` renderer. It allows the user diff --git a/doc/webtemplate.html b/doc/webtemplate.html index 63a4ab2141..f23c4332aa 100644 --- a/doc/webtemplate.html +++ b/doc/webtemplate.html @@ -2,7 +2,7 @@ - Intel OSPRay$if(select_downloads)$ Download$endif$$if(select_documentation)$ Documentation$endif$$if(select_examples)$ Examples$endif$$if(select_gallery)$ Gallery$endif$$if(select_related_projects)$ – RelatedProjects$endif$ + Intel OSPRay$if(select_downloads)$ Download$endif$$if(select_documentation)$ Documentation$endif$$if(select_tutorials)$ Tutorials$endif$$if(select_gallery)$ Gallery$endif$$if(select_related_projects)$ – RelatedProjects$endif$ $if(highlighting-css)$