mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-22 17:18:39 +00:00
Rework use_texture_alpha to provide three opaque/clip/blend modes
The change that turns nodeboxes and meshes opaque when possible is kept, as is the compatibility code that warns modders to adjust their nodedefs.
This commit is contained in:
parent
edd8c3c664
commit
83229921e5
8 changed files with 164 additions and 66 deletions
|
@ -231,6 +231,14 @@ enum AlignStyle : u8 {
|
|||
ALIGN_STYLE_USER_DEFINED,
|
||||
};
|
||||
|
||||
enum AlphaMode : u8 {
|
||||
ALPHAMODE_BLEND,
|
||||
ALPHAMODE_CLIP,
|
||||
ALPHAMODE_OPAQUE,
|
||||
ALPHAMODE_LEGACY_COMPAT, /* means either opaque or clip */
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
Stand-alone definition of a TileSpec (basically a server-side TileSpec)
|
||||
*/
|
||||
|
@ -315,9 +323,7 @@ struct ContentFeatures
|
|||
// These will be drawn over the base tiles.
|
||||
TileDef tiledef_overlay[6];
|
||||
TileDef tiledef_special[CF_SPECIAL_COUNT]; // eg. flowing liquid
|
||||
// If 255, the node is opaque.
|
||||
// Otherwise it uses texture alpha.
|
||||
u8 alpha;
|
||||
AlphaMode alpha;
|
||||
// The color of the node.
|
||||
video::SColor color;
|
||||
std::string palette_name;
|
||||
|
@ -418,20 +424,27 @@ struct ContentFeatures
|
|||
void serialize(std::ostream &os, u16 protocol_version) const;
|
||||
void deSerialize(std::istream &is);
|
||||
|
||||
#ifndef SERVER
|
||||
/*
|
||||
* Checks if any tile texture has any transparent pixels.
|
||||
* Prints a warning and returns true if that is the case, false otherwise.
|
||||
* This is supposed to be used for use_texture_alpha backwards compatibility.
|
||||
*/
|
||||
bool textureAlphaCheck(ITextureSource *tsrc, const TileDef *tiles,
|
||||
int length);
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
Some handy methods
|
||||
*/
|
||||
void setDefaultAlphaMode()
|
||||
{
|
||||
switch (drawtype) {
|
||||
case NDT_NORMAL:
|
||||
case NDT_LIQUID:
|
||||
case NDT_FLOWINGLIQUID:
|
||||
alpha = ALPHAMODE_OPAQUE;
|
||||
break;
|
||||
case NDT_NODEBOX:
|
||||
case NDT_MESH:
|
||||
alpha = ALPHAMODE_LEGACY_COMPAT; // this should eventually be OPAQUE
|
||||
break;
|
||||
default:
|
||||
alpha = ALPHAMODE_CLIP;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool needsBackfaceCulling() const
|
||||
{
|
||||
switch (drawtype) {
|
||||
|
@ -465,6 +478,21 @@ struct ContentFeatures
|
|||
void updateTextures(ITextureSource *tsrc, IShaderSource *shdsrc,
|
||||
scene::IMeshManipulator *meshmanip, Client *client, const TextureSettings &tsettings);
|
||||
#endif
|
||||
|
||||
private:
|
||||
#ifndef SERVER
|
||||
/*
|
||||
* Checks if any tile texture has any transparent pixels.
|
||||
* Prints a warning and returns true if that is the case, false otherwise.
|
||||
* This is supposed to be used for use_texture_alpha backwards compatibility.
|
||||
*/
|
||||
bool textureAlphaCheck(ITextureSource *tsrc, const TileDef *tiles,
|
||||
int length);
|
||||
#endif
|
||||
|
||||
void setAlphaFromLegacy(u8 legacy_alpha);
|
||||
|
||||
u8 getAlphaForLegacy() const;
|
||||
};
|
||||
|
||||
/*!
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue