diff --git a/site/cellthing.html b/site/cellthing.html index 4e21216..b137b18 100644 --- a/site/cellthing.html +++ b/site/cellthing.html @@ -21,17 +21,17 @@ The world consists of a grid of cells, and you can create new cell types and ass The engine randomly finds places where the one of your rules' input (left) picture matches a place in the world, and replaces it with the output (right) picture.

-
+

groups

A rule can also have cells containing a group. On the input side, that cell will match anything in the group, and on the output side it will become a random cell from the group. A diagonal line through the group icon means that it can also match on positions outside the world, where there are no cells.
-
+

copy cells

On the output side, a cell can be set to copy the contents of one cell from the input side, this is useful for applying the same rule to several cell types without randomly swapping between them on the output
-
+

random is easy, right?

@@ -43,7 +43,7 @@ A rule can have blank cells. On the input side, this means it will matc

worm

Let's say I make a rule for a little worm that moves to the right, this works fine. Its head disappears out of the world because the cell in front of the head in the input pattern is blank, which matches anything, including out of bounds. To make it stop just before the edge, you could set that rule cell to air.
-
+ Now if I want it to do the same thing in but to the left, I can simply draw the rule and worm in the other direction, right?

Almost. It no longer moves past the edge.
@@ -66,7 +66,7 @@ Once at the start, the engine checks every possible position and every rule, and Now, how should it even use that information? The first thing I tried was to randomly pick one of all the matches. This kind of works but leads to the simulation speed being dependent on the number of matches, so for example sand falls slower if there is a lot of sand that hasn't landed yet.

-
+

I got a slightly more even result by multiplying the speed (number of rule executions per frame) by the total number of matches, but this is not a perfect solution as it does not take into account overlapping matches. A cell contained in several rule matches would be more likely to be affected, which in some cases can lead to weird bias (see just one more implementation)
@@ -80,7 +80,7 @@ So now the engine picks a random position, then checks the cache and picks a ran I want to simulate a swarm of bees, so I create a rule for a bee moving by one cell, and enable rotate so it works in all directions. That was easy,

-
+

Oh no, the swarm is moving toward the top left instead of spreading equally. But I can see that the bees move in all four directions, so the rule seems to be rotated correctly.
@@ -90,10 +90,14 @@ I was stuck on this problem for quite a while, and it only happened with the new

The movement rule has these variants:
-
+ +

+

Each rule has its origin point in the top-left cell.
In the diagram below, the bee would move left when the left (purple) cell is picked by the engine, and up when the top (green) cell is picked.
-
+ +

+

But to move right or down, it needs the bees own position to be picked by the engine, since the rules always extend right-down. That means when the engine picks the bee's position, there are two possible rules to execute. Therefore, moving right and down both have half the probability overall compared to moving up or left.

the overlap checker

@@ -104,7 +108,7 @@ In this version, the cache is not only searched for matches at the chos Since the root issue was caused by asymmetry, I thought this implementation should be correct. This one was actually my first instinct when I created the cache, but as a friend suggested, an absolute-position based checker seemed (and indeed was) more performant and simpler, so I did that one first.

-
+

Now the bees are evenly distributed, just like real bees!(false)
@@ -114,7 +118,7 @@ Now the bees are evenly distributed, just like real bees!(false)
While I was trying to figure out the reason for the directional bias in the previous implementation, I realised that the overlap checker also has biases. The probability of any given cached match to be executed is dependent on its area, which is not very intuitive. Two objects of different mass fall at different speeds, and adding empty padding to a rule makes it run faster.

-
+

Ideally the red, pink and blue cells should all fall at around the same rate, but the red sand always lands first and the pink last.
@@ -125,7 +129,7 @@ Alright, the Final (I hope) implementation stores an origin offset for

fin

If you somehow read through all that, congratulations I think? Now enjoy this fire:
-
+

Download the thing and make something fun: git.crispypin.cc/CrispyPin/snad
diff --git a/site/horological-crimes.html b/site/horological-crimes.html index 0d41a0f..18d90e5 100644 --- a/site/horological-crimes.html +++ b/site/horological-crimes.html @@ -27,7 +27,7 @@ TODO front image
On a whim I decided to see if I could figure out what was wrong and attempt to fix it. How hard could that possibly be?

-open pocket watch with many intricate gears visible
+open pocket watch with many intricate gears visible

I am a professional

@@ -41,8 +41,8 @@ I stripped a short length of cable-tie into a 0.5mm diameter wire, bent it into And to hold the wire in place, I used hot glue because I don't respect the Art of Watchmaking have anything better.

-a small wire is inserted into the broken gearing
-the wire is now covered in hot glue
+a small wire is inserted into the broken gearing +the wire is now covered in hot glue

This seems to have worked pretty well as far as i can tell from winding up the clock and poking around. That gear is not moving sideways anymore and can rotate easily.
@@ -63,8 +63,8 @@ This is where I'm currently stuck, and most likely I'll abandon it forever. I do I tried to create a part that would hold the thicker(0.5mm) part of the gear, just below the bearing, but it's too tight against the rest of the parts. I'm sure that's possible with better tools but i'm out here using a cable tie wire as a drill and a plastic scrap instead of brass. It was fun but ultimately too difficult with no good tools.

-a small wire in a drill
-a small wire in a drill
+a small wire in a drill +a small wire in a drill

maybe one day i will ocme back to this project and fix it, maybe not. It was fun anyway
diff --git a/site/index.html b/site/index.html index 61da491..ac4d38c 100644 --- a/site/index.html +++ b/site/index.html @@ -31,6 +31,7 @@ this means it is
- snad (cell thing)
- keyboar
- distracting
+- old projects
- todo: put more words in the computer

diff --git a/site/projects/fractal_tree.png b/site/projects/fractal_tree.png new file mode 100644 index 0000000..2c4442d Binary files /dev/null and b/site/projects/fractal_tree.png differ diff --git a/site/projects/fractals.css b/site/projects/fractals.css new file mode 100644 index 0000000..75b62ce --- /dev/null +++ b/site/projects/fractals.css @@ -0,0 +1,67 @@ +.demo-render { + margin: 20px; + width: min-content; + background-color: #000; +} + +.controlbar { + background-color: #181818; + padding: 2px 5px; + height: max-content; + display: flex; + justify-content: space-evenly; + align-content: stretch; + flex-wrap: wrap; +} + +.controlbar button, +.controlbar input { + padding: 4px 6px; + height: 25px; + border: 1px solid #000; + border: 0; + cursor: pointer; + -webkit-box-flex: 1; + -ms-flex-positive: 1; + flex-grow: 1; + margin: 2px; +} + +.controlbar label { + background-color: #181818; + color: #fb8; + margin: 2px; + font-family: 'Consolas', 'Courier New', Courier, monospace; +} + +.clickable, +nav li, +.controlbar button, +.controlbar input { + border-radius: 2px; + background-color: #4a4; +} + +.clickable:hover, +nav li:hover, +.controlbar button:hover, +.controlbar input:hover { + background-color: #4af; +} + +.clickable:active, +nav li:active, +.controlbar button:active, +.controlbar input:active { + background-color: #46c; +} + +.clickable:disabled, +nav li:disabled, +.controlbar button:disabled, +.controlbar input:disabled { + background-color: #8b8; + text-decoration: line-through; + color: #000; + cursor: default; +} \ No newline at end of file diff --git a/site/projects/fractals.html b/site/projects/fractals.html new file mode 100644 index 0000000..9fb99dc --- /dev/null +++ b/site/projects/fractals.html @@ -0,0 +1,78 @@ + + + + + + + something silly - fractals + + + + + +

+

Fractals

+

+2021-05-26
+This page is a collection of fractal renderers I made in JS for a school assignment back in 2020.
+This is the only JS on this website.
+

+

Tree fractal

+

+The splitting angle is defined by the mouses x position. The number of iterations is set in the first input field (default is 12). Each branch is slightly smaller than its parent, the factor is the second input field. Click the canvas to pause/resume the image.
+

+ +
+ + +
+
+

+

Mandelbrot set

+

+Wikipedia page
+You can click to zoom and set the iteration count in the input field.
+

+ +
+ + +
+
+

+

Multibrot set

+

+Wikipedia page
+You can click to zoom and set the iteration count in the input field. The second input controls the exponent.
+

+

+This is quite slow to render.
+

+ +
+ + + +
+
+

+

Interactive Julia set

+

+Wikipedia page
+You can set the iteration count in the input field.
+

+ +
+ + +
+
+

+

+ + + +

+ + + \ No newline at end of file diff --git a/site/projects/fractals.js b/site/projects/fractals.js new file mode 100644 index 0000000..e4187d4 --- /dev/null +++ b/site/projects/fractals.js @@ -0,0 +1,264 @@ +'use strict' +// I made this in school and I had to 'use strict'. +// I no longer use JS. + +class FractalTree { + constructor(id, iterations, mod) { + this.app = document.getElementById(id); + console.debug(this.app); + this.canvas = this.app.getElementsByTagName("canvas")[0]; + this.canvas.width = 512; + this.canvas.height = 448; + this.ctx = this.canvas.getContext("2d"); + + this.iterations = iterations; + this.mod = mod; + this.angle = Math.PI * 0.2; + + this.update = true; + + this.palette = ["#430", "#440", "#450", "#460", "#470", "#480", "#080"]; + + this.canvas.addEventListener("mousemove", this.mouseMove.bind(this)); + this.canvas.addEventListener("mousedown", this.click.bind(this)); + } + + static vector(l, angle) { + return { + x: Math.cos(angle) * l, + y: Math.sin(angle) * l + }; + } + + tree(x, y, length, i, angle) { + if (i==0) { return; } + + let dir = FractalTree.vector(length * this.mod, angle + this.angle); + + this.ctx.beginPath(); + this.ctx.moveTo(x, y); + this.ctx.lineWidth = i; + this.ctx.strokeStyle = this.palette[this.iterations-i]; + this.ctx.lineTo(x + dir.x, y - dir.y); + this.ctx.stroke(); + + this.tree(x + dir.x, y - dir.y, length*this.mod, i-1, angle - this.angle); + this.tree(x + dir.x, y - dir.y, length*this.mod, i-1, angle + this.angle); + } + + render() { + this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height); + this.tree(256, this.canvas.height-64, 128, this.iterations, Math.PI/2 - this.angle); + } + + mouseMove(event) { + if (this.update) { + let x = event.clientX - this.canvas.getBoundingClientRect().left; + this.angle = x * Math.PI / this.canvas.width; + this.render(); + } + } + + click(event) { + this.update = !this.update; + if (this.update) { + let x = event.clientX - this.canvas.getBoundingClientRect().left; + this.angle = x * Math.PI / this.canvas.width; + this.render(); + } + } + + setIter(i) { + this.iterations = i; + this.render(); + } + + setMod(m) { + this.mod = m; + this.render(); + } +} + +class Mandelbrot { + constructor(id, iter=255, width=512, height=512, minX=-2, minY=-1.5, maxX=1, maxY=1.5) { + this.app = document.getElementById(id); + this.canvas = this.app.getElementsByTagName("canvas")[0]; + this.canvas.width = width; + this.canvas.height = height; + this.ctx = this.canvas.getContext("2d"); + + this.renderBtn = this.app.getElementsByClassName("controlbar")[0].getElementsByTagName("button")[0]; + + this.init(minX, minY, maxX, maxY); + this.defaultZoom = [minX, minY, maxX, maxY]; + this.iter = iter; + + this.palette = [16, 32, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 160, 168, 176, 184, 192, 200, 208, 216, 224, 232, 240, 248]; + + this.canvas.addEventListener("mousedown", this.zoom.bind(this)); + } + + zoom(event) { + //zoom function + let zoomf = 8; + let x = this.reScaleX(event.clientX - this.canvas.getBoundingClientRect().left); + let y = this.reScaleY(event.clientY - this.canvas.getBoundingClientRect().top); + let dx = (this.maxX - this.minX)/zoomf; + let dy = (this.maxY - this.minY)/zoomf; + this.init(x - dx, y - dy, x + dx, y + dy); + this.render(); + } + + reset() { + this.init(this.defaultZoom[0], this.defaultZoom[1], this.defaultZoom[2], this.defaultZoom[3]); + this.render(); + } + + setIter(x) { + this.iter = x; + this.render(); + } + + init(minX, minY, maxX, maxY) { + this.minX = minX; + this.minY = minY; + this.maxX = maxX; + this.maxY = maxY; + + this.scaleX = (maxX - minX) / this.canvas.width; + this.scaleY = (maxY - minY) / this.canvas.height; + } + + reScaleX(x) { + return x * this.scaleX + this.minX; + } + + reScaleY(y) { + return y * this.scaleY + this.minY; + } + + point(x0, y0) { + let x = 0, y = 0; + let i = 0; + let x2 = 0, y2 = 0; + while (x2 + y2 <= 4 && i < this.iter) { + y = 2*x*y + y0; + x = x2 - y2 + x0; + x2 = x*x; + y2 = y*y; + i++; + } + return i; + } + + render() { + let start = new Date(); + let result = this.ctx.getImageData(0,0, this.canvas.width, this.canvas.height); + let px = 0; + let yp; + for (let yPos = 0; yPos < this.canvas.height; yPos++) { + yp = this.reScaleY(yPos); + for (let xPos = 0; xPos < this.canvas.width; xPos++) { + let i = this.point(this.reScaleX(xPos), yp); + if (i != this.iter) { + let col = this.palette[Math.min(i, this.palette.length-1)] + result.data[px] = 0; + result.data[px+1] = col; + result.data[px+2] = col; + } else { + result.data[px] = 0; + result.data[px+1] = 0; + result.data[px+2] = 0; + } + result.data[px+3] = 255; + px += 4; + } + } + this.ctx.putImageData(result, 0, 0); + this.renderBtn.textContent = `Reset ${new Date() - start}ms`; + } + +} + +class Multibrot extends Mandelbrot { + constructor(id, power, iter=255, width=512, height=512, minX=-2, minY=-2, maxX=2, maxY=2) { + super(id, iter, width, height, minX, minY, maxX, maxY); + this.power = power; + } + + point(x0, y0) { + let x = 0, y = 0; + let i = 0; + let xtmp, xxyyn, atn; + let n2 = this.power/2; + while (x*x + y*y <= 4 && i < this.iter) { + xxyyn = (x*x+y*y)**(n2); + atn = this.power*Math.atan2(y, x); + xtmp = xxyyn * Math.cos(atn) + x0; + y = xxyyn * Math.sin(atn) + y0; + x = xtmp; + i++; + } + return i; + } + + setPower(x) { + this.power = x; + this.render(); + } +} + +class Julia extends Mandelbrot { + constructor(id, iter=255, width=512, height=512, minX=-2, minY=-2, maxX=2, maxY=2) { + super(id, iter, width, height, minX, minY, maxX, maxY); + this.cx = this.reScaleX(width/2); + this.cy = this.reScaleY(height/3.2); + + this.update = true; + + this.canvas.removeEventListener("mousedown", this.zoom); + + this.canvas.addEventListener("mousedown", this.click.bind(this)); + this.canvas.addEventListener("mousemove", this.mouseMove.bind(this)); + } + + click(event) { + this.update = !this.update; + this.mouseMove(event); + } + + zoom() { + return; + } + + mouseMove(event) { + if (this.update) { + this.cx = this.reScaleX(event.clientX - this.canvas.getBoundingClientRect().left); + this.cy = this.reScaleY(event.clientY - this.canvas.getBoundingClientRect().top); + this.render(); + } + } + + point(zx, zy) { + let i = 0, xtmp = 0; + let zx2 = zx*zx, zy2 = zy*zy; + while (zx2 + zy2 < 4 && i < this.iter) { + xtmp = zx2 - zy2; + zy = 2*zx*zy + this.cy; + zx = xtmp + this.cx; + zx2 = zx*zx; + zy2 = zy*zy; + i++; + } + return i; + } +} + +let fractalTree = new FractalTree("fractal-tree", 12, 0.75); +let mandelbrot = new Mandelbrot("mandelbrot"); +let multibrot = new Multibrot("multibrot", 4); +let juliaSet = new Julia("julia-set", 64, 512, 512); + +fractalTree.render(); +mandelbrot.render(); +juliaSet.render(); diff --git a/site/projects/gol.png b/site/projects/gol.png new file mode 100644 index 0000000..26e8c3d Binary files /dev/null and b/site/projects/gol.png differ diff --git a/site/projects/old-project-list.html b/site/projects/old-project-list.html new file mode 100644 index 0000000..0c21411 --- /dev/null +++ b/site/projects/old-project-list.html @@ -0,0 +1,77 @@ + + + + + + + something silly - old-project-list + + + + + +
+

projects

+

+2024-07-06
+Some older projects that were created before this blog
+

+

Voxel engine in Godot 3 + Rust

+

+start: 2022-04-19
+last update: 2022-05-05
+source: github.com/CrispyPin/gd-voxel-rs
+

+

+I made a voxel engine in rust to learn rust and godot-rust as well as explore voxel systems. It has (practically) infinite terrain generation, lets you place and remove voxels and supports transparent voxel types. The main point was to develop an optimised meshing algorithm.
+ +This one I actually wrote a post about here
+

+

OVR Utils

+

+start: 2021-05-14
+last update: 2022-05-08
+source: github.com/CrispyPin/ovr-utils
+

+

+OVR Utils is a VR overlay application that has some useful tools for SteamVR.
+I wanted an overlay that could tell me the time without having to open the steam dashboard, and to see the battery levels of my controllers easily, but couldn't find one for free that also had Linux support. So I decided to create my own, and also wrote down a long list of other useful tools. So far only a few of these have been implemented, such as the image overlay and the keyboard.
+

+

Raymarched voxel rendering

+

+start: 2021-04-18
+last update: 2021-04-29
+source: github.com/CrispyPin/voxel-raymarcher
+

+

+A raymarched voxel renderer made with a Godot shader.
+ +

+

Game of Life wallpaper

+

+start: 2021-03-21
+last update: 2022-02-22
+source: github.com/CrispyPin/gol-wallpaper
+

+

+This is hosted on github pages at gol.crispypin.cc
+screenshot of conways game of life +

+

Fractals

+

+start: 2020-03-04
+last update: 2020-05-19
+source: github.com/CrispyPin/Webb-1-Projekt/
+

+

+While I was learning web development and JavaScript I made a page with fractals.
+It has now been moved here
+ +

+

+back to more recent stuff
+ +

+ + + \ No newline at end of file diff --git a/site/projects/raymarched-voxels.png b/site/projects/raymarched-voxels.png new file mode 100644 index 0000000..58beffd Binary files /dev/null and b/site/projects/raymarched-voxels.png differ diff --git a/site/projects/voxel_media/demo.mp4 b/site/projects/voxel_media/demo.mp4 new file mode 100644 index 0000000..7a4721a Binary files /dev/null and b/site/projects/voxel_media/demo.mp4 differ diff --git a/site/projects/voxel_media/demo2.mp4 b/site/projects/voxel_media/demo2.mp4 new file mode 100644 index 0000000..8bb15cc Binary files /dev/null and b/site/projects/voxel_media/demo2.mp4 differ diff --git a/site/projects/voxel_media/fig1.png b/site/projects/voxel_media/fig1.png new file mode 100644 index 0000000..3139fc1 Binary files /dev/null and b/site/projects/voxel_media/fig1.png differ diff --git a/site/projects/voxel_media/fig2.png b/site/projects/voxel_media/fig2.png new file mode 100644 index 0000000..78bd96c Binary files /dev/null and b/site/projects/voxel_media/fig2.png differ diff --git a/site/projects/voxel_media/fig3.png b/site/projects/voxel_media/fig3.png new file mode 100644 index 0000000..ab400b6 Binary files /dev/null and b/site/projects/voxel_media/fig3.png differ diff --git a/site/projects/voxels.html b/site/projects/voxels.html new file mode 100644 index 0000000..2fe2ba5 --- /dev/null +++ b/site/projects/voxels.html @@ -0,0 +1,60 @@ + + + + + + + something silly - voxels + + + + + +
+

Voxel engine in Godot 3 with Rust

+

+2022-05-05
+I made a voxel engine in rust to learn rust and godot-rust as well as explore voxel systems. It has (practically) infinite terrain generation, lets you place and remove voxels and supports transparent voxel types. The main point was to develop an optimised meshing algorithm.
+

+

+ +Demo of fast terrain generation
+ +Optimised mesh visualisation
+

+

Optimised/greedy mesh algorithm

+

+editor's note: This writeup was never finished :D
+

+

+The algorithm I'm using is one I made myself, inspired by a few others. I could not find an easy to understand explanation of how to do it but this artice and this article gave me somewhere to start.
+

+

+In this explanation I will assume basic knowledge of how meshes work and how to do the simplest form of culling for voxel meshes.
+
+fig. 1: example set of voxels, with the simplest form of mesh generation applied.
+

+

+To start off, we can break down the problem to 2 dimensions by recognising that each direction along the axis as well as each layer along those directions is independent. We then only have to process a single 2D slice of the voxel domain at once.
+

+

+
+fig. 2: The algorithm only needs to consider one layer and direction at a time, highlighted in green
+

+

+The first step is to generate "strips", essentially create long quads that cover connected voxels. We can loop through the plane and keep track of at most one active strip. The active strip is the last one started and we grow it as more voxels under it are traversed. In the inner loop we check the voxel at that position as well as the one above. With this we can determine if we need to stop the current strip, start a new one or do nothing. If there is not currently an active strip, a new one should be created when the voxel below is filled and the one above is empty (an exposed surface).
+

+

+
+fig.3: Long strips of adjacent voxels can be merged into fewer, long quads.
+

+

+.
+

+

+this was incomprehensible, take me home
+ +

+ + + \ No newline at end of file diff --git a/write/cellthing.md b/write/cellthing.md index 09b56dd..29a4890 100644 --- a/write/cellthing.md +++ b/write/cellthing.md @@ -25,7 +25,7 @@ A rule can have *blank* cells. On the input side, this means it will match anyth Let's say I make a rule for a little worm that moves to the right, this works fine. Its head disappears out of the world because the cell in front of the head in the *input* pattern is blank, which matches anything, including out of bounds. To make it stop just before the edge, you could set that rule cell to air. Now if I want it to do the same thing in but to the left, I can simply draw the rule and worm in the other direction, right? - +
Almost. It no longer moves past the edge. When a rule and position is chosen, the top-left of the rule is aligned with that position. In the example above, the rule would have to start from outside the world to make the worm continue one more step. @@ -58,9 +58,11 @@ I was stuck on this problem for quite a while, and it only happened with the new The movement rule has these variants: + Each rule has its origin point in the top-left cell. In the diagram below, the bee would move left when the left (purple) cell is picked by the engine, and up when the top (green) cell is picked. + But to move right or down, it needs the bees own position to be picked by the engine, since the rules always extend right-down. That means when the engine picks the bee's position, there are *two* possible rules to execute. Therefore, moving right and down both have half the probability overall compared to moving up or left. diff --git a/write/index.md b/write/index.md index 8ce29e4..73e128a 100644 --- a/write/index.md +++ b/write/index.md @@ -15,6 +15,7 @@ this means it is - [snad (cell thing)](/cellthing) - [keyboar](/keyboards-are-fun) - [distracting](/humans/distracting) +- [old projects](/projects/old-project-list) - todo: put more words in the computer [other sites](/internets) diff --git a/write/projects/fractals.md b/write/projects/fractals.md new file mode 100644 index 0000000..41caa47 --- /dev/null +++ b/write/projects/fractals.md @@ -0,0 +1,53 @@ +# Fractals +`2021-05-26` +This page is a collection of fractal renderers I made in JS for a school assignment back in 2020. +This is the *only* JS on this website. + +## Tree fractal +The splitting angle is defined by the mouses x position. The number of iterations is set in the first input field (default is 12). Each branch is slightly smaller than its parent, the factor is the second input field. Click the canvas to pause/resume the image. +
+ +
+ + +
+
+ +## Mandelbrot set +[Wikipedia page](https://en.wikipedia.org/wiki/Mandelbrot_set) +You can click to zoom and set the iteration count in the input field. +
+ +
+ + +
+
+ +## Multibrot set +[Wikipedia page](https://en.wikipedia.org/wiki/Multibrot_set) +You can click to zoom and set the iteration count in the input field. The second input controls the exponent. + +This is quite slow to render. +
+ +
+ + + +
+
+ +## Interactive Julia set +[Wikipedia page](https://en.wikipedia.org/wiki/Julia_set) +You can set the iteration count in the input field. +
+ +
+ + +
+
+ + + diff --git a/write/projects/old-project-list.md b/write/projects/old-project-list.md new file mode 100644 index 0000000..55e4993 --- /dev/null +++ b/write/projects/old-project-list.md @@ -0,0 +1,49 @@ +# projects +`2024-07-06` +Some older projects that were created before this blog + +### Voxel engine in Godot 3 + Rust +start: `2022-04-19` +last update: `2022-05-05` +source: [github.com/CrispyPin/gd-voxel-rs](https://github.com/CrispyPin/gd-voxel-rs) + +I made a voxel engine in rust to learn rust and godot-rust as well as explore voxel systems. It has (practically) infinite terrain generation, lets you place and remove voxels and supports transparent voxel types. The main point was to develop an optimised meshing algorithm. + +This one I actually wrote a post about [here](/projects/voxels) + +### OVR Utils +start: `2021-05-14` +last update: `2022-05-08` +source: [github.com/CrispyPin/ovr-utils](https://github.com/CrispyPin/ovr-utils) + +OVR Utils is a VR overlay application that has some useful tools for SteamVR. +I wanted an overlay that could tell me the time without having to open the steam dashboard, and to see the battery levels of my controllers easily, but couldn't find one for free that also had Linux support. So I decided to create my own, and also wrote down a long list of other useful tools. So far only a few of these have been implemented, such as the image overlay and the keyboard. + +### Raymarched voxel rendering +start: `2021-04-18` +last update: `2021-04-29` +source: [github.com/CrispyPin/voxel-raymarcher](https://github.com/CrispyPin/voxel-raymarcher) + +A raymarched voxel renderer made with a Godot shader. + + +### Game of Life wallpaper +start: `2021-03-21` +last update: `2022-02-22` +source: [github.com/CrispyPin/gol-wallpaper](https://github.com/CrispyPin/gol-wallpaper/) + +This is hosted on github pages at [gol.crispypin.cc](https://gol.crispypin.cc/?cellsize=5&time=2&margin=0&populate=true) +screenshot of conways game of life + +### Fractals +start: `2020-03-04` +last update: `2020-05-19` +source: [github.com/CrispyPin/Webb-1-Projekt/](https://github.com/CrispyPin/Webb-1-Projekt/) + +While I was learning web development and JavaScript I made a page with fractals. +It has now been moved [here](/projects/fractals) + + + + +back to [more recent stuff](/) diff --git a/write/projects/voxels.md b/write/projects/voxels.md new file mode 100644 index 0000000..d75c9a0 --- /dev/null +++ b/write/projects/voxels.md @@ -0,0 +1,31 @@ +# Voxel engine in Godot 3 with Rust +`2022-05-05` +I made a voxel engine in rust to learn rust and godot-rust as well as explore voxel systems. It has (practically) infinite terrain generation, lets you place and remove voxels and supports transparent voxel types. The main point was to develop an optimised meshing algorithm. + + +Demo of fast terrain generation + +Optimised mesh visualisation + +## Optimised/greedy mesh algorithm +editor's note: This writeup was never finished :D + +The algorithm I'm using is one I made myself, inspired by a few others. I could not find an easy to understand explanation of how to do it but [this artice](https://vercidium.com/blog/voxel-world-optimisations/) and [this article](https://0fps.net/2012/06/30/meshing-in-a-minecraft-game/) gave me somewhere to start. + +In this explanation I will assume basic knowledge of how meshes work and how to do the simplest form of culling for voxel meshes. +
+fig. 1: example set of voxels, with the simplest form of mesh generation applied. + +To start off, we can break down the problem to 2 dimensions by recognising that each direction along the axis as well as each layer along those directions is independent. We then only have to process a single 2D slice of the voxel domain at once. + +
+fig. 2: The algorithm only needs to consider one layer and direction at a time, highlighted in green + +The first step is to generate "strips", essentially create long quads that cover connected voxels. We can loop through the plane and keep track of at most one active strip. The active strip is the last one started and we grow it as more voxels under it are traversed. In the inner loop we check the voxel at that position as well as the one above. With this we can determine if we need to stop the current strip, start a new one or do nothing. If there is not currently an active strip, a new one should be created when the voxel below is filled and the one above is empty (an exposed surface). + +
+fig.3: Long strips of adjacent voxels can be merged into fewer, long quads. + +. + +this was incomprehensible, take me [home](/) \ No newline at end of file