GithubHelp home page GithubHelp logo

wumo / vkg Goto Github PK

View Code? Open in Web Editor NEW
7.0 1.0 1.0 17.53 MB

Vulkan Graphics Engine

License: MIT License

CMake 2.15% Python 0.37% C++ 43.77% C 52.12% GLSL 1.00% HTML 0.57% Shell 0.01%
vulkan raytracing deferred-shading cascaded-shadow-mapping atmospheric-rendering gltf cpp20

vkg's Introduction

vkg

Download

Graphics Engine on Vulkan written in C/C++ 20

  • Deferred Shading
  • Cascaded Shadow Mapping [1][2][3]
  • Atmospheric Rendering [4]
  • Ray tracing on NVIDIA RTX graphics card
  • Load glTF models.
  • Update vertices/transforms/materials/lights per frame.

sample

Other Language Bindings

Usage

Requirements:

  • python3 >= 3.7
  • git >= 2.0.0
  • gcc >= 10.0; Visual Studio 2019; clang >= 10.0
  • cmake >= 3.17
  • conan >= 1.28
  • Graphics driver that supports Vulkan 1.2.0(nvidia-450 or above)
  • RayTracing Feature requires RTX 20 series graphics card.
  1. Use conan as the package manager. Add aditional conan repo:
conan remote add bincrafters https://api.bintray.com/conan/bincrafters/public-conan
conan remote add wumo https://api.bintray.com/conan/wumo/public
  1. Add conan dependency vkg/0.0.1@wumo/stable.

  2. That is all! Build with cmake or any tool you like (and the conan supports).

Sample code:

#include "vkg/render/renderer.hpp"
#include "vkg/util/colors.hpp"
#include "vkg/render/util/panning_camera.hpp"
using namespace vkg;
auto main() -> int {
  // window and renderer setting
  WindowConfig windowConfig{.title = "Sample", .width = 1080, .height = 720};
  FeatureConfig featureConfig{.numFrames = 2, .rayTrace = true};
  Renderer app{windowConfig, featureConfig};

  // scene setting
  SceneConfig sceneConfig{
    .maxNumTransforms = 100'0000,
    .maxNumPrimitives = 100'0000,
    .maxNumMeshInstances = 100'0000,
  };
  auto &scene = app.addScene(sceneConfig);

  // atmosphere setting
  auto &sky = scene.atmosphere();
  sky.enable(true);
  sky.setSunIntensity(10);
  sky.setSunDirection({-1, -0.1, 0});

  // primitive
  auto primitives =
    scene.newPrimitives(PrimitiveBuilder().sphere({}, 1.f).newPrimitive());
  // material
  auto &mat = scene.material(scene.newMaterial(MaterialType::eBRDF));
  mat.setColorFactor({Green, 1.f}).setPbrFactor({0, 0.3, 0.4, 0});
  // primitive + material => mesh
  auto mesh = scene.newMesh(primitives[0], mat.id());
  // mesh => node
  auto node = scene.newNode(Transform{});
  scene.node(node).addMeshes({mesh});
  // node => model
  auto model = scene.newModel({node});
  // model => instance
  auto sphere = scene.newModelInstance(model);

  // scene camera setting
  auto &camera = scene.camera();
  camera.setLocation({-5.610391, 0.049703, 16.386591});
  camera.setDirection({5.610391, -0.049703, -16.386591});

  // using builtin panning camera to change view
  PanningCamera panningCamera{camera};
  // capture input
  auto &input = app.window().input();

  //render loop
  app.loop([&](uint32_t frameIdx, double elapsedMs) {
    // update camera from input
    panningCamera.update(input);

    // apply transform per frame
    auto &ins = scene.modelInstance(sphere);
    auto t = ins.transform();
    t.translation.x -= elapsedMs * 0.001;
    ins.setTransform(t);
  });

  return 0;
}

Build

Requirements:

  • python3 >= 3.7
  • git >= 2.0.0
  • gcc >= 10.0; Visual Studio 2019; clang >= 10.0
  • cmake >= 3.12
  • conan >= 1.28
  • Graphics driver that supports Vulkan 1.2.0 (nvidia-450 or above)
  • RayTracing Feature requires RTX 20 series graphics card.

Ubuntu:

Tested on Ubuntu 20.04:

$ sudo apt install -y git gcc-10 cmake ninja-build python3-pip
$ pip3 install conan

Windows:

Instal Visual Studio 2019 or using scoop to install dependencies:

# install scoop
$ Set-ExecutionPolicy RemoteSigned -scope CurrentUser
$ iex (new-object net.webclient).downloadstring('https://get.scoop.sh')
# install dependencies
$ scoop install python git gcc cmake ninja
# install conan
$ pip install conan

Add aditional conan repo:

conan remote add bincrafters https://api.bintray.com/conan/bincrafters/public-conan
conan remote add wumo https://api.bintray.com/conan/wumo/public

Build with cmake:

Runs in a proper terminal (Visual Studio Developer Command Prompt on Windows)

mkdir build && cd build
cmake ..  -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build . --config Release

TODO

  • Ray Cone texture lod [5]
  • Weighted, Blended Order-Independent Transparency [6][7]
  • Multiple Scene/View
  • Font Rendering
  • ImGUI integration
  • Custom ComputeShader/IntersectionShader Primitive
  • Occlusion Culling
  • Clear Coat
  • FrameGraph
  • Terrain Rendering
  • Ocean Rendering
  • Cloud Rendering
  • Virtual Texture (Sparse Residency)

References

[1] Cascaded Shadow Maps by lwjglgamdev

[2] Cascaded Shadow Maps by Microsoft

[3] GPU Gems 3

[4] Precomputed Atmospheric Scattering

[5] Texture Level of Detail Strategies for Real-Time Ray Tracing

[6] Weighted Blended Order-Independent Transparency

[7] vk_order_independent_transparency

vkg's People

Contributors

wumo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

meowboy326

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.