aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/defaultsettings.cpp9
-rw-r--r--src/game.cpp57
-rw-r--r--src/itemdef.cpp11
-rw-r--r--src/mapblock_mesh.cpp61
-rw-r--r--src/nodedef.cpp13
-rw-r--r--src/nodedef.h2
-rw-r--r--src/script/common/c_content.cpp3
-rw-r--r--src/tile.h18
8 files changed, 131 insertions, 43 deletions
diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp
index df7570b33..68350bec0 100644
--- a/src/defaultsettings.cpp
+++ b/src/defaultsettings.cpp
@@ -126,6 +126,15 @@ void set_default_settings(Settings *settings)
settings->setDefault("trilinear_filter", "false");
settings->setDefault("preload_item_visuals", "true");
settings->setDefault("enable_bumpmapping", "false");
+ settings->setDefault("enable_parallax_occlusion", "false");
+ settings->setDefault("parallax_occlusion_scale", "0.08");
+ settings->setDefault("parallax_occlusion_bias", "0.04");
+ settings->setDefault("enable_waving_water", "false");
+ settings->setDefault("water_wave_height", "1.0");
+ settings->setDefault("water_wave_length", "20.0");
+ settings->setDefault("water_wave_speed", "5.0");
+ settings->setDefault("enable_waving_leaves", "false");
+ settings->setDefault("enable_waving_plants", "false");
settings->setDefault("enable_shaders", "true");
settings->setDefault("repeat_rightclick_time", "0.25");
settings->setDefault("enable_particles", "true");
diff --git a/src/game.cpp b/src/game.cpp
index 71a578a65..22abe4c74 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -805,13 +805,64 @@ public:
float daynight_ratio_f = (float)daynight_ratio / 1000.0;
services->setPixelShaderConstant("dayNightRatio", &daynight_ratio_f, 1);
+ u32 animation_timer = porting::getTimeMs() % 100000;
+ float animation_timer_f = (float)animation_timer / 100000.0;
+ services->setPixelShaderConstant("animationTimer", &animation_timer_f, 1);
+ services->setVertexShaderConstant("animationTimer", &animation_timer_f, 1);
+
+ LocalPlayer* player = m_client->getEnv().getLocalPlayer();
+ v3f eye_position = player->getEyePosition();
+ services->setPixelShaderConstant("eyePosition", (irr::f32*)&eye_position, 3);
+ services->setVertexShaderConstant("eyePosition", (irr::f32*)&eye_position, 3);
+
+ float enable_bumpmapping = 0;
+ if (g_settings->getBool("enable_bumpmapping"))
+ enable_bumpmapping = 1;
+ services->setPixelShaderConstant("enableBumpmapping", &enable_bumpmapping, 1);
+
+ float enable_parallax_occlusion = 0;
+ if (g_settings->getBool("enable_parallax_occlusion"));{
+ enable_parallax_occlusion = 1;
+ float parallax_occlusion_scale = g_settings->getFloat("parallax_occlusion_scale");
+ services->setPixelShaderConstant("parallaxOcclusionScale", &parallax_occlusion_scale, 1);
+ float parallax_occlusion_bias = g_settings->getFloat("parallax_occlusion_bias");
+ services->setPixelShaderConstant("parallaxOcclusionBias", &parallax_occlusion_bias, 1);
+ }
+ services->setPixelShaderConstant("enableParallaxOcclusion", &enable_parallax_occlusion, 1);
+
+ float enable_waving_water = 0;
+ if (g_settings->getBool("enable_waving_water")){
+ enable_waving_water = 1;
+ float water_wave_height_f = g_settings->getFloat("water_wave_height");
+ services->setVertexShaderConstant("waterWaveHeight", &water_wave_height_f, 1);
+ float water_wave_length_f = g_settings->getFloat("water_wave_length");
+ services->setVertexShaderConstant("waterWaveLength", &water_wave_length_f, 1);
+ float water_wave_speed_f = g_settings->getFloat("water_wave_speed");
+ services->setVertexShaderConstant("waterWaveSpeed", &water_wave_speed_f, 1);
+ }
+ services->setVertexShaderConstant("enableWavingWater", &enable_waving_water, 1);
+
+ float enable_waving_leaves = 0;
+ if (g_settings->getBool("enable_waving_leaves"))
+ enable_waving_leaves = 1;
+ services->setVertexShaderConstant("enableWavingLeaves", &enable_waving_leaves, 1);
+
+ float enable_waving_plants = 0;
+ if (g_settings->getBool("enable_waving_plants"))
+ enable_waving_plants = 1;
+ services->setVertexShaderConstant("enableWavingPlants", &enable_waving_plants, 1);
+
+
// Normal map texture layer
- int layer = 1;
+ int layer1 = 1;
+ int layer2 = 2;
// before 1.8 there isn't a "integer interface", only float
#if (IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR < 8)
- services->setPixelShaderConstant("normalTexture" , (irr::f32*)&layer, 1);
+ services->setPixelShaderConstant("normalTexture" , (irr::f32*)&layer1, 1);
+ services->setPixelShaderConstant("useNormalmap" , (irr::f32*)&layer2, 1);
#else
- services->setPixelShaderConstant("normalTexture" , (irr::s32*)&layer, 1);
+ services->setPixelShaderConstant("normalTexture" , (irr::s32*)&layer1, 1);
+ services->setPixelShaderConstant("useNormalmap" , (irr::s32*)&layer2, 1);
#endif
}
};
diff --git a/src/itemdef.cpp b/src/itemdef.cpp
index d34d68582..f77a198b5 100644
--- a/src/itemdef.cpp
+++ b/src/itemdef.cpp
@@ -390,16 +390,18 @@ public:
/*
Make a mesh from the node
*/
+ bool reenable_shaders = false;
+ if(g_settings->getBool("enable_shaders")){
+ reenable_shaders = true;
+ g_settings->setBool("enable_shaders",false);
+ }
MeshMakeData mesh_make_data(gamedef);
MapNode mesh_make_node(id, param1, 0);
mesh_make_data.fillSingleNode(&mesh_make_node);
MapBlockMesh mapblock_mesh(&mesh_make_data);
-
scene::IMesh *node_mesh = mapblock_mesh.getMesh();
assert(node_mesh);
video::SColor c(255, 255, 255, 255);
- if(g_settings->getBool("enable_shaders"))
- c = MapBlock_LightColor(255, 0xffff, decode_light(f.light_source));
setMeshColor(node_mesh, c);
/*
@@ -455,6 +457,9 @@ public:
//no way reference count can be smaller than 2 in this place!
assert(cc->wield_mesh->getReferenceCount() >= 2);
+
+ if (reenable_shaders)
+ g_settings->setBool("enable_shaders",true);
}
// Put in cache
diff --git a/src/mapblock_mesh.cpp b/src/mapblock_mesh.cpp
index 253703ddc..81aac72d7 100644
--- a/src/mapblock_mesh.cpp
+++ b/src/mapblock_mesh.cpp
@@ -1112,18 +1112,18 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data):
bool enable_shaders = g_settings->getBool("enable_shaders");
bool enable_bumpmapping = g_settings->getBool("enable_bumpmapping");
- video::E_MATERIAL_TYPE shadermat1, shadermat2, shadermat3, bumpmaps1, bumpmaps2;
- shadermat1 = shadermat2 = shadermat3 = bumpmaps1 = bumpmaps2 = video::EMT_SOLID;
+ video::E_MATERIAL_TYPE shadermat1, shadermat2, shadermat3,
+ shadermat4, shadermat5;
+ shadermat1 = shadermat2 = shadermat3 = shadermat4 = shadermat5 =
+ video::EMT_SOLID;
if (enable_shaders) {
IShaderSource *shdrsrc = m_gamedef->getShaderSource();
- shadermat1 = shdrsrc->getShader("test_shader_1").material;
- shadermat2 = shdrsrc->getShader("test_shader_2").material;
- shadermat3 = shdrsrc->getShader("test_shader_3").material;
- if (enable_bumpmapping) {
- bumpmaps1 = shdrsrc->getShader("bumpmaps_solids").material;
- bumpmaps2 = shdrsrc->getShader("bumpmaps_liquids").material;
- }
+ shadermat1 = shdrsrc->getShader("solids_shader").material;
+ shadermat2 = shdrsrc->getShader("liquids_shader").material;
+ shadermat3 = shdrsrc->getShader("alpha_shader").material;
+ shadermat4 = shdrsrc->getShader("leaves_shader").material;
+ shadermat5 = shdrsrc->getShader("plants_shader").material;
}
for(u32 i = 0; i < collector.prebuffers.size(); i++)
@@ -1204,22 +1204,18 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data):
material.setFlag(video::EMF_FOG_ENABLE, true);
//material.setFlag(video::EMF_ANTI_ALIASING, video::EAAM_OFF);
//material.setFlag(video::EMF_ANTI_ALIASING, video::EAAM_SIMPLE);
- material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
+ //material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
material.setTexture(0, p.tile.texture);
-
+
if (enable_shaders) {
- video::E_MATERIAL_TYPE smat1 = shadermat1;
- video::E_MATERIAL_TYPE smat2 = shadermat2;
- video::E_MATERIAL_TYPE smat3 = shadermat3;
-
+ ITextureSource *tsrc = data->m_gamedef->tsrc();
+ material.setTexture(2, tsrc->getTexture("disable_img.png"));
if (enable_bumpmapping) {
- ITextureSource *tsrc = data->m_gamedef->tsrc();
std::string fname_base = tsrc->getTextureName(p.tile.texture_id);
-
std::string normal_ext = "_normal.png";
size_t pos = fname_base.find(".");
std::string fname_normal = fname_base.substr(0, pos) + normal_ext;
-
+
if (tsrc->isKnownSourceImage(fname_normal)) {
// look for image extension and replace it
size_t i = 0;
@@ -1227,19 +1223,15 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data):
fname_base.replace(i, 4, normal_ext);
i += normal_ext.length();
}
-
material.setTexture(1, tsrc->getTexture(fname_base));
-
- smat1 = bumpmaps1;
- smat2 = bumpmaps2;
+ material.setTexture(2, tsrc->getTexture("enable_img.png"));
}
}
-
- p.tile.applyMaterialOptionsWithShaders(material, smat1, smat2, smat3);
+ p.tile.applyMaterialOptionsWithShaders(material,
+ shadermat1, shadermat2, shadermat3, shadermat4, shadermat5);
} else {
p.tile.applyMaterialOptions(material);
}
-
// Create meshbuffer
// This is a "Standard MeshBuffer",
@@ -1369,18 +1361,21 @@ bool MapBlockMesh::animate(bool faraway, float time, int crack, u32 daynight_rat
os<<"^[verticalframe:"<<(int)tile.animation_frame_count<<":"<<frame;
// Set the texture
buf->getMaterial().setTexture(0, tsrc->getTexture(os.str()));
+ buf->getMaterial().setTexture(2, tsrc->getTexture("disable_img.png"));
if (enable_shaders && enable_bumpmapping)
{
- std::string basename,normal;
- basename = tsrc->getTextureName(tile.texture_id);
+ std::string fname_base,fname_normal;
+ fname_base = tsrc->getTextureName(tile.texture_id);
unsigned pos;
- pos = basename.find(".");
- normal = basename.substr (0, pos);
- normal += "_normal.png";
- os.str("");
- os<<normal<<"^[verticalframe:"<<(int)tile.animation_frame_count<<":"<<frame;
- if (tsrc->isKnownSourceImage(normal))
+ pos = fname_base.find(".");
+ fname_normal = fname_base.substr (0, pos);
+ fname_normal += "_normal.png";
+ if (tsrc->isKnownSourceImage(fname_normal)){
+ os.str("");
+ os<<fname_normal<<"^[verticalframe:"<<(int)tile.animation_frame_count<<":"<<frame;
buf->getMaterial().setTexture(1, tsrc->getTexture(os.str()));
+ buf->getMaterial().setTexture(2, tsrc->getTexture("enable_img.png"));
+ }
}
}
diff --git a/src/nodedef.cpp b/src/nodedef.cpp
index d13d0653d..2b6de0461 100644
--- a/src/nodedef.cpp
+++ b/src/nodedef.cpp
@@ -225,6 +225,7 @@ void ContentFeatures::reset()
damage_per_second = 0;
node_box = NodeBox();
selection_box = NodeBox();
+ waving = 0;
legacy_facedir_simple = false;
legacy_wallmounted = false;
sound_footstep = SimpleSoundSpec();
@@ -292,6 +293,7 @@ void ContentFeatures::serialize(std::ostream &os, u16 protocol_version)
writeU8(os, liquid_range);
// Stuff below should be moved to correct place in a version that otherwise changes
// the protocol version
+ writeU8(os, waving);
}
void ContentFeatures::deSerialize(std::istream &is)
@@ -359,6 +361,7 @@ void ContentFeatures::deSerialize(std::istream &is)
try{
// Stuff below should be moved to correct place in a version that
// otherwise changes the protocol version
+ waving = readU8(is);
}catch(SerializationError &e) {};
}
@@ -618,6 +621,9 @@ public:
}
bool is_liquid = false;
+ u8 material_type;
+ material_type = (f->alpha == 255) ? TILE_MATERIAL_BASIC : TILE_MATERIAL_ALPHA;
+
switch(f->drawtype){
default:
case NDT_NORMAL:
@@ -669,10 +675,14 @@ public:
tiledef[i].name += std::string("^[noalpha");
}
}
+ if (f->waving == 1)
+ material_type = TILE_MATERIAL_LEAVES;
break;
case NDT_PLANTLIKE:
f->solidness = 0;
f->backface_culling = false;
+ if (f->waving == 1)
+ material_type = TILE_MATERIAL_PLANTS;
break;
case NDT_TORCHLIKE:
case NDT_SIGNLIKE:
@@ -683,11 +693,8 @@ public:
break;
}
- u8 material_type;
if (is_liquid)
material_type = (f->alpha == 255) ? TILE_MATERIAL_LIQUID_OPAQUE : TILE_MATERIAL_LIQUID_TRANSPARENT;
- else
- material_type = (f->alpha == 255) ? TILE_MATERIAL_BASIC : TILE_MATERIAL_ALPHA;
// Tiles (fill in f->tiles[])
for(u16 j=0; j<6; j++){
diff --git a/src/nodedef.h b/src/nodedef.h
index c0322d919..d4cd66f80 100644
--- a/src/nodedef.h
+++ b/src/nodedef.h
@@ -234,6 +234,8 @@ struct ContentFeatures
u32 damage_per_second;
NodeBox node_box;
NodeBox selection_box;
+ // Used for waving leaves/plants
+ u8 waving;
// Compatibility with old maps
// Set to true if paramtype used to be 'facedir_simple'
bool legacy_facedir_simple;
diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp
index fd98e9480..d58479042 100644
--- a/src/script/common/c_content.cpp
+++ b/src/script/common/c_content.cpp
@@ -428,6 +428,9 @@ ContentFeatures read_content_features(lua_State *L, int index)
f.selection_box = read_nodebox(L, -1);
lua_pop(L, 1);
+ f.waving = getintfield_default(L, index,
+ "waving", f.waving);
+
// Set to true if paramtype used to be 'facedir_simple'
getboolfield(L, index, "legacy_facedir_simple", f.legacy_facedir_simple);
// Set to true if wall_mounted used to be set to true
diff --git a/src/tile.h b/src/tile.h
index 90e180a48..b748c092e 100644
--- a/src/tile.h
+++ b/src/tile.h
@@ -136,6 +136,8 @@ enum MaterialType{
TILE_MATERIAL_ALPHA,
TILE_MATERIAL_LIQUID_TRANSPARENT,
TILE_MATERIAL_LIQUID_OPAQUE,
+ TILE_MATERIAL_LEAVES,
+ TILE_MATERIAL_PLANTS
};
// Material flags
@@ -204,13 +206,21 @@ struct TileSpec
case TILE_MATERIAL_LIQUID_OPAQUE:
material.MaterialType = video::EMT_SOLID;
break;
+ case TILE_MATERIAL_LEAVES:
+ material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
+ break;
+ case TILE_MATERIAL_PLANTS:
+ material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
+ 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 video::E_MATERIAL_TYPE &alpha) const
+ const video::E_MATERIAL_TYPE &alpha,
+ const video::E_MATERIAL_TYPE &leaves,
+ const video::E_MATERIAL_TYPE &plants) const
{
switch(material_type){
case TILE_MATERIAL_BASIC:
@@ -225,6 +235,12 @@ struct TileSpec
case TILE_MATERIAL_LIQUID_OPAQUE:
material.MaterialType = liquid;
break;
+ case TILE_MATERIAL_LEAVES:
+ material.MaterialType = leaves;
+ break;
+ case TILE_MATERIAL_PLANTS:
+ material.MaterialType = plants;
+ break;
}
material.BackfaceCulling = (material_flags & MATERIAL_FLAG_BACKFACE_CULLING) ? true : false;
}