3
2012
Diamond Square Algorithm

Converted Diamond Square Algorithm / random midpoint displacement fractal from Processing (original by “Justin Seyster”) to Unity C#.
*See also related forum topic.
Release#1:
– Color32 array with SetPixels32() (instead of plotting each pixel at a time..)
– Replaced “/2” with “*0.5f” (supposed to be bit better??)
Ideas:
– Try to make some terrain height maps? Or just directly displace vertices from the function..?
– Does it work in 3D?
– Use it for drawing clouds? Minecraft map?
– What if you adjust parameters each frame, how it looks animated?
– Use as a shader? Someone has made one here, who would convert to unity..?
– Mix colors with previous layer..?
– LookUpTables?
Webplayer:
nothing to see..it just generates a texture as in screenshot..
Download source:
DiamondSquareAlgorithm1.unityPackage
Or donatebuy source:
0.5 eur [digishop id=”14″] (download link comes to your email)
Includes: Example scene, c# source
—
Image#2: texture size: 2048×2048, filtermode.Point,

—
Image#3: deep profiler report (should try to put the colors in array..instead of using single setpixels..also could try using ints? and replace divisions with multipliers?)
Small update: using array & setpixels, bit faster..
—
Image#4: greyscale..heightmaps..
—
Image#5 (Terrain with nicer colors.. the grid’ding is quite visible in larger terrains..)

Related Posts
12 Comments + Add Comment
Leave a comment
Recent posts
- Unity Editor: Tree Generator
- Leaf/Foliage Generator Tools (Runs in Browser)
- Testing Unity AI Beta
- Ways to Support UnityCoder Development
- Using UI Slider to Create 5-Star Rating Element
- Game Music Library For Unity (editor plugin)
- Fontastic : Easily Test Fonts in Unity Editor!
- GeoTiff Importer & Terrain Generator for Unity
- Create Baked DropShadow for UI images
- .JP2 Ortho Image Converter to PNG/JPG/TIFF
- Convert LAS/LAZ/PLY pointclouds to GLTF (GLB) Point Meshes (standalone converter)
- Detect SRP (URP or HDRP) with Assembly Definition Version Defines
Recent Comments
- on Sprite Sheet Flip Book Shader
- on Sprite Sheet Flip Book Shader
- on [Asset Store] PolygonCollider2D Optimizer
- on Trajectory Test Scene 2.0
- on Vector3 maths for dummies!
- on UnityHub 3.6.0: Remove Version Control & Cloud Dashboard columns
- on Using RenderDoc with Unity (graphics debugger)
- on UI Scroll View automatic Content height
Coin:
CUgDSbRqFcAumDSAcdKDvuXsw26VdkJe8C8WGUQHBAGS
An article by















This is amazing!Can’t wait for the source
Hello!How do i download it?I have installed the toolbar and have java enabled and still says that UnityCoder.com Toolbar must be installed & Javascript enabled! (and these links are personal, use the toolbar to access downloads) yada yada
^ link fixed!
I also was not able to download – after installing shitty toolbar
Chrome has problems with the downloads..
(It might work better now, link doesnt open in a new window anymore)
Sorry for calling your toolbar shitty. You are an awesome programmer. I was just frustrated.
no problems, havent yet found other solutions for offering free downloads.. (actually google ads are better than the toolbar already)
generic lattice noise algorithm:
http://www.codeproject.com/Articles/785084/A-generic-lattice-noise-algorithm-an-evolution-of
I suppose this is not a “Dianmond-Squere” Algorithm because it looks so linear and “griddy”.
It looks like a two dimensional “Midpoint-Displacement”. You need to do two steps first create all squares then diamonds
Wonderful! You just saved me a few hours of work, thanks a lot!
How did you generate the greyscale height map?
I think the colors were just set to 0-1 for each (R, G, B), so it becomes grayscale,
in the terrain colors image, there is some added if’s to set different colors based on the value (like if height is 0.5, then use grass color..)