Add better color settings
This commit is contained in:
parent
feddf7273f
commit
77645e6667
33
init.lua
33
init.lua
@ -1,22 +1,33 @@
|
||||
-- If true, the Perlin test nodes will support color
|
||||
-- (set to false in case of performance problems)
|
||||
local colorize_nodes = minetest.settings:get_bool("perlin_explorer_colorize", true)
|
||||
local COLORIZE_NODES = true
|
||||
|
||||
-- If true, will use the grayscale color palette.
|
||||
-- If false, will use the default colors.
|
||||
local grayscale_colors = minetest.settings:get_bool("perlin_explorer_grayscale", false)
|
||||
|
||||
-- The number of available test node colors is divided by this number.
|
||||
-- A number between 1 to 256
|
||||
-- * 1 = Full 256 palette.
|
||||
-- * 2 = 128 colors.
|
||||
-- * 4 = 64 colors.
|
||||
-- etc.
|
||||
-- Higher values lead to less colors but increased performance.
|
||||
-- The number of available test node colors.
|
||||
-- Higher values lead to worse performance but a coarse color scheme.
|
||||
-- This value is only used for performance reason, because Minetest
|
||||
-- has a sharp performance drop when there are many different node colors on screen.
|
||||
-- Consider removing this one when Minetest's performance problem has been solved.
|
||||
local COLOR_PRECISION = 4
|
||||
local color_count = tonumber(minetest.settings:get("perlin_explorer_color_count")) or 64
|
||||
local color_lookup = {
|
||||
[256] = 1, -- full color palette
|
||||
[128] = 2,
|
||||
[64] = 4,
|
||||
[32] = 8,
|
||||
[16] = 16,
|
||||
[8] = 32,
|
||||
[4] = 64,
|
||||
[2] = 128,
|
||||
[1] = 256,
|
||||
}
|
||||
-- This value is used for the calculation of the simplified color.
|
||||
local color_precision = color_lookup[color_count]
|
||||
if not color_precision then
|
||||
color_precision = 4 -- default: 64 colors
|
||||
end
|
||||
|
||||
-- Time to wait in seconds before checking and generating new nodes in autobuild mode.
|
||||
local AUTOBUILD_UPDATE_TIME = 0.1
|
||||
@ -271,7 +282,7 @@ end)
|
||||
|
||||
-- Test nodes to generate a map based on a perlin noise
|
||||
local paramtype2, palette
|
||||
if colorize_nodes then
|
||||
if COLORIZE_NODES then
|
||||
paramtype2 = "color"
|
||||
end
|
||||
if grayscale_colors then
|
||||
@ -625,7 +636,7 @@ local update_map = function(pos, noise, noiseparams, options, stats_mode)
|
||||
node_param2 = math.floor(math.abs(node_param2))
|
||||
node_param2 = math.max(0, math.min(255, node_param2))
|
||||
if node_param2 < 255 then
|
||||
node_param2 = node_param2 - (node_param2 % COLOR_PRECISION)
|
||||
node_param2 = node_param2 - (node_param2 % color_precision)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1,6 +1,10 @@
|
||||
# If enabled, generated nodes will be colorized.
|
||||
# Disable this if you have performance problems.
|
||||
perlin_explorer_colorize_nodes (Colorize nodes) bool true
|
||||
# Number of available colors to use per node color palette,
|
||||
# ignoring the special “extreme” colors (which are always used).
|
||||
# High values lead to a smoother color gradient but also might
|
||||
# cause performance issues when viewing many nodes.
|
||||
# Note you need to regenerate the nodes for this change to
|
||||
# take effect.
|
||||
perlin_explorer_color_count (Palette color count) enum 64 256,128,64,32,16,8,4,2,1
|
||||
|
||||
# If enabled, will use the grayscale color palette for the nodes.
|
||||
# If disabled, will use the default colors instead.
|
||||
|
Loading…
x
Reference in New Issue
Block a user