mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-16 18:01:40 +00:00
parent
2a96b31ffc
commit
81e08fc890
2 changed files with 22 additions and 9 deletions
|
@ -396,21 +396,26 @@ void Minimap::blitMinimapPixelsToImageRadar(video::IImage *map_image)
|
||||||
void Minimap::blitMinimapPixelsToImageSurface(
|
void Minimap::blitMinimapPixelsToImageSurface(
|
||||||
video::IImage *map_image, video::IImage *heightmap_image)
|
video::IImage *map_image, video::IImage *heightmap_image)
|
||||||
{
|
{
|
||||||
// This variable creation/destruction has a 1% cost on rendering minimap
|
assert(map_image && heightmap_image);
|
||||||
video::SColor tilecolor;
|
video::SColor tilecolor;
|
||||||
for (s16 x = 0; x < data->mode.map_size; x++)
|
for (s16 x = 0; x < data->mode.map_size; x++)
|
||||||
for (s16 z = 0; z < data->mode.map_size; z++) {
|
for (s16 z = 0; z < data->mode.map_size; z++) {
|
||||||
MinimapPixel *mmpixel = &data->minimap_scan[x + z * data->mode.map_size];
|
MinimapPixel *mmpixel = &data->minimap_scan[x + z * data->mode.map_size];
|
||||||
|
|
||||||
const ContentFeatures &f = m_ndef->get(mmpixel->n);
|
const ContentFeatures &f = m_ndef->get(mmpixel->n);
|
||||||
const TileDef *tile = &f.tiledef[0];
|
const auto &tile = f.tiledef[0], &overlay = f.tiledef_overlay[0];
|
||||||
|
|
||||||
// Color of the 0th tile (mostly this is the topmost)
|
// Figure out the color of the top of the node
|
||||||
if(tile->has_color)
|
// Note that this is very simplified. The overlay and normal tile can be
|
||||||
tilecolor = tile->color;
|
// colored independently and the overlay might only cover half or less.
|
||||||
else
|
if (!overlay.name.empty() && overlay.has_color) {
|
||||||
|
tilecolor = overlay.color;
|
||||||
|
} else if (overlay.name.empty() && tile.has_color) {
|
||||||
|
tilecolor = tile.color;
|
||||||
|
} else {
|
||||||
mmpixel->n.getColor(f, &tilecolor);
|
mmpixel->n.getColor(f, &tilecolor);
|
||||||
|
}
|
||||||
|
// Multiply with pre-generated "color of texture"
|
||||||
tilecolor.setRed(tilecolor.getRed() * f.minimap_color.getRed() / 255);
|
tilecolor.setRed(tilecolor.getRed() * f.minimap_color.getRed() / 255);
|
||||||
tilecolor.setGreen(tilecolor.getGreen() * f.minimap_color.getGreen() / 255);
|
tilecolor.setGreen(tilecolor.getGreen() * f.minimap_color.getGreen() / 255);
|
||||||
tilecolor.setBlue(tilecolor.getBlue() * f.minimap_color.getBlue() / 255);
|
tilecolor.setBlue(tilecolor.getBlue() * f.minimap_color.getBlue() / 255);
|
||||||
|
|
|
@ -907,8 +907,16 @@ void ContentFeatures::updateTextures(ITextureSource *tsrc, IShaderSource *shdsrc
|
||||||
u32 overlay_shader = shdsrc->getShader("nodes_shader", overlay_material, drawtype);
|
u32 overlay_shader = shdsrc->getShader("nodes_shader", overlay_material, drawtype);
|
||||||
|
|
||||||
// minimap pixel color = average color of top tile
|
// minimap pixel color = average color of top tile
|
||||||
if (tsettings.enable_minimap && !tdef[0].name.empty() && drawtype != NDT_AIRLIKE)
|
if (tsettings.enable_minimap && drawtype != NDT_AIRLIKE && !tdef[0].name.empty())
|
||||||
minimap_color = tsrc->getTextureAverageColor(tdef[0].name);
|
{
|
||||||
|
if (!tdef_overlay[0].name.empty()) {
|
||||||
|
// Merge overlay and base texture
|
||||||
|
std::string combined = tdef[0].name + "^(" + tdef_overlay[0].name + ")";
|
||||||
|
minimap_color = tsrc->getTextureAverageColor(combined);
|
||||||
|
} else {
|
||||||
|
minimap_color = tsrc->getTextureAverageColor(tdef[0].name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Tiles (fill in f->tiles[])
|
// Tiles (fill in f->tiles[])
|
||||||
bool any_polygon_offset = false;
|
bool any_polygon_offset = false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue