Some more fallback for legacy pipeline
This commit is contained in:
@@ -785,6 +785,7 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m
|
||||
m->DiffuseColor = video::SColor(255, 255, 255, 255);
|
||||
m->EmissiveColor = video::SColor(255, 255, 255, 255);
|
||||
m->SpecularColor = video::SColor(255, 255, 255, 255);
|
||||
m->MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
|
||||
}
|
||||
else if (m_shader_name == "alphatest")
|
||||
{
|
||||
|
||||
@@ -18,9 +18,11 @@
|
||||
#include "graphics/stk_texture.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "graphics/central_settings.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "graphics/graphics_restrictions.hpp"
|
||||
#include "graphics/stk_tex_manager.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "graphics/material.hpp"
|
||||
#include "graphics/material_manager.hpp"
|
||||
#include "modes/profile_world.hpp"
|
||||
#include "utils/log.hpp"
|
||||
#include "utils/string_utils.hpp"
|
||||
@@ -123,6 +125,7 @@ void STKTexture::reload(bool no_upload, uint8_t* preload_data,
|
||||
return;
|
||||
}
|
||||
orig_img = resizeImage(orig_img, &m_orig_size, &m_size);
|
||||
applyMask(orig_img);
|
||||
data = orig_img ? (uint8_t*)orig_img->lock() : NULL;
|
||||
}
|
||||
|
||||
@@ -279,6 +282,46 @@ video::IImage* STKTexture::resizeImage(video::IImage* orig_img,
|
||||
return image;
|
||||
} // resizeImage
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void STKTexture::applyMask(video::IImage* orig_img)
|
||||
{
|
||||
#ifndef SERVER_ONLY
|
||||
Material* material = NULL;
|
||||
if (material_manager)
|
||||
{
|
||||
material = material_manager->getMaterialFor(this);
|
||||
}
|
||||
if (material && !material->getAlphaMask().empty())
|
||||
{
|
||||
video::IImage* converted_mask = irr_driver->getVideoDriver()
|
||||
->createImageFromFile(material->getAlphaMask().c_str());
|
||||
if (converted_mask == NULL)
|
||||
{
|
||||
Log::warn("STKTexture", "Applying mask failed for '%s'!",
|
||||
material->getAlphaMask().c_str());
|
||||
return;
|
||||
}
|
||||
converted_mask = resizeImage(converted_mask);
|
||||
if (converted_mask->lock())
|
||||
{
|
||||
const core::dimension2du& dim = orig_img->getDimension();
|
||||
for (unsigned int x = 0; x < dim.Width; x++)
|
||||
{
|
||||
for (unsigned int y = 0; y < dim.Height; y++)
|
||||
{
|
||||
video::SColor col = orig_img->getPixel(x, y);
|
||||
video::SColor alpha = converted_mask->getPixel(x, y);
|
||||
col.setAlpha(alpha.getRed());
|
||||
orig_img->setPixel(x, y, col, false);
|
||||
} // for y
|
||||
} // for x
|
||||
}
|
||||
converted_mask->unlock();
|
||||
converted_mask->drop();
|
||||
}
|
||||
#endif // !SERVER_ONLY
|
||||
} // applyMask
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool STKTexture::hasMipMaps() const
|
||||
{
|
||||
|
||||
@@ -54,6 +54,9 @@ private:
|
||||
bool isSrgb() const;
|
||||
// ------------------------------------------------------------------------
|
||||
bool isPremulAlpha() const;
|
||||
// ------------------------------------------------------------------------
|
||||
void applyMask(video::IImage* orig_img);
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
public:
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user