Fix tiling issues for PLANTLIKE and FIRELIKE with FSAA

This commit is contained in:
RealBadAngel 2015-08-05 22:52:32 +02:00
parent 7a6e4dc54a
commit 3295f3c401
4 changed files with 35 additions and 9 deletions

View File

@ -168,6 +168,8 @@ enum MaterialType{
// defined by extra parameters // defined by extra parameters
#define MATERIAL_FLAG_ANIMATION_VERTICAL_FRAMES 0x08 #define MATERIAL_FLAG_ANIMATION_VERTICAL_FRAMES 0x08
#define MATERIAL_FLAG_HIGHLIGHTED 0x10 #define MATERIAL_FLAG_HIGHLIGHTED 0x10
#define MATERIAL_FLAG_TILEABLE_HORIZONTAL 0x20
#define MATERIAL_FLAG_TILEABLE_VERTICAL 0x40
/* /*
This fully defines the looks of a tile. This fully defines the looks of a tile.
@ -216,7 +218,9 @@ struct TileSpec
alpha == other.alpha && alpha == other.alpha &&
material_type == other.material_type && material_type == other.material_type &&
material_flags == other.material_flags && material_flags == other.material_flags &&
rotation == other.rotation rotation == other.rotation &&
(material_flags & MATERIAL_FLAG_TILEABLE_HORIZONTAL) &&
(material_flags & MATERIAL_FLAG_TILEABLE_VERTICAL)
); );
} }
@ -250,12 +254,26 @@ struct TileSpec
} }
material.BackfaceCulling = (material_flags & MATERIAL_FLAG_BACKFACE_CULLING) material.BackfaceCulling = (material_flags & MATERIAL_FLAG_BACKFACE_CULLING)
? true : false; ? true : false;
if (!(material_flags & MATERIAL_FLAG_TILEABLE_HORIZONTAL)) {
material.TextureLayer[0].TextureWrapU = video::ETC_CLAMP_TO_EDGE;
}
if (!(material_flags & MATERIAL_FLAG_TILEABLE_VERTICAL)) {
material.TextureLayer[0].TextureWrapV = video::ETC_CLAMP_TO_EDGE;
}
} }
void applyMaterialOptionsWithShaders(video::SMaterial &material) const void applyMaterialOptionsWithShaders(video::SMaterial &material) const
{ {
material.BackfaceCulling = (material_flags & MATERIAL_FLAG_BACKFACE_CULLING) material.BackfaceCulling = (material_flags & MATERIAL_FLAG_BACKFACE_CULLING)
? true : false; ? true : false;
if (!(material_flags & MATERIAL_FLAG_TILEABLE_HORIZONTAL)) {
material.TextureLayer[0].TextureWrapU = video::ETC_CLAMP_TO_EDGE;
material.TextureLayer[1].TextureWrapU = video::ETC_CLAMP_TO_EDGE;
}
if (!(material_flags & MATERIAL_FLAG_TILEABLE_VERTICAL)) {
material.TextureLayer[0].TextureWrapV = video::ETC_CLAMP_TO_EDGE;
material.TextureLayer[1].TextureWrapV = video::ETC_CLAMP_TO_EDGE;
}
} }
u32 texture_id; u32 texture_id;

View File

@ -1014,7 +1014,7 @@ void CNodeDefManager::fillTileAttribs(ITextureSource *tsrc, TileSpec *tile,
} }
tile->flags_texture = tsrc->getShaderFlagsTexture( tile->flags_texture = tsrc->getShaderFlagsTexture(
tile->normal_texture ? true : false, tile->normal_texture ? true : false,
tiledef->tileable_horizontal, tiledef->tileable_vertical); tiledef->tileable_vertical, tiledef->tileable_horizontal);
// Material flags // Material flags
tile->material_flags = 0; tile->material_flags = 0;
@ -1022,6 +1022,10 @@ void CNodeDefManager::fillTileAttribs(ITextureSource *tsrc, TileSpec *tile,
tile->material_flags |= MATERIAL_FLAG_BACKFACE_CULLING; tile->material_flags |= MATERIAL_FLAG_BACKFACE_CULLING;
if (tiledef->animation.type == TAT_VERTICAL_FRAMES) if (tiledef->animation.type == TAT_VERTICAL_FRAMES)
tile->material_flags |= MATERIAL_FLAG_ANIMATION_VERTICAL_FRAMES; tile->material_flags |= MATERIAL_FLAG_ANIMATION_VERTICAL_FRAMES;
if (tiledef->tileable_horizontal)
tile->material_flags |= MATERIAL_FLAG_TILEABLE_HORIZONTAL;
if (tiledef->tileable_vertical)
tile->material_flags |= MATERIAL_FLAG_TILEABLE_VERTICAL;
// Animation parameters // Animation parameters
int frame_count = 1; int frame_count = 1;

View File

@ -258,17 +258,20 @@ void push_object_properties(lua_State *L, ObjectProperties *prop)
} }
/******************************************************************************/ /******************************************************************************/
TileDef read_tiledef(lua_State *L, int index) TileDef read_tiledef(lua_State *L, int index, u8 drawtype)
{ {
if(index < 0) if(index < 0)
index = lua_gettop(L) + 1 + index; index = lua_gettop(L) + 1 + index;
TileDef tiledef; TileDef tiledef;
bool default_tiling = (drawtype == NDT_PLANTLIKE || drawtype == NDT_FIRELIKE)
? false : true;
// key at index -2 and value at index // key at index -2 and value at index
if(lua_isstring(L, index)){ if(lua_isstring(L, index)){
// "default_lava.png" // "default_lava.png"
tiledef.name = lua_tostring(L, index); tiledef.name = lua_tostring(L, index);
tiledef.tileable_vertical = default_tiling;
tiledef.tileable_horizontal = default_tiling;
} }
else if(lua_istable(L, index)) else if(lua_istable(L, index))
{ {
@ -279,9 +282,9 @@ TileDef read_tiledef(lua_State *L, int index)
tiledef.backface_culling = getboolfield_default( tiledef.backface_culling = getboolfield_default(
L, index, "backface_culling", true); L, index, "backface_culling", true);
tiledef.tileable_horizontal = getboolfield_default( tiledef.tileable_horizontal = getboolfield_default(
L, index, "tileable_horizontal", true); L, index, "tileable_horizontal", default_tiling);
tiledef.tileable_vertical = getboolfield_default( tiledef.tileable_vertical = getboolfield_default(
L, index, "tileable_vertical", true); L, index, "tileable_vertical", default_tiling);
// animation = {} // animation = {}
lua_getfield(L, index, "animation"); lua_getfield(L, index, "animation");
if(lua_istable(L, -1)){ if(lua_istable(L, -1)){
@ -357,7 +360,7 @@ ContentFeatures read_content_features(lua_State *L, int index)
int i = 0; int i = 0;
while(lua_next(L, table) != 0){ while(lua_next(L, table) != 0){
// Read tiledef from value // Read tiledef from value
f.tiledef[i] = read_tiledef(L, -1); f.tiledef[i] = read_tiledef(L, -1, f.drawtype);
// removes value, keeps key for next iteration // removes value, keeps key for next iteration
lua_pop(L, 1); lua_pop(L, 1);
i++; i++;
@ -392,7 +395,7 @@ ContentFeatures read_content_features(lua_State *L, int index)
int i = 0; int i = 0;
while(lua_next(L, table) != 0){ while(lua_next(L, table) != 0){
// Read tiledef from value // Read tiledef from value
f.tiledef_special[i] = read_tiledef(L, -1); f.tiledef_special[i] = read_tiledef(L, -1, f.drawtype);
// removes value, keeps key for next iteration // removes value, keeps key for next iteration
lua_pop(L, 1); lua_pop(L, 1);
i++; i++;

View File

@ -63,7 +63,8 @@ class Schematic;
ContentFeatures read_content_features (lua_State *L, int index); ContentFeatures read_content_features (lua_State *L, int index);
TileDef read_tiledef (lua_State *L, int index); TileDef read_tiledef (lua_State *L, int index,
u8 drawtype);
void read_soundspec (lua_State *L, int index, void read_soundspec (lua_State *L, int index,
SimpleSoundSpec &spec); SimpleSoundSpec &spec);
NodeBox read_nodebox (lua_State *L, int index); NodeBox read_nodebox (lua_State *L, int index);