mirror of
https://github.com/minetest-mods/nether.git
synced 2024-12-27 19:30:28 +01:00
Dynamic/hardware portal colouring
Currently proof of concept: Removes wormhole colour from .png texture and specifies it through MT API instead. The post_effect_color may call for registering a separate node per portal colour. Palette 0 will have to be the traditional portal magenta (instead of 0 being black) for map compatibility with mod when colour was in the texture and not param2.
This commit is contained in:
parent
83c9ad574f
commit
3126d067a1
29
init.lua
29
init.lua
@ -22,10 +22,10 @@
|
|||||||
|
|
||||||
-- Parameters
|
-- Parameters
|
||||||
|
|
||||||
|
local DEBUG = false
|
||||||
local NETHER_DEPTH = -5000
|
local NETHER_DEPTH = -5000
|
||||||
local TCAVE = 0.6
|
local TCAVE = 0.6
|
||||||
local BLEND = 128
|
local BLEND = 128
|
||||||
local DEBUG = false
|
|
||||||
|
|
||||||
|
|
||||||
-- 3D noise
|
-- 3D noise
|
||||||
@ -284,11 +284,25 @@ local function get_timerPos_from_p1_and_p2(p1, p2)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- orientation is the rotation degrees passed to place_schematic: 0, 90, 180, or 270
|
-- orientation is the rotation degrees passed to place_schematic: 0, 90, 180, or 270
|
||||||
local function get_param2_from_orientation(param2, orientation)
|
-- color is a value from 0 to 7 corresponding to the pixels in portal_palette.png
|
||||||
return orientation / 90
|
local function get_param2_from_color_and_orientation(color, orientation)
|
||||||
|
assert(orientation, "no orientation passed")
|
||||||
|
|
||||||
|
-- wormhole nodes have a paramtype2 of colorfacedir, which means the
|
||||||
|
-- high 3 bits are palette, followed by 3 direction bits and 2 rotation bits.
|
||||||
|
-- We set the palette bits and rotation
|
||||||
|
return (orientation / 90) + color * 32
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_orientation_from_param2(param2)
|
local function get_orientation_from_param2(param2)
|
||||||
|
-- Strip off the top 6 bits, unfortunately MT lua has no bitwise '&'
|
||||||
|
-- (high 3 bits are palette, followed by 3 direction bits then 2 rotation bits)
|
||||||
|
if param2 >= 128 then param2 = param2 - 128 end
|
||||||
|
if param2 >= 64 then param2 = param2 - 64 end
|
||||||
|
if param2 >= 32 then param2 = param2 - 32 end
|
||||||
|
if param2 >= 16 then param2 = param2 - 16 end
|
||||||
|
if param2 >= 8 then param2 = param2 - 8 end
|
||||||
|
|
||||||
return param2 * 90
|
return param2 * 90
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -336,7 +350,7 @@ local function set_portal_metadata(portal_definition, anchorPos, orientation, de
|
|||||||
-- they define the bounding volume for the portal.
|
-- they define the bounding volume for the portal.
|
||||||
local p1, p2 = portal_definition.shape:get_p1_and_p2_from_anchorPos(anchorPos, orientation)
|
local p1, p2 = portal_definition.shape:get_p1_and_p2_from_anchorPos(anchorPos, orientation)
|
||||||
local p1_string, p2_string = minetest.pos_to_string(p1), minetest.pos_to_string(p2)
|
local p1_string, p2_string = minetest.pos_to_string(p1), minetest.pos_to_string(p2)
|
||||||
local param2 = get_param2_from_orientation(0, orientation)
|
local param2 = get_param2_from_color_and_orientation(portal_definition.wormhole_node_color, orientation)
|
||||||
|
|
||||||
local update_aborted-- using closures to allow the updateFunc to return extra information - by setting this variable
|
local update_aborted-- using closures to allow the updateFunc to return extra information - by setting this variable
|
||||||
|
|
||||||
@ -863,7 +877,7 @@ function run_wormhole(pos, time_elapsed)
|
|||||||
minsize = 0.5,
|
minsize = 0.5,
|
||||||
maxsize = 1.5,
|
maxsize = 1.5,
|
||||||
collisiondetection = false,
|
collisiondetection = false,
|
||||||
texture = "nether_particle.png",
|
texture = "nether_particle.png^[colorize:#808:alpha",
|
||||||
glow = 5
|
glow = 5
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
@ -975,7 +989,9 @@ minetest.register_node("nether:portal", {
|
|||||||
},
|
},
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "colorfacedir",
|
||||||
|
palette = "portal_palette.png",
|
||||||
|
post_effect_color = {a = 180, r = 128, g = 0, b = 128},
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
use_texture_alpha = true,
|
use_texture_alpha = true,
|
||||||
walkable = false,
|
walkable = false,
|
||||||
@ -985,7 +1001,6 @@ minetest.register_node("nether:portal", {
|
|||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
drop = "",
|
drop = "",
|
||||||
light_source = 5,
|
light_source = 5,
|
||||||
post_effect_color = {a = 180, r = 128, g = 0, b = 128},
|
|
||||||
alpha = 192,
|
alpha = 192,
|
||||||
node_box = {
|
node_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 226 B After Width: | Height: | Size: 149 B |
Binary file not shown.
Before Width: | Height: | Size: 382 B After Width: | Height: | Size: 282 B |
BIN
textures/portal_palette.png
Normal file
BIN
textures/portal_palette.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 875 B |
Loading…
Reference in New Issue
Block a user