mirror of
https://github.com/minetest/minetest.git
synced 2024-12-24 15:12:23 +01:00
Fix tile MaterialType to make sense and make lava surface be shader'd lower like water
This commit is contained in:
parent
ca16119adb
commit
3e07c5bf82
@ -1081,15 +1081,11 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data):
|
|||||||
material.MaterialType
|
material.MaterialType
|
||||||
= video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
|
= video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
|
||||||
material.setTexture(0, p.tile.texture.atlas);
|
material.setTexture(0, p.tile.texture.atlas);
|
||||||
|
if(enable_shaders)
|
||||||
|
p.tile.applyMaterialOptionsWithShaders(material, shadermat1, shadermat2);
|
||||||
|
else
|
||||||
p.tile.applyMaterialOptions(material);
|
p.tile.applyMaterialOptions(material);
|
||||||
|
|
||||||
if(enable_shaders){
|
|
||||||
if(material.MaterialType == video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF)
|
|
||||||
material.MaterialType = shadermat1;
|
|
||||||
if(material.MaterialType == video::EMT_TRANSPARENT_VERTEX_ALPHA)
|
|
||||||
material.MaterialType = shadermat2;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create meshbuffer
|
// Create meshbuffer
|
||||||
|
|
||||||
// This is a "Standard MeshBuffer",
|
// This is a "Standard MeshBuffer",
|
||||||
|
@ -555,6 +555,7 @@ public:
|
|||||||
tiledef[j].name = "unknown_block.png";
|
tiledef[j].name = "unknown_block.png";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool is_liquid = false;
|
||||||
switch(f->drawtype){
|
switch(f->drawtype){
|
||||||
default:
|
default:
|
||||||
case NDT_NORMAL:
|
case NDT_NORMAL:
|
||||||
@ -573,12 +574,14 @@ public:
|
|||||||
f->solidness = 1;
|
f->solidness = 1;
|
||||||
f->backface_culling = false;
|
f->backface_culling = false;
|
||||||
}
|
}
|
||||||
|
is_liquid = true;
|
||||||
break;
|
break;
|
||||||
case NDT_FLOWINGLIQUID:
|
case NDT_FLOWINGLIQUID:
|
||||||
assert(f->liquid_type == LIQUID_FLOWING);
|
assert(f->liquid_type == LIQUID_FLOWING);
|
||||||
f->solidness = 0;
|
f->solidness = 0;
|
||||||
if(opaque_water)
|
if(opaque_water)
|
||||||
f->alpha = 255;
|
f->alpha = 255;
|
||||||
|
is_liquid = true;
|
||||||
break;
|
break;
|
||||||
case NDT_GLASSLIKE:
|
case NDT_GLASSLIKE:
|
||||||
f->solidness = 0;
|
f->solidness = 0;
|
||||||
@ -611,16 +614,24 @@ public:
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u8 material_type = 0;
|
||||||
|
if(is_liquid){
|
||||||
|
if(f->alpha == 255)
|
||||||
|
material_type = TILE_MATERIAL_LIQUID_OPAQUE;
|
||||||
|
else
|
||||||
|
material_type = TILE_MATERIAL_LIQUID_TRANSPARENT;
|
||||||
|
} else{
|
||||||
|
material_type = TILE_MATERIAL_BASIC;
|
||||||
|
}
|
||||||
|
|
||||||
// Tiles (fill in f->tiles[])
|
// Tiles (fill in f->tiles[])
|
||||||
for(u16 j=0; j<6; j++){
|
for(u16 j=0; j<6; j++){
|
||||||
// Texture
|
// Texture
|
||||||
f->tiles[j].texture = tsrc->getTexture(tiledef[j].name);
|
f->tiles[j].texture = tsrc->getTexture(tiledef[j].name);
|
||||||
// Alpha
|
// Alpha
|
||||||
f->tiles[j].alpha = f->alpha;
|
f->tiles[j].alpha = f->alpha;
|
||||||
if(f->alpha == 255)
|
// Material type
|
||||||
f->tiles[j].material_type = MATERIAL_ALPHA_SIMPLE;
|
f->tiles[j].material_type = material_type;
|
||||||
else
|
|
||||||
f->tiles[j].material_type = MATERIAL_ALPHA_VERTEX;
|
|
||||||
// Material flags
|
// Material flags
|
||||||
f->tiles[j].material_flags = 0;
|
f->tiles[j].material_flags = 0;
|
||||||
if(f->backface_culling)
|
if(f->backface_culling)
|
||||||
@ -661,10 +672,8 @@ public:
|
|||||||
tsrc->getTexture(f->tiledef_special[j].name);
|
tsrc->getTexture(f->tiledef_special[j].name);
|
||||||
// Alpha
|
// Alpha
|
||||||
f->special_tiles[j].alpha = f->alpha;
|
f->special_tiles[j].alpha = f->alpha;
|
||||||
if(f->alpha == 255)
|
// Material type
|
||||||
f->special_tiles[j].material_type = MATERIAL_ALPHA_SIMPLE;
|
f->special_tiles[j].material_type = material_type;
|
||||||
else
|
|
||||||
f->special_tiles[j].material_type = MATERIAL_ALPHA_VERTEX;
|
|
||||||
// Material flags
|
// Material flags
|
||||||
f->special_tiles[j].material_flags = 0;
|
f->special_tiles[j].material_flags = 0;
|
||||||
if(f->tiledef_special[j].backface_culling)
|
if(f->tiledef_special[j].backface_culling)
|
||||||
|
48
src/tile.h
48
src/tile.h
@ -161,10 +161,9 @@ public:
|
|||||||
IWritableTextureSource* createTextureSource(IrrlichtDevice *device);
|
IWritableTextureSource* createTextureSource(IrrlichtDevice *device);
|
||||||
|
|
||||||
enum MaterialType{
|
enum MaterialType{
|
||||||
MATERIAL_ALPHA_NONE,
|
TILE_MATERIAL_BASIC,
|
||||||
MATERIAL_ALPHA_VERTEX,
|
TILE_MATERIAL_LIQUID_TRANSPARENT,
|
||||||
MATERIAL_ALPHA_SIMPLE, // >127 = opaque
|
TILE_MATERIAL_LIQUID_OPAQUE,
|
||||||
MATERIAL_ALPHA_BLEND,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Material flags
|
// Material flags
|
||||||
@ -178,6 +177,8 @@ enum MaterialType{
|
|||||||
// Animation made up by splitting the texture to vertical frames, as
|
// Animation made up by splitting the texture to vertical frames, as
|
||||||
// defined by extra parameters
|
// defined by extra parameters
|
||||||
#define MATERIAL_FLAG_ANIMATION_VERTICAL_FRAMES 0x08
|
#define MATERIAL_FLAG_ANIMATION_VERTICAL_FRAMES 0x08
|
||||||
|
// Whether liquid shader should be used
|
||||||
|
#define MATERIAL_FLAG_
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This fully defines the looks of a tile.
|
This fully defines the looks of a tile.
|
||||||
@ -188,9 +189,7 @@ struct TileSpec
|
|||||||
TileSpec():
|
TileSpec():
|
||||||
texture(0),
|
texture(0),
|
||||||
alpha(255),
|
alpha(255),
|
||||||
//material_type(MATERIAL_ALPHA_NONE),
|
material_type(TILE_MATERIAL_BASIC),
|
||||||
// Use this so that leaves don't need a separate material
|
|
||||||
material_type(MATERIAL_ALPHA_SIMPLE),
|
|
||||||
material_flags(
|
material_flags(
|
||||||
//0 // <- DEBUG, Use the one below
|
//0 // <- DEBUG, Use the one below
|
||||||
MATERIAL_FLAG_BACKFACE_CULLING
|
MATERIAL_FLAG_BACKFACE_CULLING
|
||||||
@ -218,15 +217,34 @@ struct TileSpec
|
|||||||
// Sets everything else except the texture in the material
|
// Sets everything else except the texture in the material
|
||||||
void applyMaterialOptions(video::SMaterial &material) const
|
void applyMaterialOptions(video::SMaterial &material) const
|
||||||
{
|
{
|
||||||
if(material_type == MATERIAL_ALPHA_NONE)
|
switch(material_type){
|
||||||
material.MaterialType = video::EMT_SOLID;
|
case TILE_MATERIAL_BASIC:
|
||||||
else if(material_type == MATERIAL_ALPHA_VERTEX)
|
|
||||||
material.MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA;
|
|
||||||
else if(material_type == MATERIAL_ALPHA_SIMPLE)
|
|
||||||
material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
|
material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
|
||||||
else if(material_type == MATERIAL_ALPHA_BLEND)
|
break;
|
||||||
material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
|
case TILE_MATERIAL_LIQUID_TRANSPARENT:
|
||||||
|
material.MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA;
|
||||||
|
break;
|
||||||
|
case TILE_MATERIAL_LIQUID_OPAQUE:
|
||||||
|
material.MaterialType = video::EMT_SOLID;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
material.BackfaceCulling = (material_flags & MATERIAL_FLAG_BACKFACE_CULLING) ? true : false;
|
||||||
|
}
|
||||||
|
void applyMaterialOptionsWithShaders(video::SMaterial &material,
|
||||||
|
const video::E_MATERIAL_TYPE &basic,
|
||||||
|
const video::E_MATERIAL_TYPE &liquid) const
|
||||||
|
{
|
||||||
|
switch(material_type){
|
||||||
|
case TILE_MATERIAL_BASIC:
|
||||||
|
material.MaterialType = basic;
|
||||||
|
break;
|
||||||
|
case TILE_MATERIAL_LIQUID_TRANSPARENT:
|
||||||
|
material.MaterialType = liquid;
|
||||||
|
break;
|
||||||
|
case TILE_MATERIAL_LIQUID_OPAQUE:
|
||||||
|
material.MaterialType = liquid;
|
||||||
|
break;
|
||||||
|
}
|
||||||
material.BackfaceCulling = (material_flags & MATERIAL_FLAG_BACKFACE_CULLING) ? true : false;
|
material.BackfaceCulling = (material_flags & MATERIAL_FLAG_BACKFACE_CULLING) ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user