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
|
||||
|
||||
local DEBUG = false
|
||||
local NETHER_DEPTH = -5000
|
||||
local TCAVE = 0.6
|
||||
local BLEND = 128
|
||||
local DEBUG = false
|
||||
|
||||
|
||||
-- 3D noise
|
||||
@ -284,11 +284,25 @@ local function get_timerPos_from_p1_and_p2(p1, p2)
|
||||
end
|
||||
|
||||
-- orientation is the rotation degrees passed to place_schematic: 0, 90, 180, or 270
|
||||
local function get_param2_from_orientation(param2, orientation)
|
||||
return orientation / 90
|
||||
-- color is a value from 0 to 7 corresponding to the pixels in portal_palette.png
|
||||
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
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
@ -336,7 +350,7 @@ local function set_portal_metadata(portal_definition, anchorPos, orientation, de
|
||||
-- they define the bounding volume for the portal.
|
||||
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 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
|
||||
|
||||
@ -863,7 +877,7 @@ function run_wormhole(pos, time_elapsed)
|
||||
minsize = 0.5,
|
||||
maxsize = 1.5,
|
||||
collisiondetection = false,
|
||||
texture = "nether_particle.png",
|
||||
texture = "nether_particle.png^[colorize:#808:alpha",
|
||||
glow = 5
|
||||
})
|
||||
end
|
||||
@ -975,7 +989,9 @@ minetest.register_node("nether:portal", {
|
||||
},
|
||||
drawtype = "nodebox",
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
paramtype2 = "colorfacedir",
|
||||
palette = "portal_palette.png",
|
||||
post_effect_color = {a = 180, r = 128, g = 0, b = 128},
|
||||
sunlight_propagates = true,
|
||||
use_texture_alpha = true,
|
||||
walkable = false,
|
||||
@ -985,7 +1001,6 @@ minetest.register_node("nether:portal", {
|
||||
is_ground_content = false,
|
||||
drop = "",
|
||||
light_source = 5,
|
||||
post_effect_color = {a = 180, r = 128, g = 0, b = 128},
|
||||
alpha = 192,
|
||||
node_box = {
|
||||
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