Skip to content

Commit 95d7348

Browse files
authored
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).
1 parent a19d003 commit 95d7348

File tree

5 files changed

+24
-2
lines changed

5 files changed

+24
-2
lines changed

doc/lua_api.md

+16-2
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,11 @@ to let the client generate textures on-the-fly.
490490
The modifiers are applied directly in sRGB colorspace,
491491
i.e. without gamma-correction.
492492

493+
### Notes
494+
495+
* `TEXMOD_UPSCALE`: The texture with the lower resolution will be automatically
496+
upscaled to the higher resolution texture.
497+
493498
### Texture overlaying
494499

495500
Textures can be overlaid by putting a `^` between them.
@@ -503,8 +508,9 @@ Example:
503508
default_dirt.png^default_grass_side.png
504509

505510
`default_grass_side.png` is overlaid over `default_dirt.png`.
506-
The texture with the lower resolution will be automatically upscaled to
507-
the higher resolution texture.
511+
512+
*See notes: `TEXMOD_UPSCALE`*
513+
508514

509515
### Texture grouping
510516

@@ -701,6 +707,8 @@ Apply a mask to the base image.
701707

702708
The mask is applied using binary AND.
703709

710+
*See notes: `TEXMOD_UPSCALE`*
711+
704712
#### `[sheet:<w>x<h>:<x>,<y>`
705713

706714
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
798806
textures swapped, see the `[hardlight` modifier description for more detail
799807
about these blend modes.
800808

809+
*See notes: `TEXMOD_UPSCALE`*
810+
801811
#### `[hardlight:<file>`
802812

803813
Applies a Hard light blend with the two textures, like the Hard light layer
@@ -813,6 +823,8 @@ increase contrast without clipping.
813823
Hard light is the same as Overlay but with the roles of the two textures
814824
swapped, i.e. `A.png^[hardlight:B.png` is the same as `B.png^[overlay:A.png`
815825

826+
*See notes: `TEXMOD_UPSCALE`*
827+
816828
#### `[png:<base64>`
817829

818830
Embed a base64 encoded PNG image in the texture string.
@@ -831,6 +843,8 @@ In particular consider `minetest.dynamic_add_media` and test whether
831843
using other texture modifiers could result in a shorter string than
832844
embedding a whole image, this may vary by use case.
833845

846+
*See notes: `TEXMOD_UPSCALE`*
847+
834848
Hardware coloring
835849
-----------------
836850

games/devtest/mods/testnodes/textures.lua

+6
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ minetest.register_node("testnodes:fill_positioning_reference", {
5252
groups = {dig_immediate = 3},
5353
})
5454

55+
minetest.register_node("testnodes:modifier_mask", {
56+
description = S("[mask Modifier Test Node"),
57+
tiles = {"testnodes_128x128_rgb.png^[mask:testnodes_mask_WRGBKW.png"},
58+
groups = {dig_immediate = 3},
59+
})
60+
5561
-- Node texture transparency test
5662

5763
local alphas = { 64, 128, 191 }
Loading
Loading

src/client/imagesource.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -1447,6 +1447,8 @@ bool ImageSource::generateImagePart(std::string_view part_of_name,
14471447

14481448
video::IImage *img = generateImage(filename, source_image_names);
14491449
if (img) {
1450+
upscaleImagesToMatchLargest(baseimg, img);
1451+
14501452
apply_mask(img, baseimg, v2s32(0, 0), v2s32(0, 0),
14511453
img->getDimension());
14521454
img->drop();

0 commit comments

Comments
 (0)