Code Monkey home page Code Monkey logo

acceleration-structures's Introduction

Acceleration Structures

This repo contains files as part of my bachelor thesis project where two different algorithms for bounding volume hierarchy construction were evaluated. Visualised below is the traversal complexity for one of the resulting tree structures.

dragon-LBVH.mp4

Requirements

Requires a Nvidia graphics card and CUDA drivers. The program does not use any API features introduced in newer versions of CUDA, so it'll likely work even on somewhat older versions. It has however only been tested on CUDA 11.6.

Build instructions

Built on windows using:

  • MSVC (19.29)
  • CUDA (11.6)

Although will likely still work on older versions. Requires an Nvidia GPU.

    nvcc src/main.cu -Xcompiler "/O2" -o build/main

Include debugging symbols by passing the Zi flag to MSVC via the NVCC -Xcomplier argument (obviously only applicable on windows when compiling using MSVC):

    nvcc.exe -Xcompiler "/Zi" -o build/main src/main.cu

Command line arguments

    -i , --input <filepath>
        Which .obj file to use.
        Defaults to: sample_models/large_70.obj

    -o, --image-output <filepath>
        What name to save the resulting render as (ppm format).
        Defaults to: output.ppm

    -spp, --samples-per-pixel <int>
        When rendering the image, how many samples per pixels should be used.
        Defaults to: 30

    -iw, --image-width <int>
        Resulting image width.
        Defaults to: 512

    -ih, --image-height <int>
        Resulting image height.
        Defaults to: 512

    --max-depth <int>
        Specify maximum number of per ray bounces allowed during raytracing.
        Defaults to: 5

    -bvh <int>
        Specify which acceleration structure to use.
        Defaults to: 1
            0 - No acceleration structure, brute force ray triangle intersections.
            1 - Karras (2012), LBVH.
            2 - Wald (2007), SAH Binning.

    -r, --render <int>
        Whether or not to render the scene.
        Defaults to: 1
            0 - Do not render.
            1 - Render normal (lambertian diffuse).
            2 - Render BVH traversal heatmap.
    
    -x <float>, -y <float>, -z <float>
        Specify world position of the camera by supplying either x, y and/or z coordinates.
        Defaults to: 0.0

    --normalize <int>
        When rendering a heatmap, this flag allows for more control as to 
        what value the frame buffer should be normalized with regards to 
        (see section "Animations" for more info).
        Defaults to: The maximum number of steps traversed during the rendered frame.

Benchmarking

Dependencies

Requires Python >= 3.6. The algorithms can be benchmarked by running the script benchmark.py. Before running any benchmarks however, install any missing dependencies:

    python -m pip install -r requirements.txt

Running the benchmarks

The benchmarking script assumes that the binary is located at build/main.exe. The benchmarks can then be run from the projects root directory:

    python Benchmarking/benchmark.py

The default benchmarking configuration expects 6 .obj files to be present in sample_models/mcguire directory. These models can be retreived from the McGuire Computer Graphics Archive. They are the following:

  • salle_de_bain.obj
  • dragon.obj
  • sibenik.obj
  • sponza.obj
  • vokselia_spawn.obj
  • san_miguel.obj

The benchmarking script will output traversal data into the folder traversal_steps with the naming scheme traversal_frame_<frame>_<scene>-<bvh type>_<Render type>.txt or traversal_frame_99_san_miguel-LBVH_RenderType.HEATMAP.txt. The other script in the Benchmarking folder, traversal_stats.py will process these files, group them together based on scene and acceleration structure and output various statistics about the number of steps traversed, such as min, max, mean and standard deviation. This script is also meant to be ran from the root directory as such:

    python Benchmarking/traversal_stats.py

Depending on the amount of data to be processed, this can take a while and there's no indication of progress while the script is running.

Animations

Additionally, the benchmarking file can be used to create camera animations. By default the animation tool will interpolate the camera position between two positions and render out a .ppm image sequence for each frame. The image sequence will then be encoded to a h264 .mp4 file, this step requires ffmpeg to be installed and present in your PATH environment variable.

When rendering BVH traversal heatmap, you sometimes want to normalize the output image with regards to some arbitrary max value. This is useful when rendering an animation and the entire image sequence pixel values should be normalized according to the maximum steps traversed throughout the animation (as opposed to per frame normalization, which could result in flickering). When normalizing the frame buffer, a custom maximum value can be supplied to the program using the --normalize flag (see section Command line arguments).

acceleration-structures's People

Contributors

aggsel avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.