From 02292e03e42e5c3be0aa09a329dabd9c8dad5571 Mon Sep 17 00:00:00 2001 From: hecks <42101236+hecktest@users.noreply.github.com> Date: Wed, 13 Oct 2021 17:51:37 +0200 Subject: Add embedded PNG texture modifier (#11498) --- games/devtest/mods/testnodes/textures.lua | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'games/devtest/mods') diff --git a/games/devtest/mods/testnodes/textures.lua b/games/devtest/mods/testnodes/textures.lua index 4652007d9..dc581b0c7 100644 --- a/games/devtest/mods/testnodes/textures.lua +++ b/games/devtest/mods/testnodes/textures.lua @@ -102,12 +102,22 @@ local function gen_checkers(w, h, tile) end local fractal = mandelbrot(512, 512, 128) +local frac_emb = mandelbrot(64, 64, 64) local checker = gen_checkers(512, 512, 32) local floor = math.floor local abs = math.abs +local data_emb = {} local data_mb = {} local data_ck = {} +for i=1, #frac_emb do + data_emb[i] = { + r = floor(abs(frac_emb[i] * 2 - 1) * 255), + g = floor(abs(1 - frac_emb[i]) * 255), + b = floor(frac_emb[i] * 255), + a = frac_emb[i] < 0.95 and 255 or 0, + } +end for i=1, #fractal do data_mb[i] = { r = floor(fractal[i] * 255), @@ -140,3 +150,24 @@ minetest.register_node("testnodes:generated_png_ck", { groups = { dig_immediate = 2 }, }) + +local png_emb = "[png:" .. minetest.encode_base64(minetest.encode_png(64,64,data_emb)) + +minetest.register_node("testnodes:generated_png_emb", { + description = S("Generated In-Band Mandelbrot PNG Test Node"), + tiles = { png_emb }, + + groups = { dig_immediate = 2 }, +}) +minetest.register_node("testnodes:generated_png_src_emb", { + description = S("Generated In-Band Source Blit Mandelbrot PNG Test Node"), + tiles = { png_emb .. "^testnodes_damage_neg.png" }, + + groups = { dig_immediate = 2 }, +}) +minetest.register_node("testnodes:generated_png_dst_emb", { + description = S("Generated In-Band Dest Blit Mandelbrot PNG Test Node"), + tiles = { "testnodes_generated_ck.png^" .. png_emb }, + + groups = { dig_immediate = 2 }, +}) -- cgit v1.2.3