Added a setting for disabling smooth lighting. Updated changelog.
authorPerttu Ahola <celeron55@gmail.com>
Sun, 24 Apr 2011 09:31:19 +0000 (12:31 +0300)
committerPerttu Ahola <celeron55@gmail.com>
Sun, 24 Apr 2011 09:31:19 +0000 (12:31 +0300)
doc/changelog.txt
minetest.conf.example
src/defaultsettings.cpp
src/mapblock.cpp

index d61f378615af131d779533a632f0a9a8cc3a9160..f467d6ecde5b511b49046854194ee3326b0bb8a7 100644 (file)
@@ -3,6 +3,9 @@ Minetest-c55 changelog
 This should contain all the major changes.
 For minor stuff, refer to the commit log of the repository.
 
+X:
+- Smooth lighting with simple ambient occlusion
+
 2011-04-23_0_test:
 - Small bug fixes
 - Item drop multiplication fixed
index 770677da11a9c29668cc0372751e654d895bc24e..48f326229889d957fdd86698a0e603201fe36dc1 100644 (file)
@@ -27,6 +27,8 @@
 #new_style_water = true
 # Enable nice leaves; disable for speed
 #new_style_leaves = true
+# Enable smooth lighting with simple ambient occlusion; disable for speed
+#smooth_lighting = true
 # Whether to draw a frametime graph
 #frametime_graph = false
 # Enable combining mainly used textures to a bigger one
index d1e9d45cdda7acc706774a66b6815373076a7c68..fc63856baae6f0c764069a6f0d1a1ceca46d5e50 100644 (file)
@@ -41,6 +41,7 @@ void set_default_settings()
        g_settings.setDefault("enable_fog", "true");
        g_settings.setDefault("new_style_water", "false");
        g_settings.setDefault("new_style_leaves", "true");
+       g_settings.setDefault("smooth_lighting", "true");
        g_settings.setDefault("frametime_graph", "false");
        g_settings.setDefault("enable_texture_atlas", "true");
        g_settings.setDefault("texture_path", "");
index 69834b56a824590c0f6dc4275dafdfd322d3565d..824f7dc8acc901fa67b7324f2b892931dedee0b8 100644 (file)
@@ -400,7 +400,8 @@ void updateFastFaceRow(
                core::array<FastFace> &dest,
                NodeModMap &temp_mods,
                VoxelManipulator &vmanip,
-               v3s16 blockpos_nodes)
+               v3s16 blockpos_nodes,
+               bool smooth_lighting)
 {
        v3s16 p = startpos;
        
@@ -508,50 +509,53 @@ void updateFastFaceRow(
                                        scale.Z = continuous_tiles_count;
                                }
                                
-                               //u8 li = decode_light(light);
+                               if(smooth_lighting == false)
+                                       li0 = li1 = li2 = li3 = decode_light(light);
 
                                // If node at sp (tile0) is more solid
                                if(mf == 1)
                                {
-                                       if(face_dir == v3s16(0,0,1))
+                                       if(smooth_lighting)
                                        {
-                                               // Going along X+, faces in Z+
-                                               li0 = getSmoothLight(p_map_first+v3s16(0,0,1),
-                                                               vmanip, daynight_ratio);
-                                               li1 = getSmoothLight(p_map+v3s16(1,0,1),
-                                                               vmanip, daynight_ratio);
-                                               li2 = getSmoothLight(p_map+v3s16(1,1,1),
-                                                               vmanip, daynight_ratio);
-                                               li3 = getSmoothLight(p_map_first+v3s16(0,1,1),
-                                                               vmanip, daynight_ratio);
-                                       }
-                                       else if(face_dir == v3s16(0,1,0))
-                                       {
-                                               // Going along X+, faces in Y+
-                                               li0 = getSmoothLight(p_map_first+v3s16(0,1,1),
-                                                               vmanip, daynight_ratio);
-                                               li1 = getSmoothLight(p_map+v3s16(1,1,1),
-                                                               vmanip, daynight_ratio);
-                                               li2 = getSmoothLight(p_map+v3s16(1,1,0),
-                                                               vmanip, daynight_ratio);
-                                               li3 = getSmoothLight(p_map_first+v3s16(0,1,0),
-                                                               vmanip, daynight_ratio);
-                                       }
-                                       else if(face_dir == v3s16(1,0,0))
-                                       {
-                                               // Going along Z+, faces in X+
-                                               li0 = getSmoothLight(p_map_first+v3s16(1,0,1),
-                                                               vmanip, daynight_ratio);
-                                               li1 = getSmoothLight(p_map+v3s16(1,0,0),
-                                                               vmanip, daynight_ratio);
-                                               li2 = getSmoothLight(p_map+v3s16(1,1,0),
-                                                               vmanip, daynight_ratio);
-                                               li3 = getSmoothLight(p_map_first+v3s16(1,1,1),
-                                                               vmanip, daynight_ratio);
+                                               if(face_dir == v3s16(0,0,1))
+                                               {
+                                                       // Going along X+, faces in Z+
+                                                       li0 = getSmoothLight(p_map_first+v3s16(0,0,1),
+                                                                       vmanip, daynight_ratio);
+                                                       li1 = getSmoothLight(p_map+v3s16(1,0,1),
+                                                                       vmanip, daynight_ratio);
+                                                       li2 = getSmoothLight(p_map+v3s16(1,1,1),
+                                                                       vmanip, daynight_ratio);
+                                                       li3 = getSmoothLight(p_map_first+v3s16(0,1,1),
+                                                                       vmanip, daynight_ratio);
+                                               }
+                                               else if(face_dir == v3s16(0,1,0))
+                                               {
+                                                       // Going along X+, faces in Y+
+                                                       li0 = getSmoothLight(p_map_first+v3s16(0,1,1),
+                                                                       vmanip, daynight_ratio);
+                                                       li1 = getSmoothLight(p_map+v3s16(1,1,1),
+                                                                       vmanip, daynight_ratio);
+                                                       li2 = getSmoothLight(p_map+v3s16(1,1,0),
+                                                                       vmanip, daynight_ratio);
+                                                       li3 = getSmoothLight(p_map_first+v3s16(0,1,0),
+                                                                       vmanip, daynight_ratio);
+                                               }
+                                               else if(face_dir == v3s16(1,0,0))
+                                               {
+                                                       // Going along Z+, faces in X+
+                                                       li0 = getSmoothLight(p_map_first+v3s16(1,0,1),
+                                                                       vmanip, daynight_ratio);
+                                                       li1 = getSmoothLight(p_map+v3s16(1,0,0),
+                                                                       vmanip, daynight_ratio);
+                                                       li2 = getSmoothLight(p_map+v3s16(1,1,0),
+                                                                       vmanip, daynight_ratio);
+                                                       li3 = getSmoothLight(p_map_first+v3s16(1,1,1),
+                                                                       vmanip, daynight_ratio);
+                                               }
+                                               else assert(0);
                                        }
-                                       else assert(0);
 
-                                       //makeFastFace(tile0, li, li, li, li,
                                        makeFastFace(tile0, li0, li1, li2, li3,
                                                        sp, face_dir, scale,
                                                        posRelative_f, dest);
@@ -559,49 +563,51 @@ void updateFastFaceRow(
                                // If node at sp is less solid (mf == 2)
                                else
                                {
-                                       // Offset to the actual solid block
-                                       p_map += face_dir;
-                                       p_map_first += face_dir;
-                                       
-                                       if(face_dir == v3s16(0,0,1))
+                                       if(smooth_lighting)
                                        {
-                                               // Going along X+, faces in Z-
-                                               li0 = getSmoothLight(p_map+v3s16(1,0,0),
-                                                               vmanip, daynight_ratio);
-                                               li1 = getSmoothLight(p_map_first+v3s16(0,0,0),
-                                                               vmanip, daynight_ratio);
-                                               li2 = getSmoothLight(p_map_first+v3s16(0,1,0),
-                                                               vmanip, daynight_ratio);
-                                               li3 = getSmoothLight(p_map+v3s16(1,1,0),
-                                                               vmanip, daynight_ratio);
-                                       }
-                                       else if(face_dir == v3s16(0,1,0))
-                                       {
-                                               // Going along X+, faces in Y-
-                                               li0 = getSmoothLight(p_map_first+v3s16(0,0,0),
-                                                               vmanip, daynight_ratio);
-                                               li1 = getSmoothLight(p_map+v3s16(1,0,0),
-                                                               vmanip, daynight_ratio);
-                                               li2 = getSmoothLight(p_map+v3s16(1,0,1),
-                                                               vmanip, daynight_ratio);
-                                               li3 = getSmoothLight(p_map_first+v3s16(0,0,1),
-                                                               vmanip, daynight_ratio);
-                                       }
-                                       else if(face_dir == v3s16(1,0,0))
-                                       {
-                                               // Going along Z+, faces in X-
-                                               li0 = getSmoothLight(p_map_first+v3s16(0,0,0),
-                                                               vmanip, daynight_ratio);
-                                               li1 = getSmoothLight(p_map+v3s16(0,0,1),
-                                                               vmanip, daynight_ratio);
-                                               li2 = getSmoothLight(p_map+v3s16(0,1,1),
-                                                               vmanip, daynight_ratio);
-                                               li3 = getSmoothLight(p_map_first+v3s16(0,1,0),
-                                                               vmanip, daynight_ratio);
+                                               // Offset to the actual solid block
+                                               p_map += face_dir;
+                                               p_map_first += face_dir;
+                                               
+                                               if(face_dir == v3s16(0,0,1))
+                                               {
+                                                       // Going along X+, faces in Z-
+                                                       li0 = getSmoothLight(p_map+v3s16(1,0,0),
+                                                                       vmanip, daynight_ratio);
+                                                       li1 = getSmoothLight(p_map_first+v3s16(0,0,0),
+                                                                       vmanip, daynight_ratio);
+                                                       li2 = getSmoothLight(p_map_first+v3s16(0,1,0),
+                                                                       vmanip, daynight_ratio);
+                                                       li3 = getSmoothLight(p_map+v3s16(1,1,0),
+                                                                       vmanip, daynight_ratio);
+                                               }
+                                               else if(face_dir == v3s16(0,1,0))
+                                               {
+                                                       // Going along X+, faces in Y-
+                                                       li0 = getSmoothLight(p_map_first+v3s16(0,0,0),
+                                                                       vmanip, daynight_ratio);
+                                                       li1 = getSmoothLight(p_map+v3s16(1,0,0),
+                                                                       vmanip, daynight_ratio);
+                                                       li2 = getSmoothLight(p_map+v3s16(1,0,1),
+                                                                       vmanip, daynight_ratio);
+                                                       li3 = getSmoothLight(p_map_first+v3s16(0,0,1),
+                                                                       vmanip, daynight_ratio);
+                                               }
+                                               else if(face_dir == v3s16(1,0,0))
+                                               {
+                                                       // Going along Z+, faces in X-
+                                                       li0 = getSmoothLight(p_map_first+v3s16(0,0,0),
+                                                                       vmanip, daynight_ratio);
+                                                       li1 = getSmoothLight(p_map+v3s16(0,0,1),
+                                                                       vmanip, daynight_ratio);
+                                                       li2 = getSmoothLight(p_map+v3s16(0,1,1),
+                                                                       vmanip, daynight_ratio);
+                                                       li3 = getSmoothLight(p_map_first+v3s16(0,1,0),
+                                                                       vmanip, daynight_ratio);
+                                               }
+                                               else assert(0);
                                        }
-                                       else assert(0);
 
-                                       //makeFastFace(tile1, li, li, li, li,
                                        makeFastFace(tile1, li0, li1, li2, li3,
                                                        sp+face_dir_f, -face_dir, scale,
                                                        posRelative_f, dest);
@@ -731,6 +737,7 @@ scene::SMesh* makeMapBlockMesh(MeshMakeData *data)
        */
        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");
        
        float node_water_level = 1.0;
        if(new_style_water)
@@ -762,7 +769,8 @@ scene::SMesh* makeMapBlockMesh(MeshMakeData *data)
                                                fastfaces_new,
                                                data->m_temp_mods,
                                                data->m_vmanip,
-                                               blockpos_nodes);
+                                               blockpos_nodes,
+                                               smooth_lighting);
                        }
                }
                /*
@@ -779,7 +787,8 @@ scene::SMesh* makeMapBlockMesh(MeshMakeData *data)
                                                fastfaces_new,
                                                data->m_temp_mods,
                                                data->m_vmanip,
-                                               blockpos_nodes);
+                                               blockpos_nodes,
+                                               smooth_lighting);
                        }
                }
                /*
@@ -796,7 +805,8 @@ scene::SMesh* makeMapBlockMesh(MeshMakeData *data)
                                                fastfaces_new,
                                                data->m_temp_mods,
                                                data->m_vmanip,
-                                               blockpos_nodes);
+                                               blockpos_nodes,
+                                               smooth_lighting);
                        }
                }
        }