Make lava brighter by showing light sources at their full emitted light level
authorPerttu Ahola <celeron55@gmail.com>
Sun, 8 Apr 2012 01:01:12 +0000 (04:01 +0300)
committerPerttu Ahola <celeron55@gmail.com>
Sun, 8 Apr 2012 01:01:12 +0000 (04:01 +0300)
src/content_mapblock.cpp
src/mapblock_mesh.cpp

index 8f102cd9174f3f58403af3fc8653fe2eecbcfb30..3184925a49b69ee6d7f1caafcd2317fc107bdee5 100644 (file)
@@ -210,8 +210,16 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
                                top_is_same_liquid = true;
                        
                        u16 l = 0;
+                       // If this liquid emits light and doesn't contain light, draw
+                       // it at what it emits, for an increased effect
+                       u8 light_source = nodedef->get(n).light_source;
+                       if(light_source != 0){
+                               //l = decode_light(undiminish_light(light_source));
+                               l = decode_light(light_source);
+                               l = l | (l<<8);
+                       }
                        // Use the light of the node on top if possible
-                       if(nodedef->get(ntop).param_type == CPT_LIGHT)
+                       else if(nodedef->get(ntop).param_type == CPT_LIGHT)
                                l = getInteriorLight(ntop, 0, data);
                        // Otherwise use the light of this node (the liquid)
                        else
index abe23855f247ea71513296b130753a066b766f90..0e26161e2d7aee65776743e46e6a3fe865935a42 100644 (file)
@@ -183,6 +183,15 @@ static u8 getFaceLight(enum LightBank bank, MapNode n, MapNode n2,
        else
                light = l2;
 
+       // Boost light level for light sources
+       u8 light_source = MYMAX(ndef->get(n).light_source,
+                       ndef->get(n2).light_source);
+       //if(light_source >= light)
+               //return decode_light(undiminish_light(light_source));
+       if(light_source > light)
+               //return decode_light(light_source);
+               light = light_source;
+
        // Make some nice difference to different sides
 
        // This makes light come from a corner
@@ -233,10 +242,13 @@ static u8 getSmoothLight(enum LightBank bank, v3s16 p, MeshMakeData *data)
        u16 ambient_occlusion = 0;
        u16 light = 0;
        u16 light_count = 0;
+       u8 light_source_max = 0;
        for(u32 i=0; i<8; i++)
        {
                MapNode n = data->m_vmanip.getNodeNoEx(p - dirs8[i]);
                const ContentFeatures &f = ndef->get(n);
+               if(f.light_source > light_source_max)
+                       light_source_max = f.light_source;
                // Check f.solidness because fast-style leaves look
                // better this way
                if(f.param_type == CPT_LIGHT && f.solidness != 2)
@@ -255,6 +267,11 @@ static u8 getSmoothLight(enum LightBank bank, v3s16 p, MeshMakeData *data)
        
        light /= light_count;
 
+       // Boost brightness around light sources
+       if(decode_light(light_source_max) >= light)
+               //return decode_light(undiminish_light(light_source_max));
+               return decode_light(light_source_max);
+
        if(ambient_occlusion > 4)
        {
                ambient_occlusion -= 4;