Add absvalue support for heat and humidity noises

This commit is contained in:
Wuzzy 2024-12-07 15:53:34 +01:00
parent 3bd107f72d
commit 71401a207f
3 changed files with 40 additions and 17 deletions

View File

@ -173,6 +173,9 @@ A Voronoi diagram is supposed to be here but for some reason it cannot be displa
<label for="inputNoiseHeatPersistence">Persistence:&nbsp;</label>
<input id="inputNoiseHeatPersistence" class="numInput" type="number" value="0.5" step=0.01>
<input id="inputNoiseHeatAbsvalue" type="checkbox">
<label for="inputNoiseHeatAbsvalue">absvalue</label>
<h3>Humidity (<code id="noiseSettingNameHumidity">mg_biome_np_humidity</code>)</h3>
<label for="inputNoiseHumidityOffset">Offset:&nbsp;</label>
<input id="inputNoiseHumidityOffset" class="numInput" type="number" value="50" step=0.01>
@ -186,6 +189,9 @@ A Voronoi diagram is supposed to be here but for some reason it cannot be displa
<label for="inputNoiseHumidityPersistence">Persistence:&nbsp;</label>
<input id="inputNoiseHumidityPersistence" class="numInput" type="number" value="0.5" step=0.01>
<input id="inputNoiseHumidityAbsvalue" type="checkbox">
<label for="inputNoiseHumidityAbsvalue">absvalue</label>
<h3>Reset</h3>
<button id="inputNoiseReset" type="button">Reset noise parameters</button>
</form>

View File

@ -1476,10 +1476,12 @@ function updateWidgetStates() {
inputNoiseHeatScale.value = noises.heat.scale;
inputNoiseHeatOctaves.value = noises.heat.octaves;
inputNoiseHeatPersistence.value = noises.heat.persistence;
inputNoiseHeatAbsvalue.checked = noises.heat.absvalue;
inputNoiseHumidityOffset.value = noises.humidity.offset;
inputNoiseHumidityScale.value = noises.humidity.scale;
inputNoiseHumidityOctaves.value = noises.humidity.octaves;
inputNoiseHumidityPersistence.value = noises.humidity.persistence;
inputNoiseHumidityAbsvalue.checked = noises.humidity.absvalue;
if (v6_flag_snowbiomes) {
inputV6FreqDesert.disabled = true;
@ -2206,26 +2208,41 @@ function blurNoiseParam(noiseName, noiseValueName, element, defaultValue) {
draw(true);
}
}
function updateNoiseParamCheckbox(noiseName, noiseValueName, element) {
let val = element.checked;
noises[noiseName][noiseValueName] = val;
clear();
updateAreaVars();
draw(true);
}
let noiseWidgetTable = [
{ elem: inputNoiseHeatScale, noise: "heat", noise_param: "scale", default_modern: NOISE_SCALE_DEFAULT, default_v6: NOISE_V6_HEAT_SCALE_DEFAULT },
{ elem: inputNoiseHeatOffset, noise: "heat", noise_param: "offset", default_modern: NOISE_OFFSET_DEFAULT, default_v6: NOISE_V6_HEAT_OFFSET_DEFAULT },
{ elem: inputNoiseHeatOctaves, noise: "heat", noise_param: "octaves", default_modern: NOISE_OCTAVES_DEFAULT, default_v6: NOISE_V6_HEAT_OCTAVES_DEFAULT },
{ elem: inputNoiseHeatPersistence, noise: "heat", noise_param: "persistence", default_modern: NOISE_PERSISTENCE_DEFAULT, default_v6: NOISE_V6_HEAT_PERSISTENCE_DEFAULT },
{ elem: inputNoiseHumidityScale, noise: "humidity", noise_param: "scale", default_modern: NOISE_SCALE_DEFAULT, default_v6: NOISE_V6_HUMIDITY_SCALE_DEFAULT },
{ elem: inputNoiseHumidityOffset, noise: "humidity", noise_param: "offset", default_modern: NOISE_OFFSET_DEFAULT, default_v6: NOISE_V6_HUMIDITY_OFFSET_DEFAULT },
{ elem: inputNoiseHumidityOctaves, noise: "humidity", noise_param: "octaves", default_modern: NOISE_OCTAVES_DEFAULT, default_v6: NOISE_V6_HUMIDITY_OCTAVES_DEFAULT },
{ elem: inputNoiseHumidityPersistence, noise: "humidity", noise_param: "persistence", default_modern: NOISE_PERSISTENCE_DEFAULT, default_v6: NOISE_V6_HUMIDITY_PERSISTENCE_DEFAULT },
{ elem: inputNoiseHeatScale, type: "input", noise: "heat", noise_param: "scale", default_modern: NOISE_SCALE_DEFAULT, default_v6: NOISE_V6_HEAT_SCALE_DEFAULT },
{ elem: inputNoiseHeatOffset, type: "input", noise: "heat", noise_param: "offset", default_modern: NOISE_OFFSET_DEFAULT, default_v6: NOISE_V6_HEAT_OFFSET_DEFAULT },
{ elem: inputNoiseHeatOctaves, type: "input", noise: "heat", noise_param: "octaves", default_modern: NOISE_OCTAVES_DEFAULT, default_v6: NOISE_V6_HEAT_OCTAVES_DEFAULT },
{ elem: inputNoiseHeatPersistence, type: "input", noise: "heat", noise_param: "persistence", default_modern: NOISE_PERSISTENCE_DEFAULT, default_v6: NOISE_V6_HEAT_PERSISTENCE_DEFAULT },
{ elem: inputNoiseHeatAbsvalue, type: "checkbox", noise: "heat", noise_param: "absvalue", default_modern: NOISE_ABSVALUE_DEFAULT, default_v6: NOISE_V6_HEAT_ABSVALUE_DEFAULT },
{ elem: inputNoiseHumidityScale, type: "input", noise: "humidity", noise_param: "scale", default_modern: NOISE_SCALE_DEFAULT, default_v6: NOISE_V6_HUMIDITY_SCALE_DEFAULT },
{ elem: inputNoiseHumidityOffset, type: "input", noise: "humidity", noise_param: "offset", default_modern: NOISE_OFFSET_DEFAULT, default_v6: NOISE_V6_HUMIDITY_OFFSET_DEFAULT },
{ elem: inputNoiseHumidityOctaves, type: "input", noise: "humidity", noise_param: "octaves", default_modern: NOISE_OCTAVES_DEFAULT, default_v6: NOISE_V6_HUMIDITY_OCTAVES_DEFAULT },
{ elem: inputNoiseHumidityPersistence, type: "input", noise: "humidity", noise_param: "persistence", default_modern: NOISE_PERSISTENCE_DEFAULT, default_v6: NOISE_V6_HUMIDITY_PERSISTENCE_DEFAULT },
{ elem: inputNoiseHumidityAbsvalue, type: "checkbox", noise: "humidity", noise_param: "absvalue", default_modern: NOISE_ABSVALUE_DEFAULT, default_v6: NOISE_V6_HUMIDITY_ABSVALUE_DEFAULT },
]
for (let n of noiseWidgetTable) {
n.elem.oninput = function() {
updateNoiseParam(n.noise, n.noise_param, this);
}
n.elem.onblur = function() {
let noiseElem = n.noise + "_" + biomeMode;
let defaultValue = n[DEFAULT_BIOME_NAME + "_" + biomeMode];
blurNoiseParam(n.noise, n.noise_param, this, defaultValue);
if (n.type === "input") {
n.elem.oninput = function() {
updateNoiseParam(n.noise, n.noise_param, this);
}
n.elem.onblur = function() {
let noiseElem = n.noise + "_" + biomeMode;
let defaultValue = n[DEFAULT_BIOME_NAME + "_" + biomeMode];
blurNoiseParam(n.noise, n.noise_param, this, defaultValue);
}
} else if (n.type === "checkbox") {
n.elem.onchange = function() {
updateNoiseParamCheckbox(n.noise, n.noise_param, this);
}
}
}
@ -2260,11 +2277,13 @@ inputNoiseReset.onclick = function() {
inputNoiseHeatScale.value = noises.heat.scale;
inputNoiseHeatOctaves.value = noises.heat.octaves;
inputNoiseHeatPersistence.value = noises.heat.persistence;
inputNoiseHeatAbsvalue.checked = noises.heat.absvalue;
inputNoiseHumidityOffset.value = noises.humidity.offset;
inputNoiseHumidityScale.value = noises.humidity.scale;
inputNoiseHumidityOctaves.value = noises.humidity.octaves;
inputNoiseHumidityPersistence.value = noises.humidity.persistence;
inputNoiseHumidityAbsvalue.checked = noises.humidity.absvalue;
clear();
updateAreaVars();

View File

@ -147,8 +147,6 @@
<p>Heat/humidity <b>values above 1,000,000 or below &minus;1,000,000</b> are <b>not supported</b> and will trigger an error message. This is a much smaller range than what Luanti supports. Also, no diagram can be drawn if the heat or humidity noise scale equals 0 or is very small, although this is legal in Luanti. This does not mean that your chosen settings wont work in Luanti, just that LiBPoV cant visualize them.</p>
<p>LiBPoV assumes that the <code>absvalue</code> flag of the heat/humidity noises is always <code>false</code>. So if your game/mod has set it to true, the diagram may still show a value range that is actually impossible.</p>
<h2>Credits / License</h2>
<p>LiBPoV is <b>free software</b>. See the <a href="./license.html">License</a> page for details.</p>