Coder Social home page Coder Social logo

vertexwahn / flatlandrt Goto Github PK

View Code? Open in Web Editor NEW
72.0 5.0 2.0 60.29 MB

FlatlandRT is a 2D ray tracer visualization tool.

Home Page: https://vertexwahn.de/page/open_source/

License: Apache License 2.0

Starlark 7.33% C++ 87.49% C 0.84% Shell 1.67% CMake 0.14% POV-Ray SDL 2.27% Python 0.26%
raytracer 2d computer-graphics raytracing rendering cpp ray-tracer ray-tracing raycasting visualization

flatlandrt's Introduction

Support Ukraine Build Status

FlatlandRT

Description

FlatlandRT is a 2D ray tracer visualization tool. The following pictures were created using FlatlandRT:

From left to right: Refraction, ambient occlusion and reflection:

Refraction, ambient occlusion and reflection

Quadtree intersection of 2D triangle meshes:

Quadtree

More examples scenes can be found here. See the user manual if you want to find out how to use it.

Quick start

This project uses Bazel as a build system. The current used version is defined in .bazelversion.

Prerequisites:

The following tools should be installed:

Checkout, build, and run:

You can use Flatland by invoking the following commands:

All platforms:

git clone https://github.com/Vertexwahn/FlatlandRT # clone the repository
cd FlatlandRT # change directory to cloned repository
cd devertexwahn # switch to the location where the WORKSPACE.bazel file is located

Render a scene with Windows 10/11 x64 with Visual Studio 2019:

bazel --output_base=C:/bazel_output_base  run --config=vs2019 //flatland/cli:flatland.cli --scene_filename=C:\scenes\bunny.flatland.xml

Render a scene with Windows 10/11 x64 with Visual Studio 2022:

bazel --output_base=C:/bazel_output_base  run --config=vs2022 //flatland/cli:flatland.cli --scene_filename=C:\scenes\bunny.flatland.xml

For more hints on how to use Bazel on Windows have a look at the Bazel on Windows document.

Render a scene with Ubuntu 20.04:

bazel run --config=gcc9 //flatland/cli:flatland.cli -- --scene_filename=$(pwd)/flatland/scenes/bunny/bunny.flatland.xml

Render a scene with Ubuntu 22.04:

bazel run --config=gcc11 //flatland/cli:flatland.cli -- --scene_filename=$(pwd)/flatland/scenes/bunny/bunny.flatland.xml

Render a scene with macOS 11/12/13:

bazel run --config=macos //flatland/cli:flatland.cli -- --scene_filename=$(pwd)/flatland/scenes/bunny/bunny.flatland.xml

Building & Testing

Building and testing with Linux

Command line (bash/zsh)

# Run all tests using GCC 9.3
bazel test --config=gcc9 //...
# Build all targets uing GCC 9.3
bazel build --config=gcc9 //... 
# Run all tests using GCC 11
bazel test --config=gcc11 //...
# Build all targets uing GCC 11
bazel build --config=gcc11 //...
# Run all tests using Clang 14
bazel test --config=clang14 //...
# Build all targets uing Clang 14
bazel build --config=clang14 //...

CLion

There is a Bazel plug-in for CLion. It can be downloaded from here.

You can use the following .bazelproject file:

directories:
  .

test_sources:
  flatland/tests

derive_targets_from_directories: true

additional_languages:
  python

build_flags:
  --config=gcc11

Code coverage

Make sure that lcov is installed.

sudo apt install lcov

Go to the directory that contains the WORKSPACE.bazel file and execute:

./coverage.sh buchgr_remote_cache
xdg-open coverage_report/index.html

Address Sanitizer

There is a build config called asan that can be used for detecting memory errors.

bazel run --config=asan --compilation_mode=opt //flatland/cli:flatland.cli --  $(pwd)/flatland/scenes/sphere.flatland.xml

Clang Tidy

bazel build --config=clang-tidy //flatland/core/...

Building with Windows

Command line (Powershell)

# Build with Visual Studio C++ Compiler
bazel build --config=vs2022 //...

Using Visual Studio

Use Lavender to generate a solution and project files for Visual Studio.

python3 G:\dev\lavender\generate.py --config=vs2022  //...

Lavender is far from being perfect. It might be necessary to do some modifications to the generated solution and project files.

Development process

I made a short video where I describe how I use test driven development to implement this project: Let's Code: Using Test-driven Development to implement a ray tracer

Ray tracing 101

I have written some blog post about ray tracing that can be found here: Ray Tracing 101

License

The source code of FlatlandRT itself is under the Apache License 2.0 (see LICENSE). The license of its third-party dependencies or some third-party code fragments can and is under different license terms. See copyright notes in the next section.

Copyright notes

FlatlandRT makes use of several software libraries. Some tools and libraries were copied to this repository (see third_party folder). The corresponding licenses can be found in the third_party folder of this repository. Besides this, some source code was directly copied from other open-source software libraries or programs. This is always clearly stated as a comment in the source code of FlatlandRT. If you find any copyright or license violations or issues please let me know.

Copied source code/ideas

Build related

Third party dependencies

Artwork

The Stanford Bunny was derived from the Stanford Bunny provided from the Stanford 3D Scanning Repository (see here).

The data for the Donut, Armadillo and Stanford Bunny for the 2D triangle data was derived from https://github.com/mmacklin/sandbox.

Credits

A big thank goes to all the providers, developers, and maintainers of the aforementioned open source projects and artifacts.

flatlandrt's People

Contributors

vertexwahn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

cssteffy12

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.