File: quaternion_motion_blur.cpp

package info (click to toggle)
embree 4.3.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 100,656 kB
  • sloc: cpp: 228,918; xml: 40,944; ansic: 2,685; python: 812; sh: 635; makefile: 228; csh: 42
file content (72 lines) | stat: -rw-r--r-- 2,094 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Copyright 2009-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0

#include "../common/tutorial/tutorial.h"
#include "../common/tutorial/benchmark_render.h"

#if defined(EMBREE_SYCL_TUTORIAL)
#  define NAME "quaternion_motion_blur_sycl"
#  define FEATURES FEATURE_RTCORE | FEATURE_SYCL
#else
#  define NAME "quaternion_motion_blur"
#  define FEATURES FEATURE_RTCORE
#endif

namespace embree
{
  typedef void (*DrawGUI)(void);

  extern "C" {
    int g_spp = 8;
    int g_numTimeSteps = 5;
    float g_time = 0.f;
    float g_shutter_close = 1.f;
    bool g_animate = true;
    bool g_accumulate = true;
    bool g_reset = false;
    DrawGUI g_drawGUI = nullptr;
  }

  extern "C" bool g_motion_blur;

  struct Tutorial : public TutorialApplication 
  {
    Tutorial()
      : TutorialApplication(NAME,FEATURES)
    {
      registerOption("spp", [] (Ref<ParseStream> cin, const FileName& path) {
          g_spp = cin->getInt();
        }, "--spp <int>: sets number of samples per pixel");

      camera.from = Vec3fa(-30.0f,30.0f,0.0f);
      camera.to   = Vec3fa(0.0f,0.0f,0.0f);
      camera.up   = Vec3fa(1.0f,0.0f,0.0f);
      camera.fov  = 30.f;
    }

#if defined(USE_GLFW)
    
    void drawGUI() override
    {
      if (ImGui::SliderInt ("samples per pixel",  &g_spp, 1, 32))  g_reset = true;
      if (ImGui::SliderInt ("time steps",  &g_numTimeSteps, 3, 10))  g_reset = true;
      if (ImGui::Checkbox ("animate", &g_animate)) g_reset = true;
      if (ImGui::Checkbox ("motion blur", &g_motion_blur)) g_reset = true;
      if (!g_motion_blur) {
        if (ImGui::SliderFloat ("time", &g_time, 0.f, 1.f)) g_reset = true;
      } else {
        if (ImGui::SliderFloat ("shutter close", &g_shutter_close, 0.f, 1.f)) g_reset = true;
      }
      if (g_drawGUI)
        g_drawGUI();
    }
#endif
  };
}

int main(int argc, char** argv) {
  if (embree::TutorialBenchmark::benchmark(argc, argv)) {
    return embree::TutorialBenchmark(embree::renderBenchFunc<embree::Tutorial>).main(argc, argv, "quaternion_motion_blur");
  }
  return embree::Tutorial().main(argc,argv);
}