Coder Social home page Coder Social logo

voxel-engine's Introduction

Voxel-Engine

A CPU based sparse voxel octree renderer.

Codacy Badge Build Status License: GPL v3

Voxel-Engine is a library that aims to render voxels, stored in a sparse octree, interactively using the CPU. It does so by combining raytracing with a hierarchical Z-buffer. For more information, please read my voxel-engine blog at http://bcmpinc.wordpress.com.

Dependencies

The Voxel-Engine requires a POSIX compliant operating system. (Thus it does not work on Microsoft Windows) Furthermore it uses the following libraries:

  • GLM: OpenGL Mathematics (mandatory)
  • SDL2 (required for the viewer)
  • SDL2_Image (for the heightmap converter)
  • libpng (allows the benchmark tool to export the images)
  • ffmpeg (allows the viewer to save a movie, note that libav likely won't work)

The Voxel-Engine itself does not use SDL_Image, but this library is used by some of the tools accompanying the program.

Compilation

The program and tools should compile by running:

mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make -j 4

Execution

After compilation, the Voxel-Engine program is executed by:

./voxel ../vxl/sign.oc2

Which opens the example sing.oc2 model in the vxl directory.

If you have ffmpeg library on your computer, then the viewer can be build with video capture support. To do this run cmake with:

cmake -DENABLE_CAPTURE=ON -DLIBAV_ROOT_DIR=/path/to/ffmpeg ..

Note that the libav library won't work here.

Tools

./build_db ../vxl/pointset.vxl ../vxl/model.oc2 [mask repeats]

Converts the vxl/pointset.vxl pointset and saves it to vxl/model.oc2 in octree format. This process contains a sorting step that reorders the points in the original pointset file. The output, vxl/model.oc2 can be loaded into the renderer by running ./voxel vxl/model.oc2.

The repeat argument can be used to create a model consisting of 2^repeats copies of the model in the X, Y and Z directions. The directions in which the model are repeated can be limited using the mask, which is a bitwise -or combination of X=4, Y=2 and Z=1. The model will not be copied into the specified directions.

./ascii2bin pointset

Converts a .vxl.txt file, which is in ASCII format into a .vxl file that is in binary format. The file pointset must reside in vxl/ and be specified without its extension. A backup is created of the original file.

./convert lidar-ascii-file

Used to convert a file in LiDaR ASCII format to a .vxl.txt file. It skips the first line which is assumed to contain the table header. This program contains some hard coded numbers which need to be tuned when converting a new file. Furthermore, this program needs to be updated to output in binary format.

./convert2 xyzrgb

Used to convert a file in x, y, z, r, g, b format to a binary .vxl file. This program contains some hard coded numbers which need to be tuned when converting a new file.

Orientation

The system uses a left-handed axis system. Upon loading the Voxel-Engine, the positive X direction is to the right, the positive Y direction is to the top and the camera is facing towards the positive Z direction.

File structures

The ASCII .vxl.txt file stores one point per line. Each line contain the (X,Y,Z) coordinate as decimal and the color as hexadecimal number. The numbers are space separated.

The binary .vxl file stores one point per 32 bytes. The structure of a point is given in pointset.h.

The binary .oc2 file stores an octree containing a model. It is a list of octree nodes, with the first one being the root. Its structure is given in octree.h.

License

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

voxel-engine's People

Contributors

bcmpinc 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

Watchers

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

voxel-engine's Issues

Build error: ‘_mm_max_epi32’ was not declared

Following the installation instructions, I get the following errors after running make:

/home/tau/foreign/voxel-engine/src/engine/octree_draw.cpp: In function ‘__m128i blend_epi32(__m128i, __m128i)’:
/home/tau/foreign/voxel-engine/src/engine/octree_draw.cpp:73:29: error: there are no arguments to ‘_mm_blend_ps’ that depend on a template parameter, so a declaration of ‘_mm_blend_ps’ must be available [-fpermissive]
   73 |     return _mm_castps_si128(_mm_blend_ps(_mm_castsi128_ps(a),_mm_castsi128_ps(b),mask));
      |                             ^~~~~~~~~~~~
/home/tau/foreign/voxel-engine/src/engine/octree_draw.cpp:73:29: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
/home/tau/foreign/voxel-engine/src/engine/octree_draw.cpp: In function ‘int extract_epi32(__m128i)’:
/home/tau/foreign/voxel-engine/src/engine/octree_draw.cpp:84:12: error: there are no arguments to ‘_mm_extract_epi32’ that depend on a template parameter, so a declaration of ‘_mm_extract_epi32’ must be available [-fpermissive]
   84 |     return _mm_extract_epi32(a, index);
      |            ^~~~~~~~~~~~~~~~~
/home/tau/foreign/voxel-engine/src/engine/octree_draw.cpp: In function ‘__m128i compute_frustum(__m128i, __m128i, __m128i)’:
/home/tau/foreign/voxel-engine/src/engine/octree_draw.cpp:99:38: error: ‘_mm_max_epi32’ was not declared in this scope; did you mean ‘_mm_max_epi16’?
   99 |     frustum = _mm_sub_epi32(frustum, _mm_max_epi32(dx, nil));
      |                                      ^~~~~~~~~~~~~
      |                                      _mm_max_epi16

... and a couple of similar ones, all relating to undeclared __mm* identifiers.

I'm using g++ (GCC) 11.1.0 on a Ryzen 5 4600H, which does support SSE4.1. Do I need to enable it with the compiler in some way?

Find SDL2.cmake sets SDL2_INCLUDE_DIR incorrectly

System config

System: Mac OSX 10.9
/Libraries/Frameworks contains SDL.framework as well as SDL2.framework

The FindSDL2.cmake sets

SDL2_INCLUDE_DIR to /Library/Frameworks/SDL.framework/headers (incorrectly)
SLD2_LIBRARY to /Library/Frameworks/SDL2.framework;-framework Cocoa (correct)

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.