GithubHelp home page GithubHelp logo

remorses / binary-greedy-meshing Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cgerikj/binary-greedy-meshing

0.0 2.0 0.0 5.73 MB

Demo: https://www.youtube.com/watch?v=LxfDmF0HxSg

License: MIT License

CMake 0.57% C++ 9.69% GLSL 0.37% C 89.37%

binary-greedy-meshing's Introduction

Binary Greedy Meshing

Fast voxel meshing algorithm - creates 'greedy' meshes with support for voxel types, baked light & Ambient Occlusion. UVs can easily be added but the vertex structure would have to be changed from a single integer.

Setup example (Visual Studio)

> git clone https://github.com/cgerikj/binary-greedy-meshing --recursive
> cd binary-greedy-meshing
> mkdir build && cd build
> cmake .. -G "Visual Studio 16 2019"
> start binaryMesher.sln

Program usage

  • Noclip: WASD
  • Toggle wireframe: X
  • Regenerate: Spacebar
  • Cycle mesh type: Tab

Meshing duration is printed to the console.

Algorithm usage

The mesher lives in src/mesher.h

Input data:

  • std::vector<uint8_t> voxels (values 0-31 usable)
  • std::vector<uint8_t> light (values 0-15 usable)

The input data includes duplicate edge data from neighboring chunks which is used for visibility culling and AO. Input data is ordered in YXZ and is 64^3 which results in a 62^3 mesh.

Output data:

  • std::vector<uint32_t> of vertices in chunk-space.

Mesh details

Vertex data is packed into one unsigned integer:

  • x, y, z: 6 bit each (0-63)
  • Type: 5 bit (0-31)
  • Light: 4 bit (0-15)
  • Normal: 3 bit (0-5)
  • AO: 2 bit

Meshes can be offset to world space using a per-draw uniform or by packing xyz in gl_BaseInstance if rendering with glMultiDrawArraysIndirect.

Screenshots

Mesh Wireframe

Benchmarks

Average execution time running on Ryzen 3800x.

Scene Milliseconds Vertices
3d hills 1.139 46798
Red sphere 1.108 71532
White noise 33.315 2142608
3d checkerboard 36.832 4289904
Empty 0.174 0

binary-greedy-meshing's People

Contributors

cgerikj avatar mgerhardy avatar

Watchers

 avatar  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.