Giter VIP home page Giter VIP logo

raycraft's Introduction

raycraft

There have been many Minecraft clones already, but this one is a little different. The goal of this project is to be a proof of concept implementation of a voxel building game that uses ray tracing instead of rasterization for rendering.

The sample program included shows off some of the features of the ray tracer.

Requirements

  • Linux or Windows
  • Hardware support for OpenGL 3.3

Implementation details

Although OpenCL is around these days, I found it more convenient to implement the ray tracer in a fragment shader and have it run over every pixel on the screen by drawing a full screen quad. That is because GLSL is a language much more suited for graphics programming in general.

The world is currently uploaded as a 3D texture with a single 32-bit channel for every block. Although 8 bits is more than enough to contain the data for any block, it makes dealing with memory alignment easier right now. It is unlikely that this will change any time soon.

The ray tracer finds the first coordinate inside the world as reached when following the direction of the ray and then continues stepping through the world until a non-empty block is found. It steps by doing a ray/cube intersection on the block its currently in and continues from the intersection point. This guarantees a maximum amount of iterations per pixel less than sizeX+sizeY+sizeZ where these are the dimensions of the world.

The largest difference between this rendering approach and Minecraft's rasterization approach is that the concept of building chunks doesn't exist. Modifying the world is as simple as a single glTexSubImage3D call. It is of course still preferable to not have parts of the world in memory that are too far away besides the implementation defined 3D texture dimensions limits.

Performance

The performance is reasonable, support for larger worlds will require the ray tracer to be optimized better and there are rendering artefacts that need to be fixed.

Todo

  • Fixing rendering artefacts, especially on larger worlds
  • Optimization

License

MIT

The source code comes bundled with gl3w and GLM, which are licensed as public domain and MIT respectively.

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.