OSDVF / LookingGlassPT

Path tracing in native Looking Glass display format. Supports glTF scenes and a single area light.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Path Tracer for Looking Glass display

Multiwindow multithreaded scene rendering example.
Shoot rays through your Looking Glass.

Yet another quick school project.

Features

  • Automatic Looking Glass calibration
    • through Holoplay.js if you have Looking Glass Bridge application running and Node.js installed
    • through good old USB interface as a fallback
    • Looking Glass rendering works correctly only in full screen mode (press f)
  • Loading scenes (many supported formats through assimp but optimized for glTF format with no embedded textures)
  • Non-realtime path tracing
  • Realtime ray tracing
  • Example Cornell Box scene (cornellBox.glb)
  • Input processing on one thread and rendering on another thread (event queue synchronization may be slow, but VS profiler shows 'not that much'🙃)
  • Works even if you set display scaling different than 100% (like me)
  • Acceleration of triangle rendering by using BVH and Embree-like triangle data structure

Build

  • There aim was to make this project portable, but it was tested only on Windows 10 x64 with GTX 1050 Mobile
  • Install CMake, vcpkg and node.
  • Setup vcpkg by running
    • .\vcpkg\bootstrap-vcpkg.bat or .\vcpkg\bootstrap-vcpkg.sh in the directory where you cloned vcpkg
    • this will also print your toolchain file path something.../vcpkg.cmake
    • If you are using Visual Studio, you can also vcpkg integrate install
  • clone this repo git clone git@github.com:OSDVF/LookingGlassPT.git
  • cd LookingGlassPT
  • mkdir build && cmake -B./build -S. -DCMAKE_TOOLCHAIN_FILE=[path to vcpkg]/scripts/buildsystems/vcpkg.cmake
  • or for the Visual Studio: add CMakePresets.json. Example:
{
  "version": 3,
  "configurePresets": [
    {
      "name": "windows-base",
      "hidden": true,
      "generator": "Ninja",
      "binaryDir": "${sourceDir}/out/build/${presetName}",
      "installDir": "${sourceDir}/out/install/${presetName}",
      "cacheVariables": {
        "CMAKE_C_COMPILER": "cl.exe",
        "CMAKE_CXX_COMPILER": "cl.exe",
        "CMAKE_TOOLCHAIN_FILE": "C:/vcpkg/scripts/buildsystems/vcpkg.cmake"
      },
      "condition": {
        "type": "equals",
        "lhs": "${hostSystemName}",
        "rhs": "Windows"
      }
    }
}

Note

The executable directory (conatining LookingGlassPT.exe) will be different than the build directory (containing CMakeCache.txt, node_modules...) when building under MSBuild. It is the required to run the application with the build directory as the working directory or it will crash because of not finding required shaders (vertex.vert & fragment.frag) and calibration script (index.js).

Run

There are two windows

  • Control window for changing program settings variables (e.g. switching between flat screen and looking glass)
  • Rendering window Optional program arguments
  • d display debug console
  • flat skip initial the searching for a connected looking glass and use flat screen directly

Controls

The left window is a "control window". You can set scene parameters there.

Noteworthy scene settings

  • Scale - the program does not check the scene for correct scaling. You must set correct scaling here. For the cornellBox.glb scene the correct scaling is 10x (1 when using logarithmic scale)
  • When using Logarithmic Scale: 0 -> 1x, 1 -> 10x, 2 -> 100x, -1 -> 0.1x
  • Maximum Object Count: although this project uses BVH for triangle rendering acceleration, the complexity scales with large number of triangles. Try to reduce the object count if you have problems.
    The count of individual triangles can't be set currently.

Keyboard

The program has several interactive features which can be turned on by pressing keys when the right "rendering window" is focused.

  • i - Toggles interactive mode: W, A, S, D, Space for move, Shift for higher speed, Mouse for look around
  • l - Toggles between Looking Glass and Flat Screen mode
  • Escape - Hides the rendering window
  • p - Toggles power save mode - renders frames only when moving mouse or touching keyboard
  • f - Full screen - required when using Looking Glass as the output format
  • r - Recompile shaders - the shaders (vertex.vert, fragment.frag) are loaded from the working directory. You can edit them in the runtime and apply your changes instantly using this.
    As a fallback, shaders from the executable directory are used (if it is different than the working directory).

Screenshots

Sponza
Sponza scene(only 80 objects) running on RTX 4090
Lantern
Lantern scene running at GTX 1050 Mobile
Lantern Path Tracing
Lantern scene in path tracing mode

Cornell Box

Cornell box
Cornell box scene in path tracing mode
Cornell box on looking glass
Cornell box scene ray traced on looking glass
Cornell box on looking glass different view
Different view

Path tracing

Cornell box path tracing on looking glass
Cornell box scene path traced on looking glass (different subpixel handling not functional yet)
Cornell box path tracing on looking glass different view
Different view

Dependencies

  • C++ 20

  • System with OpenGL 4.3 and bindless texture support (ARB_bindless_texture) (find your GPU support here)

  • CMake

  • vcpkg

  • node - only for calibration via Holoplay.js

  • node modules (managed automatically by npm)

    • holoplay
    • mock-dom-resources
    • three
    • ws
  • C++ libraries (managed automatically by vcpkg)

    • glew
    • glm
    • sdl2
    • imgui
    • libusb - for calibration via USB
    • nlohmann-json - for parsing calibration data
    • tiny-process-library
    • assimp
    • stb - for loading scene textures
    • nativefiledialog - for the selection of scene file
    • boost-stacktrace - for nice debug info

Thanks to

About

Path tracing in native Looking Glass display format. Supports glTF scenes and a single area light.


Languages

Language:C++ 74.0%Language:C 14.5%Language:GLSL 9.4%Language:CMake 1.8%Language:JavaScript 0.3%