Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Minecraft:Density function: Difference between revisions

From SAS Gaming Wiki
SyncBot (talk | contribs)
Sync: updated from Minecraft
SyncBot (talk | contribs)
Sync: updated from Minecraft
 
(5 intermediate revisions by the same user not shown)
Line 20: Line 20:


== Marker functions ==
== Marker functions ==
=== {{cd|cache_2d}} ===
=== {{cd|cache}} ===
Only computes the input density once per horizontal position.
If this density function is referenced twice, it is only computed once per block position.
<div class="treeview">
<div class="treeview">
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>cache_2d</code>).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>cache</code>).
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument}}{{until|JE 26.3}} / {{nbt|double|input}}{{upcoming|JE 26.3}}: {{json ref/density function}} &mdash; The input to be cached.
** {{Nbt|string}}{{Nbt|double|input}}: {{json ref/density function}} &mdash; The input to be cached.
</div>
</div>


=== {{cd|cache_all_in_cell}} ===
=== {{cd|interpolated}} ===
Used by the game onto <code>final_density</code> and should not be referenced in data packs.
{{until|JE 26.4}}
<div class="treeview">
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>cache_all_in_cell</code>).
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument}}{{until|JE 26.3}} / {{nbt|double|input}}{{upcoming|JE 26.3}}: {{json ref/density function}} &mdash; The input to be cached.
</div>


=== {{cd|cache_once}} ===
Interpolates at each block in one cell based on the input density function value of some cells around. The size of each cell is <code>size_horizontal * 4</code> and <code>size_vertical * 4</code>.
If this density function is referenced twice, it is only computed once per block position.
<div class="treeview">
<div class="treeview">
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>cache_once</code>).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>interpolated</code>).
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument}}{{until|JE 26.3}} / {{nbt|double|input}}{{upcoming|JE 26.3}}: {{json ref/density function}} &mdash; The input to be cached.
** {{Nbt|string}}{{Nbt|double|input}}: {{json ref/density function}} &mdash; The input to be interpolated.
** {{nbt|int|cell_size_xz}}: Size in blocks of the interpolation grid cells on the X and Z axes. The number must not be negative.
** {{nbt|int|cell_size_y}}: Size in blocks of the interpolation grid cells on the Y axis. The number must not be negative.
</div>
</div>


=== {{cd|flat_cache}} ===
=== {{cd|upscale}} ===
Calculate the value per 4×4 column (Value at each block in one column is the same). And it is calculated only once per column, at Y=0. Used often in combination with <code>interpolated</code>.
Samples the input function at a reduced resolution and upscales on each axis with the specified modes. Modes that require more samples will generally perform worse. Upscaling is peformed by axis in order of Z, X, then Y.{{upcoming|JE 26.4}}
<div class="treeview">
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>flat_cache</code>).
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument}}{{until|JE 26.3}} / {{nbt|double|input}}{{upcoming|JE 26.3}}: {{json ref/density function}} &mdash; The input to be cached.
</div>


=== {{cd|interpolated}} ===
Interpolates at each block in one cell based on the input density function value of some cells around. The size of each cell is <code>size_horizontal * 4</code> and <code>size_vertical * 4</code>. Used often in combination with <code>flat_cache</code>.
<div class="treeview">
<div class="treeview">
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>interpolated</code>).
** {{nbt|string|type}}: The ID of the density function type (in this case, <code>upscale</code>).
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument}}{{until|JE 26.3}} / {{nbt|double|input}}{{upcoming|JE 26.3}}: {{json ref/density function}} &mdash; The input to be interpolated.
** {{Nbt|string}}{{Nbt|double|input}}: {{json ref/density function}} &mdash; The input to sample.
** {{nbt|int-array|point}}: {{cd|[x, y, z]}}; the configuration for this axis.
*** {{nbt|string|mode}}: one of:
**** {{nbt|int|nearest_neighbor}}: Value is discontinuous across cell boundaries, with the gradient always at 0. The values at cell vertices will always be equal to the cell value. One sample per axis.
**** {{nbt|int|interpolate_linear}}: Value is continuous, and the gradient is content with a cell but discontinuous across cell boundaries. The values at cell vertices will always be equal to the cell value. Two samples per axis.
**** {{nbt|int|interpolate_cosine}}: Value and gradient are continuous, and the gradient is 0 at cell boundaries. The values at cell vertices will always be equal to the cell value. Two samples per axis.
**** {{nbt|int|interpolate_cubic}}: Value and gradient are continuous. The values at cell vertices will always be equal to the cell value. Four samples per axis.
**** {{nbt|int|b_spline_cubic}}: Value and gradient are continuous. The values at cell vertices do not necessarily need to equal to the cell value. Four samples per axis.
*** {{nbt|int|cell_size}}: The size of each upscaling cell. Value between 1 and 64, inclusive.
</div>
</div>


Line 71: Line 68:
** {{Nbt|double|xz_scale}}: Scales the X and Z before sampling.
** {{Nbt|double|xz_scale}}: Scales the X and Z before sampling.
** {{Nbt|double|y_scale}}: Scales the Y before sampling.
** {{Nbt|double|y_scale}}: Scales the Y before sampling.
** {{nbt|double|shift_x}}: Optional; A domain warp to apply on X. If not specified, no warping will be applied (equivalent to 0).
** {{nbt|double|shift_y}}: Optional; A domain warp to apply on Y. If not specified, no warping will be applied (equivalent to 0).
** {{nbt|double|shift_z}}: Optional; A domain warp to apply on Z. If not specified, no warping will be applied (equivalent to 0).
</div>
</div>


Line 90: Line 90:
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>shift</code>).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>shift</code>).
** {{Nbt|string|argument}}{{until|JE 26.3}} / {{nbt|string|noise}}{{upcoming|JE 26.3}}: {{json ref|noise|Custom noise}} &mdash; The noise to sample.
** {{Nbt|string|noise}}: {{json ref|noise|Custom noise}} &mdash; The noise to sample.
</div>
</div>


Line 98: Line 98:
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>shift_a</code>).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>shift_a</code>).
** {{Nbt|string|argument}}{{until|JE 26.3}} / {{nbt|string|noise}}{{upcoming|JE 26.3}}: {{json ref|noise|Custom noise}} &mdash; The noise to sample.
** {{Nbt|string|noise}}: {{json ref|noise|Custom noise}} &mdash; The noise to sample.
</div>
</div>


Line 106: Line 106:
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>shift_b</code>).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>shift_b</code>).
** {{Nbt|string|argument}}{{until|JE 26.3}} / {{nbt|string|noise}}{{upcoming|JE 26.3}}: {{json ref|noise|Custom noise}} &mdash; The noise to sample.
</div>
=== {{cd|shifted_noise}} ===
Similar to <code>noise</code>, but first shifts the input coordinates.
<div class="treeview">
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>shifted_noise</code>).
** {{Nbt|string|noise}}: {{json ref|noise|Custom noise}} &mdash; The noise to sample.
** {{Nbt|string|noise}}: {{json ref|noise|Custom noise}} &mdash; The noise to sample.
** {{Nbt|double|xz_scale}}: Scales the X and Z before sampling.
** {{Nbt|double|y_scale}}: Scales the Y before sampling.
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|shift_x}}: {{json ref/density function}} &mdash; offset of the position in the X direction.
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|shift_y}}: {{json ref/density function}} &mdash; offset of the position in the Y direction.
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|shift_z}}: {{json ref/density function}} &mdash; offset of the position in the Z direction.
</div>
</div>


Line 130: Line 117:
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>abs</code>).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>abs</code>).
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument}}{{until|JE 26.3}} / {{nbt|double|input}}{{upcoming|JE 26.3}}: {{json ref/density function}} &mdash; The input of the calculation.
** {{Nbt|string}}{{Nbt|double|input}}: {{json ref/density function}} &mdash; The input of the calculation.
</div>
</div>


Line 138: Line 125:
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>add</code>).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>add</code>).
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument1}}{{until|JE 26.3}} / {{nbt|double|left}}{{upcoming|JE 26.3}}: {{json ref/density function}} &mdash; The first input of the calculation.
** {{Nbt|string}}{{Nbt|double|left}}: {{json ref/density function}} &mdash; The first input of the calculation.
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument2}}{{until|JE 26.3}} / {{nbt|double|right}}{{upcoming|JE 26.3}}: {{json ref/density function}} &mdash; The second input of the calculation.
** {{Nbt|string}}{{Nbt|double|right}}: {{json ref/density function}} &mdash; The second input of the calculation.
</div>
</div>


=== {{cd|ceil}} ===
=== {{cd|ceil}} ===
Rounds the input value to positive infinity.{{upcoming|JE 26.3}}
Rounds the input value to positive infinity.


<div class="treeview">
<div class="treeview">
Line 167: Line 154:
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>constant</code>).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>constant</code>).
** {{Nbt|double|argument}}{{until|JE 26.3}} / {{nbt|double|value}}{{upcoming|JE 26.3}}: A constant value. Value between −1000000.0 and 1000000.0 (both inclusive).
** {{Nbt|double|argument|value}}: A constant value. Value between −1000000.0 and 1000000.0 (both inclusive).
</div>
</div>


Line 175: Line 162:
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>cube</code>).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>cube</code>).
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument}}{{until|JE 26.3}} / {{nbt|double|input}}{{upcoming|JE 26.3}}: {{json ref/density function}} &mdash; The input of the calculation.
** {{Nbt|string}}{{Nbt|double|input}}: {{json ref/density function}} &mdash; The input of the calculation.
</div>
</div>


=== {{cd|div}} ===
=== {{cd|div}} ===
Performs division between two arguments.{{upcoming|JE 26.3}}
Performs division between two arguments.
<div class="treeview">
<div class="treeview">
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
Line 188: Line 175:


=== {{cd|floor}} ===
=== {{cd|floor}} ===
Rounds the input value to negative infinity.{{upcoming|JE 26.3}}
Rounds the input value to negative infinity.


<div class="treeview">
<div class="treeview">
Line 195: Line 182:
** {{nbt|string}}{{nbt|double}}{{nbt|compound|input}}: Density Function to round.
** {{nbt|string}}{{nbt|double}}{{nbt|compound|input}}: Density Function to round.
** {{nbt|string}}{{nbt|double}}{{nbt|compound|multiple}}: The output will be rounded to an integer multiple of the value returned by this Density Function. If not specified, defaults to a constant 1.
** {{nbt|string}}{{nbt|double}}{{nbt|compound|multiple}}: The output will be rounded to an integer multiple of the value returned by this Density Function. If not specified, defaults to a constant 1.
</div>
=== {{cd|invert}} ===
Renamed to {{cd|reciprocal}}.{{upcoming|JE 26.3}}
Inverts the input (<code>1/x</code>).
<div class="treeview">
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>invert</code>{{until|JE 26.3}} / <code>reciprocal</code>{{upcoming|JE 26.3}}).
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument}}: {{json ref/density function}} &mdash; The input of the calculation.
</div>
</div>


=== {{cd|log}} ===
=== {{cd|log}} ===
Computes the natural logarithm of the given input.{{upcoming|JE 26.3}}
Computes the natural logarithm of the given input.


<div class="treeview">
<div class="treeview">
Line 220: Line 198:
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>mul</code>).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>mul</code>).
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument1}}{{until|JE 26.3}} / {{nbt|double|left}}{{upcoming|JE 26.3}}: {{json ref/density function}} &mdash; The first input of the calculation.
** {{Nbt|string}}{{Nbt|double|left}}: {{json ref/density function}} &mdash; The first input of the calculation.
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument2}}{{until|JE 26.3}} / {{nbt|double|right}}{{upcoming|JE 26.3}}: {{json ref/density function}} &mdash; The second input of the calculation.
** {{Nbt|string}}{{Nbt|double|right}}: {{json ref/density function}} &mdash; The second input of the calculation.
</div>
</div>


Line 229: Line 207:
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>min</code>).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>min</code>).
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument1}}{{until|JE 26.3}} / {{nbt|double|left}}{{upcoming|JE 26.3}}: {{json ref/density function}} &mdash; The first input of the calculation.
** {{Nbt|string}}{{Nbt|double|left}}: {{json ref/density function}} &mdash; The first input of the calculation.
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument2}}{{until|JE 26.3}} / {{nbt|double|right}}{{upcoming|JE 26.3}}: {{json ref/density function}} &mdash; The second input of the calculation.
** {{Nbt|string}}{{Nbt|double|right}}: {{json ref/density function}} &mdash; The second input of the calculation.
</div>
</div>


Line 238: Line 216:
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>max</code>).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>max</code>).
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument1}}{{until|JE 26.3}} / {{nbt|double|left}}{{upcoming|JE 26.3}}: {{json ref/density function}} &mdash; The first input of the calculation.
** {{Nbt|string}}{{Nbt|double|left}}: {{json ref/density function}} &mdash; The first input of the calculation.
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument2}}{{until|JE 26.3}} / {{nbt|double|right}}{{upcoming|JE 26.3}}: {{json ref/density function}} &mdash; The second input of the calculation.
** {{Nbt|string}}{{Nbt|double|right}}: {{json ref/density function}} &mdash; The second input of the calculation.
</div>
</div>


=== {{cd|negate}} ===
=== {{cd|negate}} ===
Negates the input.{{upcoming|JE 26.3}}
Negates the input.
<div class="treeview">
<div class="treeview">
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
Line 251: Line 229:


=== {{cd|pow}} ===
=== {{cd|pow}} ===
Raises the given base value to an exponent.{{upcoming|JE 26.3}}
Raises the given base value to an exponent.


<div class="treeview">
<div class="treeview">
Line 258: Line 236:
** {{nbt|string}}{{nbt|double}}{{nbt|compound|base}}: the base value (Density Function).
** {{nbt|string}}{{nbt|double}}{{nbt|compound|base}}: the base value (Density Function).
** {{nbt|string}}{{nbt|double}}{{nbt|compound|exponent}}: the exponent (Density Function).
** {{nbt|string}}{{nbt|double}}{{nbt|compound|exponent}}: the exponent (Density Function).
</div>
=== {{cd|reciprocal}} ===
Inverts the input (<code>1/x</code>).
<div class="treeview">
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>reciprocal</code>).
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument}}: {{json ref/density function}} &mdash; The input of the calculation.
</div>
</div>


=== {{cd|round}} ===
=== {{cd|round}} ===
Rounds the input value to to the nearest integer (ties round up).{{upcoming|JE 26.3}}
Rounds the input value to to the nearest integer (ties round up).


<div class="treeview">
<div class="treeview">
Line 271: Line 257:


=== {{cd|sub}} ===
=== {{cd|sub}} ===
Performs subtraction between two arguments.{{upcoming|JE 26.3}}
Performs subtraction between two arguments.
<div class="treeview">
<div class="treeview">
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
Line 280: Line 266:


=== {{cd|sign}} ===
=== {{cd|sign}} ===
Computes the sign of the given input.  If positive, it returns as 1. If the input is 0, it returns 0. If negative, it returns as -1.{{upcoming|JE 26.3}}
Computes the sign of the given input.  If positive, it returns as 1. If the input is 0, it returns 0. If negative, it returns as -1.


<div class="treeview">
<div class="treeview">
Line 289: Line 275:


=== {{cd|sqrt}} ===
=== {{cd|sqrt}} ===
Computes the square root of the given input.{{upcoming|JE 26.3}}
Computes the square root of the given input.


<div class="treeview">
<div class="treeview">
Line 302: Line 288:
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>square</code>).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>square</code>).
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument}}{{until|JE 26.3}} / {{nbt|double|input}}{{upcoming|JE 26.3}}: {{json ref/density function}} &mdash; The input of the calculation.
** {{Nbt|string}}{{Nbt|double|input}}: {{json ref/density function}} &mdash; The input of the calculation.
</div>
</div>


=== {{cd|truncate}} ===
=== {{cd|truncate}} ===
Rounds the input value to 0.{{upcoming|JE 26.3}}
Rounds the input value to 0.


<div class="treeview">
<div class="treeview">
Line 319: Line 305:


=== {{cd|gradient}} ===
=== {{cd|gradient}} ===
[[File:Gradient tiling.png|thumb|Demonstration of the different tiling options for the {{cd|gradient}} density function{{upcoming|JE 26.3}}, using both an input range of -100 to 100 and an output range of -1 to 1.]]
[[File:Gradient tiling.png|thumb|Demonstration of the different tiling options for the {{cd|gradient}} density function, using both an input range of -100 to 100 and an output range of -1 to 1.]]
Clamps the given coordinate and maps the gradient to a range.{{upcoming|JE 26.3}}
Clamps the given coordinate and maps the gradient to a range.
<div class="treeview">
<div class="treeview">
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
Line 329: Line 315:
*** <code>repeat</code>: The gradient will be repeated outside its boundaries.
*** <code>repeat</code>: The gradient will be repeated outside its boundaries.
*** <code>mirrored_repeat</code>: The gradient will be repeated as such that odd repetitions are mirrored, ensuring continuity between repetitions.
*** <code>mirrored_repeat</code>: The gradient will be repeated as such that odd repetitions are mirrored, ensuring continuity between repetitions.
** {{nbt|int|from_coordinate}}{{upcoming|JE 26.3}}: The coordinate at which the gradient starts.
** {{nbt|int|from_coordinate}}: The coordinate at which the gradient starts. A vertical anchor is acceptable if the {{cd|axis}} is {{cd|y}}.{{upcoming|JE 26.4}}
** {{nbt|int|to_coordinate}}: The coordinate at which the gradient ends. It must not equal {{cd|from_coordinate}}.
** {{nbt|int|to_coordinate}}: The coordinate at which the gradient ends. It must not equal {{cd|from_coordinate}}. A vertical anchor is acceptable if the {{cd|axis}} is {{cd|y}}.{{upcoming|JE 26.4}}
** {{nbt|float|from_value}}: The value at which the gradient starts.
** {{nbt|float|from_value}}: The value at which the gradient starts.
** {{nbt|float|to_value}}: The value at which the gradient ends.
** {{nbt|float|to_value}}: The value at which the gradient ends.
Line 336: Line 322:


=== {{cd|lerp}} ===
=== {{cd|lerp}} ===
Performs (unclamped) linear interpolation between two arguments based on an alpha.{{upcoming|JE 26.3}} The returned value is: <code>first*(1-alpha) + second*alpha</code>
Performs (unclamped) linear interpolation between two arguments based on an alpha. The returned value is: <code>first*(1-alpha) + second*alpha</code>
<div class="treeview">
<div class="treeview">
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
Line 350: Line 336:
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>squeeze</code>).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>squeeze</code>).
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument}}{{until|JE 26.3}} / {{nbt|double|input}}{{upcoming|JE 26.3}}: {{json ref/density function}} &mdash; The input of the calculation.
** {{Nbt|string}}{{Nbt|double|input}}: {{json ref/density function}} &mdash; The input of the calculation.
</div>
</div>


Line 365: Line 351:
***** {{Nbt|float}}{{Nbt|compound|value}}: The value of this point. Can be either a number or a spline object.
***** {{Nbt|float}}{{Nbt|compound|value}}: The value of this point. Can be either a number or a spline object.
***** {{Nbt|float|derivative}}: The slope at this point.
***** {{Nbt|float|derivative}}: The slope at this point.
</div>
=== {{cd|y_clamped_gradient}} ===
Replaced with {{cd|gradient}}.{{upcoming|JE 26.3}}
Clamps the Y coordinate between <code>from_y</code> and <code>to_y</code> and then linearly maps it to a range.{{until|JE 26.3}}
<div class="treeview">
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>y_clamped_gradient</code>).
** {{Nbt|int|from_y}}: The value to be mapped to <code>from_value</code>. Value between −4064 and 4062 (both inclusive).
** {{Nbt|int|to_y}}: The value to be mapped to <code>to_value</code>. Value between −4064 and 4062 (both inclusive).
** {{Nbt|double|from_value}}: The value to map <code>from_y</code> to. Value between −1000000.0 and 1000000.0 (both inclusive).
** {{Nbt|double|to_value}}: The value to map <code>to_y</code> to. Value between −1000000.0 and 1000000.0 (both inclusive).
</div>
</div>


Line 388: Line 361:
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>half_negative</code>).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>half_negative</code>).
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument}}{{until|JE 26.3}} / {{nbt|double|input}}{{upcoming|JE 26.3}}: {{json ref/density function}} &mdash; The input of the calculation.
** {{Nbt|string}}{{Nbt|double|input}}: {{json ref/density function}} &mdash; The input of the calculation.
</div>
</div>


Line 410: Line 383:
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>quarter_negative</code>).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>quarter_negative</code>).
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument}}{{until|JE 26.3}} / {{nbt|double|input}}{{upcoming|JE 26.3}}: {{json ref/density function}} &mdash; The input of the calculation.
** {{Nbt|string}}{{Nbt|double|input}}: {{json ref/density function}} &mdash; The input of the calculation.
</div>
</div>


Line 445: Line 418:
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>blend_density</code>).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>blend_density</code>).
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument}}{{until|JE 26.3}} / {{nbt|double|input}}{{upcoming|JE 26.3}}: {{json ref/density function}} &mdash; The desired density of new chunks.
** {{Nbt|string}}{{Nbt|double|input}}: {{json ref/density function}} &mdash; The desired density of new chunks.
</div>
</div>


Line 456: Line 429:


=== {{cd|distance_to_point}} ===
=== {{cd|distance_to_point}} ===
[[File:Distance to point options.png|thumb|Demonstration of the different metric options for the {{cd|distance_to_point}} density function{{upcoming|JE 26.3}}, using the distance from the point (0, 0).]]
[[File:Distance to point options.png|thumb|Demonstration of the different metric options for the {{cd|distance_to_point}} density function, using the distance from the point (0, 0).]]
Computes the distance to a fixed point using the specified distance function.{{upcoming|JE 26.3}}
Computes the distance to a fixed point using the specified distance function.


<div class="treeview">
<div class="treeview">
Line 470: Line 443:
</div>
</div>


=== {{cd|end_islands}} ===
=== {{cd|domain_warp}} ===
Renamed to {{cd|end_outer_islands}}.{{upcoming|JE 26.3}}
Samples an input function by applying an offset to each sampled coordinate.{{upcoming|JE 26.4}}
 
If the offsets change rapidly by a large amount, performance may degrade significantly. This function should be used sparingly.
 
<div class="treeview">
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>domain_warp</code>).
** {{Nbt|string}}{{Nbt|double|input}}: {{json ref/density function}} &mdash; The input to sample.
**  {{nbt|int-array|offset_x}}: {{json ref/density function}} &mdash; The offset to apply to sampled X coordinates. The result is impliticly truncated to an integer. If not specified, it defaults to 0.0.
**  {{nbt|int-array|offset_y}}: {{json ref/density function}} &mdash; The offset to apply to sampled Y coordinates. The result is impliticly truncated to an integer. If not specified, it defaults to 0.0.
**  {{nbt|int-array|offset_z}}: {{json ref/density function}} &mdash; The offset to apply to sampled Z coordinates. The result is impliticly truncated to an integer. If not specified, it defaults to 0.0.
</div>
 
=== {{cd|end_outer_islands}} ===
Samples at current position using a noise algorithm used for end islands. Its minimum value is −0.84375 and its maximum value is 0.5625.
Samples at current position using a noise algorithm used for end islands. Its minimum value is −0.84375 and its maximum value is 0.5625.
<div class="treeview">
<div class="treeview">
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>end_islands</code>{{until|JE 26.3}} / <code>end_outer_islands</code>{{upcoming|JE 26.3}}).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>end_outer_islands</code>).
</div>
</div>


Line 487: Line 473:
** {{Nbt|int|lower_bound}}: The y-level to stop the scan.
** {{Nbt|int|lower_bound}}: The y-level to stop the scan.
** {{Nbt|int|cell_height}}: The resolution of the scan. E.g. if set to <code>4</code>, then only every 4th block is checked.
** {{Nbt|int|cell_height}}: The resolution of the scan. E.g. if set to <code>4</code>, then only every 4th block is checked.
</div>
=== {{cd|ore_vein}} ===
<div class="treeview">
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>ore_vein</code>).
** {{nbt|string|ore_block}}: The ore block to place.
** {{nbt|string|raw_ore_block}}: The raw ore block to place.
** {{nbt|string|filler_block}}: The filler block to place.
** {{nbt|float|raw_ore_chance}}: The probability for a raw ore block to be placed instead of an ore block. Value between 0 and 1 (inclusive).
** {{nbt|int|density}}: The probability for the ore vein to replace a block. If the value is 0 or lower, no block will be replaced.
** {{nbt|int|richness}}: The probability for an ore block or a raw ore block to be placed, as opposed to {{cd|filler_block}}. If the value is 0 or lower, all blocks will be the filler block. If the value is 1 or greater, no blocks will be the filler block.
** {{nbt|int|filler_gap}}: Overrides {{cd|richness}}; if the value is positive, {{cd|filler_block}} will always be placed.
</div>
</div>


=== {{cd|slice}} ===
=== {{cd|slice}} ===
Removes a dimension from the input domain by taking a "slice" along an axis with a specific coordinate (e.g. with the axis equaling y and the coordinate of 0, a slice will be taken along the XZ plane, with all values sampled at y=0).{{upcoming|JE 26.3}}
Removes a dimension from the input domain by taking a "slice" along an axis with a specific coordinate (e.g. with the axis equaling y and the coordinate of 0, a slice will be taken along the XZ plane, with all values sampled at y=0).


<div class="treeview">
<div class="treeview">
Line 502: Line 502:
== Removed density functions ==
== Removed density functions ==
{{outdated|section=1}}
{{outdated|section=1}}
=== {{cd|cache_2d}} ===
Removed in [[Minecraft:26.3-snap10]]
Only computes the input density once per horizontal position.
<div class="treeview">
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>cache_2d</code>).
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument}}: {{json ref/density function}} &mdash; The input to be cached.
</div>
=== {{cd|cache_all_in_cell}} ===
Removed in [[Minecraft:26.3-snap10]]
Used by the game onto <code>final_density</code> and should not be referenced in data packs.
<div class="treeview">
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>cache_all_in_cell</code>).
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument}}: {{json ref/density function}} &mdash; The input to be cached.
</div>
=== {{cd|flat_cache}} ===
Removed in [[Minecraft:26.3-snap10]]
Calculate the value per 4×4 column (Value at each block in one column is the same). And it is calculated only once per column, at Y=0. Used often in combination with <code>interpolated</code>.
<div class="treeview">
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>flat_cache</code>).
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument}}: {{json ref/density function}} &mdash; The input to be cached.
</div>
=== {{cd|shifted_noise}} ===
Removed in [[Minecraft:26.3-snap10]]
Similar to <code>noise</code>, but first shifts the input coordinates.
<div class="treeview">
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>shifted_noise</code>).
** {{Nbt|string|noise}}: {{json ref|noise|Custom noise}} &mdash; The noise to sample.
** {{Nbt|double|xz_scale}}: Scales the X and Z before sampling.
** {{Nbt|double|y_scale}}: Scales the Y before sampling.
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|shift_x}}: {{json ref/density function}} &mdash; offset of the position in the X direction.
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|shift_y}}: {{json ref/density function}} &mdash; offset of the position in the Y direction.
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|shift_z}}: {{json ref/density function}} &mdash; offset of the position in the Z direction.
</div>


=== {{cd|slide}} ===
=== {{cd|slide}} ===
Line 551: Line 596:
** {{Nbt|string|noise}}: {{json ref|noise|Custom noise}} &mdash; The noise to sample.
** {{Nbt|string|noise}}: {{json ref|noise|Custom noise}} &mdash; The noise to sample.
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|input}}: The input density function. Can be an ID of a density function, or a density function in the form of a JSON object or a constant number.
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|input}}: The input density function. Can be an ID of a density function, or a density function in the form of a JSON object or a constant number.
</div><!--
</div>
 
=== {{cd|y_clamped_gradient}} ===
Removed in [[Minecraft:26.3-snap6]]
 
Clamps the Y coordinate between <code>from_y</code> and <code>to_y</code> and then linearly maps it to a range.
<div class="treeview">
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>y_clamped_gradient</code>).
** {{Nbt|int|from_y}}: The value to be mapped to <code>from_value</code>. Value between −4064 and 4062 (both inclusive).
** {{Nbt|int|to_y}}: The value to be mapped to <code>to_value</code>. Value between −4064 and 4062 (both inclusive).
** {{Nbt|double|from_value}}: The value to map <code>from_y</code> to. Value between −1000000.0 and 1000000.0 (both inclusive).
** {{Nbt|double|to_value}}: The value to map <code>to_y</code> to. Value between −1000000.0 and 1000000.0 (both inclusive).
</div>
<!--
TYPE2
TYPE2
if (d < −0.75) {
if (d < −0.75) {
Line 584: Line 643:
|{{HistoryLine||26.2|dev=snap1|Density function {{cd|minecraft:clamp}} can now take a density function ID as an input.}}
|{{HistoryLine||26.2|dev=snap1|Density function {{cd|minecraft:clamp}} can now take a density function ID as an input.}}
|{{HistoryLine|||dev=snap5|Added density function {{cd|minecraft:interval_select}}.|Removed density function {{cd|minecraft:weird_scale_sampler}}. Its functionality has been replaced with {{cd|interval_select}}.}}
|{{HistoryLine|||dev=snap5|Added density function {{cd|minecraft:interval_select}}.|Removed density function {{cd|minecraft:weird_scale_sampler}}. Its functionality has been replaced with {{cd|interval_select}}.}}
|{{HistoryLine|java upcoming}}
|{{HistoryLine||26.3|dev=snap4|Added the following density functions:
|{{HistoryLine||26.3|dev=snap4|Added the following density functions:
* {{cd|ceil}}
* {{cd|ceil}}
Line 607: Line 665:
}}
}}
|{{HistoryLine|||dev=snap7|Density functions are no longer evaluated with double-precision floating point values, but instead with single-precision.}}
|{{HistoryLine|||dev=snap7|Density functions are no longer evaluated with double-precision floating point values, but instead with single-precision.}}
|{{HistoryLine|||dev=snap10|Added the {{cd|ore_vein}} density function.
|{{cd|cache_once}} has been renamed to {{cd|cache}}.
|Added the {{cd|shift_x}}, {{cd|shift_y}}, and {{cd|shift_z}} fields to the {{cd|noise}} density function.
|Added the {{cd|cell_size_xz}} and {{cd|cell_size_y}} fields to the {{cd|interpolated}} density function.
|Removed the following density functions:
* {{cd|cache_2d}}
* {{cd|cache_all_in_cell}}
* {{cd|flat_cache}}
* {{cd|shifted_noise}}
}}
|{{HistoryLine|java upcoming}}
|{{HistoryLine||26.4|dev=snap5|{{cd|interpolated}} has been replaced with {{cd|upscale}}.}}
|{{HistoryLine|||dev=snap6|Added the {{cd|domain_warp}} density function.
|The {{cd|from_coordinate}} and {{cd|to_coordinate}} fields in the {{cd|gradient}} density function now accept a vertical anchor if the axis is Y.}}
}}
}}


== Issues ==
== Issues ==
{{issue list|projects=MC}}
{{issue list|projects=MC}}
== References ==
{{reflist}}


== External links ==
== External links ==

Latest revision as of 11:05, 28 October 2026

Template:Exclusive Density functions make up mathematical expressions to obtain a number from a position, stored as Minecraft:JSON files within a Minecraft:data pack in the path data/<namespace>/worldgen/density_function. They are referenced from the Minecraft:noise router in Minecraft:noise settings.

Template:TOC

JSON format

A density function can be a constant number or an object.

If the Template:Nbt is constant, a shorthand format is:

  • Template:Nbt: A constant number. Value between −1000000.0 and 1000000.0 (both inclusive).

Marker functions

Template:Cd

If this density function is referenced twice, it is only computed once per block position.

Template:Cd

Template:Until

Interpolates at each block in one cell based on the input density function value of some cells around. The size of each cell is size_horizontal * 4 and size_vertical * 4.

Template:Cd

Samples the input function at a reduced resolution and upscales on each axis with the specified modes. Modes that require more samples will generally perform worse. Upscaling is peformed by axis in order of Z, X, then Y.Template:Upcoming

  • Template:Nbt: Root object.
    • Template:Nbt: The ID of the density function type (in this case, upscale).
    • Template:NbtTemplate:Nbt: Template:Json ref/density function — The input to sample.
    • Template:Nbt: Template:Cd; the configuration for this axis.
      • Template:Nbt: one of:
        • Template:Nbt: Value is discontinuous across cell boundaries, with the gradient always at 0. The values at cell vertices will always be equal to the cell value. One sample per axis.
        • Template:Nbt: Value is continuous, and the gradient is content with a cell but discontinuous across cell boundaries. The values at cell vertices will always be equal to the cell value. Two samples per axis.
        • Template:Nbt: Value and gradient are continuous, and the gradient is 0 at cell boundaries. The values at cell vertices will always be equal to the cell value. Two samples per axis.
        • Template:Nbt: Value and gradient are continuous. The values at cell vertices will always be equal to the cell value. Four samples per axis.
        • Template:Nbt: Value and gradient are continuous. The values at cell vertices do not necessarily need to equal to the cell value. Four samples per axis.
      • Template:Nbt: The size of each upscaling cell. Value between 1 and 64, inclusive.

Noise sampling functions

These density functions are used to sample noises.

Template:Cd

Samples a noise.

  • Template:Nbt: Root object.
    • Template:Nbt: The ID of the density function type (in this case, noise).
    • Template:Nbt: Template:Json ref — The noise to sample.
    • Template:Nbt: Scales the X and Z before sampling.
    • Template:Nbt: Scales the Y before sampling.
    • Template:Nbt: Optional; A domain warp to apply on X. If not specified, no warping will be applied (equivalent to 0).
    • Template:Nbt: Optional; A domain warp to apply on Y. If not specified, no warping will be applied (equivalent to 0).
    • Template:Nbt: Optional; A domain warp to apply on Z. If not specified, no warping will be applied (equivalent to 0).

Template:Cd

Samples a legacy noise. Template:Info needed

  • Template:Nbt: Root object.
    • Template:Nbt: The ID of the density function type (in this case, old_blended_noise).
    • Template:Nbt: Value between 0.001 and 1000.0 (both inclusive).
    • Template:Nbt: Value between 0.001 and 1000.0 (both inclusive).
    • Template:Nbt: Value between 0.001 and 1000.0 (both inclusive).
    • Template:Nbt: Value between 0.001 and 1000.0 (both inclusive).
    • Template:Nbt: Value between 1.0 and 8.0 (both inclusive).

Template:Cd

Samples a noise at (x/4, y/4, z/4), then multiplies it by 4.

Template:Cd

Samples a noise at (x/4, 0, z/4), then multiplies it by 4.

Template:Cd

Samples a noise at (z/4, x/4, 0), then multiplies it by 4.

Mathematical density functions

These density functions are used to perform mathematical operations.

Template:Cd

Calculates the absolute value of the input density function.

Template:Cd

Adds two density functions together.

Template:Cd

Rounds the input value to positive infinity.

Template:Cd

Clamps the input between two values.

Template:Cd

A constant value.

  • Template:Nbt: Root object.
    • Template:Nbt: The ID of the density function type (in this case, constant).
    • Template:Nbt: A constant value. Value between −1000000.0 and 1000000.0 (both inclusive).

Template:Cd

Cubes the input (x^3).

Template:Cd

Performs division between two arguments.

Template:Cd

Rounds the input value to negative infinity.

Template:Cd

Computes the natural logarithm of the given input.

Template:Cd

Multiplies two inputs.

Template:Cd

Returns the minimum of two inputs.

Template:Cd

Returns the maximum of two inputs.

Template:Cd

Negates the input.

Template:Cd

Raises the given base value to an exponent.

Template:Cd

Inverts the input (1/x).

Template:Cd

Rounds the input value to to the nearest integer (ties round up).

Template:Cd

Performs subtraction between two arguments.

Template:Cd

Computes the sign of the given input. If positive, it returns as 1. If the input is 0, it returns 0. If negative, it returns as -1.

Template:Cd

Computes the square root of the given input.

Template:Cd

Squares the input. (x^2)

Template:Cd

Rounds the input value to 0.

Mapped density functions

These density functions map a set of values onto another set of values.

Template:Cd

File:Gradient tiling.png
Demonstration of the different tiling options for the Template:Cd density function, using both an input range of -100 to 100 and an output range of -1 to 1.

Clamps the given coordinate and maps the gradient to a range.

Template:Cd

Performs (unclamped) linear interpolation between two arguments based on an alpha. The returned value is: first*(1-alpha) + second*alpha

Template:Cd

First clamps the input between −1 and 1, then transforms it using x/2 - x*x*x/24.

Template:Cd

Computes a cubic spline.

Conditional density functions

These density functions are used to apply "if-then" logic.

Template:Cd

If the input is negative, returns half of the input. Otherwise returns the input. (x < 0 ? x/2 : x)

Template:Cd

Selects between a number of density functions based on an input density function and a set of threshold values.

Template:Cd

If the input is negative, returns a quarter of the input. Otherwise returns the input. (x < 0 ? x/4 : x)

Template:Cd

Computes the input value, and depending on that result returns one of two other density functions. Basically an if-then-else statement.

Other density functions

Template:Cd

Adds beards for structures (see the terrain_adaptation field in structures). Its value is added to the final_density in noise setting by the game. Should not be referenced in data packs.

Template:Cd

Used in vanilla for smooth transition to chunks generated in old versions.Template:Info needed

Template:Cd

Used in vanilla for smooth transition to chunks generated in old versions.Template:Info needed

Template:Cd

Used in vanilla for smooth transition to chunks generated in old versions.Template:Info needed

Template:Cd

File:Distance to point options.png
Demonstration of the different metric options for the Template:Cd density function, using the distance from the point (0, 0).

Computes the distance to a fixed point using the specified distance function.

Template:Cd

Samples an input function by applying an offset to each sampled coordinate.Template:Upcoming

If the offsets change rapidly by a large amount, performance may degrade significantly. This function should be used sparingly.

Template:Cd

Samples at current position using a noise algorithm used for end islands. Its minimum value is −0.84375 and its maximum value is 0.5625.

Template:Cd

Scans through a column of an input density and returns the topmost y-level that is above 0. If no such position exists within the bounds, the Template:Nbt is returned.

Template:Cd

  • Template:Nbt: Root object.
    • Template:Nbt: The ID of the density function type (in this case, ore_vein).
    • Template:Nbt: The ore block to place.
    • Template:Nbt: The raw ore block to place.
    • Template:Nbt: The filler block to place.
    • Template:Nbt: The probability for a raw ore block to be placed instead of an ore block. Value between 0 and 1 (inclusive).
    • Template:Nbt: The probability for the ore vein to replace a block. If the value is 0 or lower, no block will be replaced.
    • Template:Nbt: The probability for an ore block or a raw ore block to be placed, as opposed to Template:Cd. If the value is 0 or lower, all blocks will be the filler block. If the value is 1 or greater, no blocks will be the filler block.
    • Template:Nbt: Overrides Template:Cd; if the value is positive, Template:Cd will always be placed.

Template:Cd

Removes a dimension from the input domain by taking a "slice" along an axis with a specific coordinate (e.g. with the axis equaling y and the coordinate of 0, a slice will be taken along the XZ plane, with all values sampled at y=0).

Removed density functions

Template:Outdated

Template:Cd

Removed in Minecraft:26.3-snap10

Only computes the input density once per horizontal position.

Template:Cd

Removed in Minecraft:26.3-snap10

Used by the game onto final_density and should not be referenced in data packs.

Template:Cd

Removed in Minecraft:26.3-snap10

Calculate the value per 4×4 column (Value at each block in one column is the same). And it is calculated only once per column, at Y=0. Used often in combination with interpolated.

Template:Cd

Removed in Minecraft:26.3-snap10

Similar to noise, but first shifts the input coordinates.

Template:Cd

Removed in Minecraft:22w12a

The legacy "spline"

Removed in Minecraft:22w11a

Template:Cd

Removed in Minecraft:22w11a

Calculate the spline from the noise settings.

Template:Cd

Removed in Minecraft:26.2-snap5

According to the input value, scales and enhances (or weakens) some regions of the specified noise, and then returns the absolute value.

Template:Cd

Removed in Minecraft:26.3-snap6

Clamps the Y coordinate between from_y and to_y and then linearly maps it to a range.

  • Template:Nbt: Root object.
    • Template:Nbt: The ID of the density function type (in this case, y_clamped_gradient).
    • Template:Nbt: The value to be mapped to from_value. Value between −4064 and 4062 (both inclusive).
    • Template:Nbt: The value to be mapped to to_value. Value between −4064 and 4062 (both inclusive).
    • Template:Nbt: The value to map from_y to. Value between −1000000.0 and 1000000.0 (both inclusive).
    • Template:Nbt: The value to map to_y to. Value between −1000000.0 and 1000000.0 (both inclusive).

History

Template:HistoryTable

Issues

Template:Issue list

External links

Navigation

Template:Navbox Java Edition technical

Minecraft:de:Dichtefunktion Minecraft:fr:Fonction de densité Minecraft:ko:밀도 함수 Minecraft:pt:Função de densidade Minecraft:zh:密度函数

Contents