Code Monkey home page Code Monkey logo

erhe's Introduction

Codacy Badge License: MIT

erhe

erhe is a C++ library for modern OpenGL experiments.

  • Uses direct state access (DSA)
  • Uses bindless textures (when supported by driver)
  • Uses persistently mapped buffers (can be disabled)
  • Uses multi draw indirect
  • Uses latest OpenGL and GLSL versions
  • Uses multiple threads and OpenGL contexts
  • Uses abstraction for OpenGL pipeline state a bit similar to Vulkan (see erhe::graphics)
  • Simple type safe(r) wrapper for GL API (see erhe::gl)
  • Supports Windows and Linux

erhe is evolution of RenderStack https://github.com/tksuoran/RenderStack

screenshot

Building

Dependencies

All dependencies of erhe are either included directly in src/ for small libraries, or git pulled from their repositories using CMake fetchcontent during CMake configure step.

Windows Requirements

  • C++ compiler. Visual Studio 2022 with msbuild has been tested. Ninjabuild GCC and clang may also work, and some older versions of Visual Studio.

  • Python 3

  • CMake

  • Optional: ninja from https://github.com/ninja-build/ninja/releases

Linux Requirements

  • Recent enough CMake
    • Ubuntu 22.04 and 20.04 have been tested to good
    • Ubuntu 18.04 has too old version of CMake
    • https://apt.kitware.com/ may help to get recent CMake
  • New enough C++ compiler
    • clang-10 or newer is ok
    • GCC-9 or newer are ok
    • GCC-8 or older is not currently support
  • python 3
  • packages such xorg-dev

For IDE:

  • Visual Studio Code with CMake and C++ extensions is supported
  • CLion is supported

Build steps for Visual Studio (Windows)

  • git clone https://github.com/tksuoran/erhe
  • In x64 native tools command prompt for vs 2022, cd to the erhe directory
  • scripts\configure_vs2022.bat
  • Open solution from the build directory with Visual Studio
  • Build solution, or editor executable

Build steps for CLion (Windows and Linux)

erhe has initial CLion support.

Currently, CLion does not fully support CMake presets. Enable Debug profile only. If you want to make a release build, edit settings for that profile, instead of trying to use the other CMake preset profiles.

  • Get from VCS: URL: https://github.com/tksuoran/erhe
  • Clone
  • Keep Debug CMake profile enabled, do not enable other profiles
  • Either default toolchain MinGW or Visual Studio
  • Wait for CMake configure to complete. It will say [Finished] in CMake tab
  • Build Project or Build 'editor'
  • Run editor

For IDE:

  • Visual Studio Code with CMake and C++ extensions is supported
  • CLion is supported

Build steps for Visual Studio Code (Windows and Linux)

  • git clone https://github.com/tksuoran/erhe
  • Open erhe folder in Visual Studio code
  • Execute command: CMake: Select Configure Preset
  • Execute command: CMake: Configure
  • Execute command: CMake: Build

Configuration

There are several configuration options that can be set when configuring erhe with CMake:

Option Description Recognized values
ERHE_AUDIO_LIBRARY Audio library miniaudio, none
ERHE_FONT_RASTERIZATION_LIBRARY Font rasterization library freetype, none
ERHE_GLTF_LIBRARY GLTF library cgltf, none
ERHE_GUI_LIBRARY GUI library imgui, none
ERHE_PHYSICS_LIBRARY Physics library bullet, jolt, none
ERHE_PNG_LIBRARY PNG loading library mango, none
ERHE_PROFILE_LIBRARY Profile library nvtx, superluminal, tracy, none
ERHE_RAYTRACE_LIBRARY Raytrace library embree, bvh, none
ERHE_SVG_LIBRARY SVG loading library lunasvg, none
ERHE_TEXT_LAYOUT_LIBRARY Text layout library harfbuzz, freetype, none
ERHE_WINDOW_LIBRARY Window library glfw, none
ERHE_XR_LIBRARY XR library OpenXR, none

Main purposes of these configuration options are

  • Allow faster build times by disabling features that are not used (during development)
  • Allow to choose different physics and raytrace backends

ERHE_PHYSICS_LIBRARY

The main physics backend is currently jolt. The bullet physics backend has been rotting for a while, it would require some work to get it back to working.

ERHE_RAYTRACE_LIBRARY

The main raytrace backend is currently bvh. Even the bvh backend is incomplete, causing performance issues when creating larger scenes. The embree raytrace backend has been rotting for a while, it would require some work to get it back to working.

erhe (editor) can be configured to use raytrace for mouse picking models from 3D viewports. By default, and when raytrace backend is set to none, mouse picking uses GPU rendering based, where GPU renders ID buffer (unique color per object and triangle) and the image is read back to the CPU.

ERHE_PROFILE_LIBRARY

The main profile library is Tracy.

Superluminal was briefly tested, but support for it is likely rotten.

ERHE_WINDOW_LIBRARY

Only glfw is currently supported as window library in erhe.

Disabling window library removes ability to show desktop window. Such configuration can still be useful if OpenXR is used.

ERHE_XR_LIBRARY

Only openxr is currently supported as XR library in erhe.

Disabling xr library removes ability to enable headset rendering in erhe editor.

ERHE_SVG_LIBRARY

Only lunasvg is current supported as SVG loading library in erhe. Disabling SVG library removes erhe editor scene node icons.

ERHE_PNG_LIBRARY

Disabling PNG library removes erhe window icon.

Current implementation uses mango (subset) and spng for loading PNG files.

ERHE_GLTF_LIBRARY

Disabling GLTF library removes capability to parse GLTF files in erhe editor.

ERHE_AUDIO_LIBRARY

Currently, audio library is only used with some code (VR theremin) that is currently not functional. miniaudio can be enabled, but at the moment it is best to use none.

ERHE_FONT_RASTERIZATION_LIBRARY

Currently, only freetype is supported. Disabling font rasterization library removes native text rendering in erhe. ImGui content is not affected.

ERHE_TEXT_LAYOUT_LIBRARY

Currently, only harfbuzz is supported. Freetype as text layout support is rotten but might be resurrected.

Disabling font layout library removes native text rendering in erhe. ImGui content is not affected.

erhe executables

editor

Editor is a sandbox like experimentation executable with a random set of functionality

  • Scene is (mostly) procedurally generated
  • A primitive GLTF parser can load GLTF file content
  • A primitive obj parser can load OBJ file content
  • ImGui is used extensively for user interface
  • Content can be viewed with OpenXR compatible headset (if enabled from erhe.ini)
  • Scene nodes can be manipulated with a basic translation / rotation gizmo
  • When physics backend is enabled, scene models can interact physically
  • Scene model geometries can be manipulated with operations such as Catmull-Clark
  • Scene models can be created using a brush tool (must have selected brush and material)

erhe libraries

Major libraries

erhe::geometry

erhe::geometry provides classes manipulating geometric, polygon based 3D objects.

Geometry is collection of Points, Polygons, Corners and their attributes.

Arbitrary attributes can be associated with each Point, Polygon and Corner.

These classes are designed for manipulating 3D objects, not for rendering them. See erhe::scene and erhe::scene_renderer how to render geometry objects.

Some features:

  • Catmull-Clark subdivision operation
  • Sqrt3 subdivision operation
  • Conway operators:
    • Dual
    • Ambo
    • Truncate
    • Gyro

erhe::gl

erhe::gl provides python generated low level C++ wrappers for OpenGL API.

Some features:

  • Strongly typed C++ enums
  • Optional API call logging, with enum and bitfield values shown as human readable strings
  • Queries for checking GL extension and command support
  • Helper functions to map enum values to/from zero based integers (to help with ImGui, hashing, serialization)

erhe::graphics

erhe::graphics provides classes basic 3D rendering with modern OpenGL.

Currently, erhe uses OpenGL as graphics API. The erhe::graphics builds a Vulkan-like abstraction on top of OpenGL:

  • erhe::graphics::Pipeline capsulates all relevant GL state.

erhe::imgui

erhe::imgui provides custom ImGui backend and helper classes to manage and implement ImGui Windows.

erhe::log

erhe::log provides helpers / wrappers for spdlog logging.

erhe::primitive

erhe::primitive provides classes to convert erhe::geometry::Geometry to renderable (or raytraceable) vertex and index buffers.

erhe::renderer

erhe::renderer provides classes to assist rendering generic 3D content.

  • Buffer_writer keeps track of range of graphics Buffer that is being written to.
  • Multi_buffer keeps dedicated versions of a graphics buffer for each frame in flight.
  • Line_renderer can be used to draw debug lines
  • Text_renderer can be used to draw 2D text (labels) into 3D viewport

erhe::item

erhe::item provides base object classes for "entities".

  • Item has name, source asset path, flags, unique id
  • Hierarchy extends Item by adding pointer to parent, and vector of children

erhe::scene

erhe::scene provides classes for basic 3D scene graph.

  • Node extends Item by adding 3D transformation and glTF-like attachment points for Camera, Light, Mesh
  • Camera is like glTF Camera, which can be attached to Node
  • Light is like glTF Light, which can be attached to Node
  • Mesh is like glTF Mesh (containing a number of Primitives), which can be attached to Node
  • Scene is collection of Nodes

erhe::rendergraph

erhe::rendergraph provides classes for arranging rendering passes into a graph

  • Rendergraph_node lists a number of inputs (dependencies) and outputs. A Rendergraph_node can be executed as part of Rendergraph.

  • Rendergraph is a collection of Rendergraph_nodes. Rendergraph can be executed, this will execute rendergraph nodes in order that is based on connections between nodes in the graph.

erhe::scene_renderer

erhe::scene_renderer provides classes for rendering erhe::scene content. It uses and extends functionality from erhe::renderer.

erhe::window namespace

erhe::toolkit provides windowing system abstraction, currently using GLFW3.

erhe::verify

erhe::verify provides a simple VERIFY(condition) and FATAL(format, ...) macros, which can be used in place of assert() and unrecoverable error.

erhe::physics

erhe::physics provides minimal abstraction / wrappers for Jolt / Bullet physics libraries. The Jolt physics backend is more complete. The Bullet physics backend has been rotting for some time.

erhe

SAST Tools

PVS-Studio - static analyzer for C, C++, C#, and Java code.

erhe's People

Contributors

deccer avatar tksuoran 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  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  avatar  avatar  avatar  avatar  avatar

erhe's Issues

`Node_raytrace::initialize()` does not reuse raytrace geometry

When brush instance is created, every instance has a new raytrace geometry created. This wastes resources and time.

Brush / Raytrace_primitive should maintain a raytrace geometry that can be shared with raytrace instances, so that for each brush instance only the raytrace instance needs to be created (and no per instance triangle mesh).

Weld Improvements

Do not merge points if that would cause non-manifold topology.

Check if merged points have corners in same polygon, remove corner from polygon if necessary. Remove polygons that have zero(?) corners

Implement Viewport Toolbar

Viewport Toolbar currently contains only camera combo.
Move there also:

  • translate/rotate
  • local/world
  • snap

Key input event bindings mishandle modifier mask

Currently all key input event bindings for key press and release require exact modifier mask match, otherwise the event will be disregarded. This can cause fly camera controls to get stuck to be pressed if key was released for example while shift was down.

issue with mango

I'm sorry I didn't say a word. I try to compile the newest main branch but I have issue.

In file included from /home/daniel/CLionProjects/erhe/src/erhe/application/rendergraph/rendergraph_node.cpp:6:
/home/daniel/CLionProjects/erhe/src/mango/include/mango/math/vector256_int8x32.hpp:7:10: fatal error: mango/math/vector.hpp: No such file or directory
7 | #include <mango/math/vector.hpp>
| ^~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [src/erhe/application/CMakeFiles/erhe_application.dir/build.make:356: src/erhe/application/CMakeFiles/erhe_application.dir/rendergraph/rendergraph_node.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1611: src/erhe/application/CMakeFiles/erhe_application.dir/all] Error 2
make: *** [Makefile:156: all] Error 2

Use threads for physics

Currently physics simulation updates are done in the main thread.
Physics updates should use threads.

Implement Node TRS transform

Currently Node transform is stored directly in a matrix.

It should be possible to have a Node which stored transform with glTF compatible manner supporting separate translation, rotation and scale, enabling later glTF animations as well (that would be a separate task).

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.