All Projects → kchapelier → Cellular Automata Voxel Shader

kchapelier / Cellular Automata Voxel Shader

Licence: mit
Generate a voxel shader (for MagicaVoxel) from a custom CA rule

Programming Languages

javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to Cellular Automata Voxel Shader

Csv2ofx
A Python library and command line tool for converting csv to ofx and qif files
Stars: ✭ 133 (-2.92%)
Mutual labels:  cli
Entrypoint
Composable CLI Argument Parser for all modern .Net platforms.
Stars: ✭ 136 (-0.73%)
Mutual labels:  cli
Braincup
Train your math skills, memory and focus.
Stars: ✭ 137 (+0%)
Mutual labels:  cli
Programmer Calculator
Terminal calculator made for programmers working with multiple number representations, sizes, and overall close to the bits
Stars: ✭ 135 (-1.46%)
Mutual labels:  cli
Simplecli
Command Line Interface Library for Arduino
Stars: ✭ 135 (-1.46%)
Mutual labels:  cli
Graphql Cli
📟 Command line tool for common GraphQL development workflows
Stars: ✭ 1,814 (+1224.09%)
Mutual labels:  cli
Om
General command line utility for working with Pivotal Operations Manager
Stars: ✭ 133 (-2.92%)
Mutual labels:  cli
Brotab
Control your browser's tabs from the command line
Stars: ✭ 137 (+0%)
Mutual labels:  cli
Sphinx Click
A Sphinx plugin to automatically document click-based applications
Stars: ✭ 134 (-2.19%)
Mutual labels:  cli
Loophole
Polar devices Python API and CLI.
Stars: ✭ 136 (-0.73%)
Mutual labels:  cli
Grofer
A system and resource monitoring tool written in Golang!
Stars: ✭ 135 (-1.46%)
Mutual labels:  cli
Ohshitgit
⁉️Oh shit! A cli tool to help you unfuck your git mistakes
Stars: ✭ 135 (-1.46%)
Mutual labels:  cli
Gk
Go-Kit Genetator
Stars: ✭ 136 (-0.73%)
Mutual labels:  cli
Spotify Cli Mac
🎶 A nodejs app to control Spotify without leaving your terminal. 🎶
Stars: ✭ 134 (-2.19%)
Mutual labels:  cli
Git Tidy
Tidy up stale git branches.
Stars: ✭ 137 (+0%)
Mutual labels:  cli
Sonic Pi Tool
🎻 Controlling Sonic Pi from the command line
Stars: ✭ 133 (-2.92%)
Mutual labels:  cli
Galacritty
WIP GTK terminal emulator based on Alacritty
Stars: ✭ 136 (-0.73%)
Mutual labels:  cli
Nord Xfce Terminal
An arctic, north-bluish clean and elegant Xfce Terminal color theme.
Stars: ✭ 136 (-0.73%)
Mutual labels:  cli
Site Scan
CLI for capturing website screenshots, powered by puppeteer.
Stars: ✭ 137 (+0%)
Mutual labels:  cli
Certok
Command line tool to check the validity and expiration dates of SSL certificates.
Stars: ✭ 136 (-0.73%)
Mutual labels:  cli

cellular-automata-voxel-shader

NPM version

Generate a voxel shader (for MagicaVoxel) from a custom CA rule.

cellular-automata-voxel-shader example

Installing and updating

With npm do:

npm install cellular-automata-voxel-shader -g

Usage

cavoxelshader rule outOfBoundValue

Return the code of the shader to stdout.

cavoxelshader info [filename]

Extracts the details of a given generated file (rule, outOfBoundValue and version) to stdout.

When used without filename, will list all the files of the current directory with their details to stdout.

Examples

cavoxelshader "E 4..6 / 6 von-neumann" 0 > erode.txt

Here "E 4..6 / 6 von-neumann" is the rule and 0 is the out-of-bound value.

General usage

In your console / terminal, go into the shader folder of your MagicaVoxel install and execute cavoxelshader "E 4..6 / 6 von-neumann" 0 > erode.txt. This will create a file called erode.txt containing the voxel shader.

Then in MagicaVoxel, load a model (for example monu1 or monu9) and execute xs erode in its console to execute it once. You can also execute xs -n 5 erode, to execute it 5 times, etc.

Rule ?

The rule describes the formula applied on each cells to update its state.

It is recommended to use the custom "Extended" rule format. The command accepts many other rule formats (Life S/B, Generations S/B/C, Vote for Life, Cyclic R/T/C/N, LUKY and NLUKY) but they were originally designed for 2D, most of them allowing only values up to 9.

The format of a valid Extended rule is as follow :

E survivalValues / birthValues neighbourhoodType neighbourhoodRange

The survivalValues defines the counts of alive neighbours necessary for a cell to survive (stay at its current alive state).
The birthValues defines the counts of alive neighbours necessary for a cell to be born (change state from dead to alive). They are both list of numbers separated by commas (thus allowing number > 9). They can also contains ranges expressed with two dots, also very useful in 3D CA.

For example "E 8,10..26 / 8..26" means :

  • a cell must survive if it has a number of alive neighbours equals to 8 or somewhere between 10 and 26
  • a cell must be born if it has a number of alive neighbours somewhere between 8 and 26

The most common neighbourhoodTypes are moore (the default) and von-neumann.
The neighbourhoodRange defines the distance that the neighbourhood covers, its radius. Its default value is 1.

A moore neighbourhood (of range 1) basically includes all the cells with a least one corner touching the current cell. In 3D, this gives 26 neighbours for a given cell. A von-neumann neighbourhood (of range 1) includes only the cells directly adjacent to the current cells. In 3D, this gives 6 neighbours for a given cell.

The Wikipedia pages for those neighbourhood include more correct definitions and examples of how the von-neumann neighbourdhood expands with a range > 1. https://en.wikipedia.org/wiki/Moore_neighborhood https://en.wikipedia.org/wiki/Von_Neumann_neighborhood

The Extended rule format also allows more unconventional neighbourhood types : corner (basically the 8 corners of the moore neighbourhood), edge (the edges of the moore neighbourhood), face (the faces of the moore neighbourdhood) and axis (all the cells directly aligned with one of the current cell's faces).

Finally, it is possible to add a probability to each range and value using a colon notation.

For example "E 8:0.75,10..26 / 8..26:0.95" means :

  • a cell might survive if its number of alie neighbours is equal to 8 (probability of 75%)
  • a cell must survive if it has a number of alive neighbours somewhere between 10 and 26
  • a cell might be born if it has a number of alive neighbours somewhere between 8 and 26 (probability of 95%)

Out-of-bound value ?

The out-of-bound value basically dictates how the cellular automata must deal with cells which are outside of the volume. Its possible values are 0 (out-of-bound values are always considered dead), 1 (out-of-bound values are always considered alive, useful to create CA expanding from the sides to the center), wrap (the cellular automata behave as if the volume was infinitely repeated in space, i.e. in a 64x64x64 volume the cell [43, 50, 64] would be wrapped to [43, 50, 0]) and clamp (the cellular automata get the nearest cell in the volume, i.e. in a 64x64x64 volume the cell [43, 50, 64] would be mapped to [43, 50, 63]).

Colouring single-state rules

Single-state rule formats (Extended, Life S/B, and LUKY) accept a single parameter allowing them to assign different colours to the cell depending on the number of alive cells in the neighbourhood at the time of the execution. By default this parameter is set to 0 which disables it. Setting it to a value of 1 enables it, while setting it to a decimal value between 0 and 1 allows to control the number of colours used.

xs myshader 0 // no colours
xs myshader 1 // one colour per number of alive cells
xs myshader 0.25 // less colours, one colour per 4 alive cells to be precise

It's possible to apply colours without modifying the state of the voxel model by executing a rule which does not do anything (ie. a rule where all cells survives and none are born). This makes it easier to experiment with different neighbourhood types and ranges.

Here are a few examples of such rules : E 0..26 / M, E 0..6 / V, E 0..32 / V 2, E 0..12 / axis 2, ...

This feature should not be executed in conjunction with multi-state rules (Generations, Cyclic R/T/C/N and NLUKY) if you care about correctness.

Examples in the wild

See the gallery for several examples.

Changelog

0.5.0 (2019-04-19) :

  • Update dependencies.
  • Drastically reduce the size of the npm package.

0.4.0 (2017-04-23) :

  • Add support for coloured output with single-state rules.

0.3.2 (2016-10-26) :

  • Changed the stochastic rule to use iRand (from magicaVoxel 0.98) instead of iFrame.
  • Updated readme with new xs -n syntax.

0.3.1 (2016-03-28) :

  • Support stochastic rules (rules with probability).

0.3.0 (2016-03-08) :

  • Implement the CLI info command.

0.2.2 (2016-03-03) :

  • Smarter code generation.

0.2.0 (2016-03-02) :

  • Add doc.
  • Add support for "clamp" out-of-bound value.

0.1.0 (2016-02-07) :

  • First implementation.

Contributors

Thanks to Nick Nenov for sharing his implementation of the colouring single-state rules feature.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].