#include "map.h"
#include "main.h" // For g_settings and g_texturesource
#include "content_mapblock.h"
+#include "settings.h"
+#include "profiler.h"
+#include "mapnode_contentfeatures.h"
void MeshMakeData::fill(u32 daynight_ratio, MapBlock *block)
{
}
}
-inline video::SColor lightColor(u8 alpha, u8 light)
+video::SColor MapBlock_LightColor(u8 alpha, u8 light)
{
+#if 0
return video::SColor(alpha,light,light,light);
+#endif
+ //return video::SColor(alpha,light,light,MYMAX(0, (s16)light-25)+25);
+ /*return video::SColor(alpha,light,light,MYMAX(0,
+ pow((float)light/255.0, 0.8)*255.0));*/
+#if 1
+ // Emphase blue a bit in darker places
+ float lim = 80;
+ float power = 0.8;
+ if(light > lim)
+ return video::SColor(alpha,light,light,light);
+ else
+ return video::SColor(alpha,light,light,MYMAX(0,
+ pow((float)light/lim, power)*lim));
+#endif
}
struct FastFace
float w = tile.texture.size.X;
float h = tile.texture.size.Y;
- /*video::SColor c = lightColor(alpha, li);
+ /*video::SColor c = MapBlock_LightColor(alpha, li);
face.vertices[0] = video::S3DVertex(vertex_pos[0], v3f(0,1,0), c,
core::vector2d<f32>(x0+w*abs_scale, y0+h));
core::vector2d<f32>(x0+w*abs_scale, y0));*/
face.vertices[0] = video::S3DVertex(vertex_pos[0], v3f(0,1,0),
- lightColor(alpha, li0),
+ MapBlock_LightColor(alpha, li0),
core::vector2d<f32>(x0+w*abs_scale, y0+h));
face.vertices[1] = video::S3DVertex(vertex_pos[1], v3f(0,1,0),
- lightColor(alpha, li1),
+ MapBlock_LightColor(alpha, li1),
core::vector2d<f32>(x0, y0+h));
face.vertices[2] = video::S3DVertex(vertex_pos[2], v3f(0,1,0),
- lightColor(alpha, li2),
+ MapBlock_LightColor(alpha, li2),
core::vector2d<f32>(x0, y0));
face.vertices[3] = video::S3DVertex(vertex_pos[3], v3f(0,1,0),
- lightColor(alpha, li3),
+ MapBlock_LightColor(alpha, li3),
core::vector2d<f32>(x0+w*abs_scale, y0));
face.tile = tile;
// This is hackish
content_t content0 = getNodeContent(p, n0, temp_mods);
content_t content1 = getNodeContent(p + face_dir, n1, temp_mods);
- u8 mf = face_contents(content0, content1);
+ bool equivalent = false;
+ u8 mf = face_contents(content0, content1, &equivalent);
if(mf == 0)
{
face_dir_corrected = -face_dir;
}
+ // eg. water and glass
+ if(equivalent)
+ tile.material_flags |= MATERIAL_FLAG_BACKFACE_CULLING;
+
if(smooth_lighting == false)
{
lights[0] = lights[1] = lights[2] = lights[3] =
u16 continuous_tiles_count = 0;
- bool makes_face;
+ bool makes_face = false;
v3s16 p_corrected;
v3s16 face_dir_corrected;
- u8 lights[4];
+ u8 lights[4] = {0,0,0,0};
TileSpec tile;
getTileInfo(blockpos_nodes, p, face_dir, daynight_ratio,
vmanip, temp_mods, smooth_lighting,
next_tile);
if(next_makes_face == makes_face
- && next_p_corrected == p_corrected
+ && next_p_corrected == p_corrected + translate_dir
&& next_face_dir_corrected == face_dir_corrected
&& next_lights[0] == lights[0]
&& next_lights[1] == lights[1]
{
next_is_different = false;
}
+ else{
+ /*if(makes_face){
+ g_profiler->add("Meshgen: diff: next_makes_face != makes_face",
+ next_makes_face != makes_face ? 1 : 0);
+ g_profiler->add("Meshgen: diff: n_p_corr != p_corr + t_dir",
+ (next_p_corrected != p_corrected + translate_dir) ? 1 : 0);
+ g_profiler->add("Meshgen: diff: next_f_dir_corr != f_dir_corr",
+ next_face_dir_corrected != face_dir_corrected ? 1 : 0);
+ g_profiler->add("Meshgen: diff: next_lights[] != lights[]",
+ (next_lights[0] != lights[0] ||
+ next_lights[0] != lights[0] ||
+ next_lights[0] != lights[0] ||
+ next_lights[0] != lights[0]) ? 1 : 0);
+ g_profiler->add("Meshgen: diff: !(next_tile == tile)",
+ !(next_tile == tile) ? 1 : 0);
+ }*/
+ }
+ /*g_profiler->add("Meshgen: Total faces checked", 1);
+ if(makes_face)
+ g_profiler->add("Meshgen: Total makes_face checked", 1);*/
+ } else {
+ /*if(makes_face)
+ g_profiler->add("Meshgen: diff: last position", 1);*/
}
continuous_tiles_count++;
v3f pf(p_corrected.X, p_corrected.Y, p_corrected.Z);
// Center point of face (kind of)
v3f sp = pf - ((f32)continuous_tiles_count / 2. - 0.5) * translate_dir_f;
+ if(continuous_tiles_count != 1)
+ sp += translate_dir_f;
v3f scale(1,1,1);
if(translate_dir.X != 0)
makeFastFace(tile, lights[0], lights[1], lights[2], lights[3],
sp, face_dir_corrected, scale,
posRelative_f, dest);
+
+ g_profiler->avg("Meshgen: faces drawn by tiling", 0);
+ for(int i=1; i<continuous_tiles_count; i++){
+ g_profiler->avg("Meshgen: faces drawn by tiling", 1);
+ }
}
continuous_tiles_count = 0;
/*
Some settings
*/
- //bool new_style_water = g_settings.getBool("new_style_water");
- //bool new_style_leaves = g_settings.getBool("new_style_leaves");
- bool smooth_lighting = g_settings.getBool("smooth_lighting");
+ //bool new_style_water = g_settings->getBool("new_style_water");
+ //bool new_style_leaves = g_settings->getBool("new_style_leaves");
+ bool smooth_lighting = g_settings->getBool("smooth_lighting");
/*
We are including the faces of the trailing edges of the block.
video::SMaterial material;
material.setFlag(video::EMF_LIGHTING, false);
+ material.setFlag(video::EMF_BACK_FACE_CULLING, true);
material.setFlag(video::EMF_BILINEAR_FILTER, false);
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;
for(u32 i=0; i<fastfaces_new.size(); i++)
{