Code Monkey home page Code Monkey logo

dla_terrain's Introduction

DLA_Terrain

This code roughly follows the instructions given in the second part of this video: https://www.youtube.com/watch?v=gsJHzBTPG0Y

DLA or Diffusion Limited Aggregation (https://en.wikipedia.org/wiki/Diffusion-limited_aggregation) is combined with image processing such as convolution (https://en.wikipedia.org/wiki/Kernel_(image_processing)) specifically an aproximation of Gaussian blur to create a heightmap that resembles a mountain range.

The code is written in c++ and only depends glm because I have not yet found the time to create my own ivec2. It also depends on glew so that it is able to create an openGL texture, this code could be removed with ease though. Functions are documented in the header, here is an example code:

// Create a dla with 12x12 dimensions.
DLA dla(12);
// Add 12 pixels.
dla.AddPixels(12);
// Upscale the texture.
dla.UpscaleTexture();

// Upscale the pixel grid.
dla.Upscale();
// etc.
dla.AddPixels(24);
dla.UpscaleTexture();

dla.Upscale();
dla.AddPixels(9 * 24);
dla.UpscaleTexture();

dla.Upscale();
dla.AddPixels(9 * 9 * 24);
dla.UpscaleTexture();

// Generate an openGL tetxure from the image data.
dla.GenTexture();

dla_terrain's People

Contributors

risingleaf avatar

Watchers

 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.