Skip to content

4. JSON

Nicolas Perrier edited this page Sep 19, 2022 · 4 revisions

Warning : this feature is no more supported in FileToVox v1.16!

FileToVox version 1.12 allows importing .json files. These files allow you to write and read data in a specific format.

There are currently 3 main types of generation available: Terrain, Heightmap, Shader.

Terrain (Beta)

This type of generator allows you to create terrains in a procedural way. This type of generator allows you to create terrains in a procedural way. You can completely modify the generation rules as well as the different biomes that will make up your land.

TODO list :

  • Blending colors between biomes
  • Add Tree support (basically you set the path to a .vox)
Click to expand
{
 "generatorType": "Terrain",
   "width": 200,
   "length": 200,
   "seed": 12,
   "biomes": [
   	{
   		"zones": [
   			{
   				"altitudeMin": 0,
   				"altitudeMax": "63.75",
   				"moistureMin": "0.2",
   				"moistureMax": "0.35"
   			},
   			{
   				"altitudeMin": "63.75",
   				"altitudeMax": "127.5",
   				"moistureMin": "0.25",
   				"moistureMax": "0.65"
   			}
   		],
   		"voxelTop": "101, 187, 77",
   		"voxelDirt": "153, 102, 51",
   		"vegetationDensity": "0.3",
   		"vegetation": [
   			{
   				"color": "255, 80, 80",
   				"probability": "0.1"
   			}
   		]
   	},
   	
   ],
   "terrainGeneratorSettings": {
   	"maxHeight": 255,
   	"minHeight": -16,
   	"waterLevel": 25,
   	"steps": [
   		{
   			"enabled": true,
   			"operationType": "SampleHeightMapTexture",
   			"noiseTexturePath": "noise/NoiseBase.png",
   			"frequency": "0.1",
   			"noiseRangeMin": "0",
   			"noiseRangeMax": "0.3"
   		},
   		{
   			"enabled": true,
   			"operationType": "BlendAdditive",
   			"inputIndex0": 0,
   			"inputIndex1": 0,
   			"weight0": 1,
   			"weight1": "-0.3"
   		},
   		{
   			"enabled": true,
   			"operationType": "Shift",
   			"param": "0.6"
   		},
   		{
   			"enabled": true,
   			"operationType": "Exponential",
   			"param": "3.8"
   		},
   		{
   			"enabled": true,
   			"operationType": "Shift",
   			"param": "0.065"
   		},
   		{
   			"enabled": true,
   			"operationType": "FlattenOrRaise",
   			"threshold": "0.105",
   			"thresholdParam": "0.1"
   		},
   		{
   			"enabled": true,
   			"operationType": "SampleHeightMapTexture",
   			"noiseTexturePath": "noise/NoiseDetail.png",
   			"frequency": "0.3",
   			"noiseRangeMin": "0",
   			"noiseRangeMax": "0.4"
   		},
   		{
   			"enabled": true,
   			"operationType": "Shift",
   			"param": "0.8"
   		},
   		{
   			"enabled": true,
   			"operationType": "BlendMultiply",
   			"inputIndex1": "7",
   			"inputIndex2": "5"
   		},
   		{
   			"enabled": true,
   			"operationType": "FlattenOrRaise",
   			"threshold": "0.11",
   			"thresholdParam": "5"
   		},
   		{
   			"enabled": true,
   			"operationType": "BeachMask",
   			"inputIndex0": "0",
   			"threshold": "0.14"
   		}
   	],
   	"seaDepthMultiplier": 1,
   	"beachWidth": "0.0009",
   	"waterColor": "0, 67, 255",
   	"shoreColor": "255, 244, 153",
   	"bedrockColor": "44, 44, 44",
   	"moisturePath": "noise/NoiseMoisture.png",
   	"moistureScale": "0.2"
   }
}

Heightmap

This is a more advanced version of the heightmap generation which is available in single order. In this specific case you will be able to define rules for each step of the generation.

Field Type Description Optional
texturePath string Path to texture (.PNG) No
colorTexturePath string Path to texture (.PNG) for colors Yes
offset int Offset to shift the base of the generation No
offsetMerge int Offset to offset the base of the generation with respect to the previous step. Only valid for a placementMode at "TOP_ONLY" Yes
colorLimit int Limit the number of colors imported Yes
enableColor bool Activate yes or no colors. If colorTexturePath is not specified, then the rendering will only be shades of gray. Yes
excavate bool Removes all voxels that cannot be seen Yes
reverse bool Reverse the direction of generation Yes
placementMode enum Indicates the type of placement for the step No
rotationMode enum Indicates the type of rotation for the step No

PlacementMode

Enum Value Description
ADDITIVE Adds the result of the heightmap generation to the final result
REPLACE Replaces the color of the voxels that matches the previous generation step
SUBSTRACT Removes voxels that match with the previous generation step
TOP_ONLY Add voxels only if there are voxels from the previous step

RotationMode

Enum Value Description
X The sens of the generation is on the X axis
Y The sens of the generation is on the Y axis
Z The sens of the generation is on the Z axis
Click to expand
{
 "generatorType": "Heightmap",
 "steps": [
   {
     "texturePath": "../files/heightmap/step1.png",
     "colorTexturePath": "",
     "height": 100,
     "offset": 0,
     "offsetMerge": 0,
     "colorLimit": 20,
     "enableColor": true,
     "excavate": true,
     "reverse":  false,
     "placementMode": "ADDITIVE",
     "rotationMode": "Y"
   },
   {
     "texturePath": "../files/heightmap/step2.png",
     "colorTexturePath": "",
     "height": 900,
     "offset": 20,
     "offsetMerge": 0,
     "colorLimit": 20,
     "enableColor": true,
     "reverse":  true,
     "excavate": true,
     "placementMode": "SUBSTRACT",
     "rotationMode": "Y"
   },
   {
     "texturePath": "../files/heightmap/step3.png",
     "colorTexturePath": "",
     "height": 1,
     "offset": 0,
     "offsetMerge": 0,
     "colorLimit": 20,
     "enableColor": true,
     "reverse":  false,
     "excavate": true,
     "placementMode": "TOP_ONLY",
     "rotationMode": "Y"
   }
 ]
}

Shaders

You can apply pseudo shaders in FileToVox! Each shader has its own parameters. Currently there are 5 shaders

1. ShaderType: FIX_HOLES

This shader is used to fill the holes. A hole is an "empty" voxel of which at least 4 adjacent voxels are not empty.

Parameter Description Optional
iterations Indicates the number of times this shader should be applied false

2. ShaderType: FIX_LONELY

This shader removes all voxels that have no adjacent voxels.

This shader has no specific parameters

3. ShaderType: COLOR_DENOISER

This shader allows you to replace the color of a voxel according to the adjacent voxels.

Parameter Description Optional
iterations Indicates the number of times this shader should be applied false
strictMode Indicates whether the algorithm is in strict mode or not. If so, the 4 adjacent voxels must all be the same color to replace the color of the voxel. Otherwise the algorithm calculates the distance between the index of the color of the voxel and that of the adjacent voxels. If the average distance is less than or equal to the 'colorRange' parameter then the color is replaced by the dominant color of adjacent voxels. false
colorRange Specifies the maximum distance between the color indexes of the palette true

4. ShaderType: CASE

This shader case surrounds / encases the voxels which match your selected color with a chosen color.

Parameter Description Optional
iterations Indicates the number of times this shader should be applied false
targetColorIndex The index of the color target. If value is set to -1, then the shader is applied to all colors false

5. ShaderType: PATINA

This shader will grow a patina on your voxels. It won't create new voxels, just change the color. This voxel is based on the patStar shader

Parameter Range Description
iterations - Indicates the number of times this shader should be applied
thickness 1 to 100 This influences the color placement pattern of the patina. Just play around with it. Higher values might cause MagicaVoxel to crash due to high computational effort.
seed 0 to 1.000.000 Using the shader on the same scene will always yield the exact same result as long as you don't change this value. Play with this to yield different patterns on the same scene.
density 0.000 to 1.000 This defines the probability that a voxel is painted in one step. The higher the value the more aggressive the spread of the patina.
additionalColorRange (-255 to 255) A number defining how many colors following (or preceeding) your selected color will be used to paint the patina.
Click to expand
{
 "generatorType": "Shader",
 "steps": [
   {
     "shaderType": "FIX_HOLES",
     "iterations": 1
   },
   {
     "shaderType": "FIX_LONELY"
   },
   {
     "shaderType": "COLOR_DENOISER",
     "iterations": 2,
     "strictMode": false,
     "colorRange": 8
   },
   {
     "shaderType": "CASE",
     "iterations": 30,
     "TargetColorIndex": 1
   },
   {
     "shaderType": "CASE",
     "iterations": 30,
     "TargetColorIndex": 1
   },
   {
     "shaderType": "PATINA",
     "iterations": 1,
     "seed": 123,
     "density": 0.3,
     "Thickness": 4,
     "TargetColorIndex": 1,
     "AdditionalColorRange": 0
   }
 ]
}