From 95d7348a08f3e2e0ca4bd75d7e9121a9c74de507 Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Fri, 4 Oct 2024 10:44:03 +0200 Subject: [PATCH] Client: upscale [mask or base image (#15205) This improves texture pack compatibility. Masks are expected to be of the same size as the base texture. This change upscales the smaller texture if needed. The behaviour is now the same as a.png^b.png and a.png^[overlay:b.png (to mention a few). --- doc/lua_api.md | 18 ++++++++++++++++-- games/devtest/mods/testnodes/textures.lua | 6 ++++++ .../textures/testnodes_128x128_rgb.png | Bin 0 -> 1870 bytes .../textures/testnodes_mask_WRGBKW.png | Bin 0 -> 148 bytes src/client/imagesource.cpp | 2 ++ 5 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 games/devtest/mods/testnodes/textures/testnodes_128x128_rgb.png create mode 100644 games/devtest/mods/testnodes/textures/testnodes_mask_WRGBKW.png diff --git a/doc/lua_api.md b/doc/lua_api.md index aeb903ae2f..57c99ef9df 100644 --- a/doc/lua_api.md +++ b/doc/lua_api.md @@ -490,6 +490,11 @@ to let the client generate textures on-the-fly. The modifiers are applied directly in sRGB colorspace, i.e. without gamma-correction. +### Notes + + * `TEXMOD_UPSCALE`: The texture with the lower resolution will be automatically + upscaled to the higher resolution texture. + ### Texture overlaying Textures can be overlaid by putting a `^` between them. @@ -503,8 +508,9 @@ Example: default_dirt.png^default_grass_side.png `default_grass_side.png` is overlaid over `default_dirt.png`. -The texture with the lower resolution will be automatically upscaled to -the higher resolution texture. + +*See notes: `TEXMOD_UPSCALE`* + ### Texture grouping @@ -701,6 +707,8 @@ Apply a mask to the base image. The mask is applied using binary AND. +*See notes: `TEXMOD_UPSCALE`* + #### `[sheet:x:,` Retrieves a tile at position x, y (in tiles, 0-indexed) @@ -798,6 +806,8 @@ in GIMP. Overlay is the same as Hard light but with the role of the two textures swapped, see the `[hardlight` modifier description for more detail about these blend modes. +*See notes: `TEXMOD_UPSCALE`* + #### `[hardlight:` Applies a Hard light blend with the two textures, like the Hard light layer @@ -813,6 +823,8 @@ increase contrast without clipping. Hard light is the same as Overlay but with the roles of the two textures swapped, i.e. `A.png^[hardlight:B.png` is the same as `B.png^[overlay:A.png` +*See notes: `TEXMOD_UPSCALE`* + #### `[png:` Embed a base64 encoded PNG image in the texture string. @@ -831,6 +843,8 @@ In particular consider `minetest.dynamic_add_media` and test whether using other texture modifiers could result in a shorter string than embedding a whole image, this may vary by use case. +*See notes: `TEXMOD_UPSCALE`* + Hardware coloring ----------------- diff --git a/games/devtest/mods/testnodes/textures.lua b/games/devtest/mods/testnodes/textures.lua index 96f291d6a8..b95fbd62e1 100644 --- a/games/devtest/mods/testnodes/textures.lua +++ b/games/devtest/mods/testnodes/textures.lua @@ -52,6 +52,12 @@ minetest.register_node("testnodes:fill_positioning_reference", { groups = {dig_immediate = 3}, }) +minetest.register_node("testnodes:modifier_mask", { + description = S("[mask Modifier Test Node"), + tiles = {"testnodes_128x128_rgb.png^[mask:testnodes_mask_WRGBKW.png"}, + groups = {dig_immediate = 3}, +}) + -- Node texture transparency test local alphas = { 64, 128, 191 } diff --git a/games/devtest/mods/testnodes/textures/testnodes_128x128_rgb.png b/games/devtest/mods/testnodes/textures/testnodes_128x128_rgb.png new file mode 100644 index 0000000000000000000000000000000000000000..060d8e67afc011f33683d706c56a1f13466ca67d GIT binary patch literal 1870 zcmV-U2eJ5xP)p|yj{wfht=m6#=n24OG&2Gu z{D4#yo0%0zL%%vz#e?s=%fB6ijN{c{oBh(OEdpjH25Rq?pZ9=wr>P{=#Kz>#4u>+rNp?IiGhZW{%8b@CI(btN)XVO7)a4CR)Tg+|b_AW(kwZDCSTe!~;LFRJiJ~vSn&oIqQ#;rt&0ri@;5F{Ou zNcHFgsUu;zRF%$}Fr8H}PC%wh8)783pzM5Y9Pday0%}uLoW>?XKwhefH^Pn^5V9sh zK#CY>HbI6jIvN>3&$eekiv!ww{mJozHdzRo z2LYIAGesm10ht2aRco`+;!&HbE{$}tIlcq5fZLgKd}*-3V=iREE z(Su*asK4VYBZgrdKx4g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wpi4ah*vAmgQd%*1h1ougg?4?f3J~jDrTj>@#HHQr` zvo_OD!nclBga=x3`!8tY3LOa!*B!)7%PRd$oy8FlFS48CIEvem`p%rv&*Zrq z0_Hnxmk{*&h;dv6C-F13Bf^~OaIY#=ZA!uu4}G^(wOt7Mwxdz1+Jb}$zVv9v0W0PV zBL=De6Mn?dw;%?Qr3#*V2oS>!1keK=U!E9h5wM0{h8TYS2THf<#Ze@*iU0rr07*qo IM6N<$f(DOnVE_OC literal 0 HcmV?d00001 diff --git a/games/devtest/mods/testnodes/textures/testnodes_mask_WRGBKW.png b/games/devtest/mods/testnodes/textures/testnodes_mask_WRGBKW.png new file mode 100644 index 0000000000000000000000000000000000000000..03ab71e3fbcc32f2cfb00d253b45f7d53788d5cb GIT binary patch literal 148 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPHV5AX?b1=0)*|G|*q|Ns9v6}uM# z1sptG978ywlM5P|*u;|!3K9#-f|!^@h1t?Y9Tf_gj6`H5BqCZIc*NM)*bSN)SF{Q+ muaj6No2PJwYsXT9bOwfhwW5w)BBrlErhB^jxvXgetDimension()); img->drop();