Make faces shading correct for all possible modes.
Skip shading for lightsources and top of the nodes. Fixes liquid sources and flowing surfaces having different brightness.master
parent
587167e940
commit
5e54bf1472
|
@ -108,7 +108,7 @@ void main(void)
|
||||||
|
|
||||||
// Moonlight is blue
|
// Moonlight is blue
|
||||||
b += (day - night) / 13.0;
|
b += (day - night) / 13.0;
|
||||||
rg -= (day - night) / 13.0;
|
rg -= (day - night) / 23.0;
|
||||||
|
|
||||||
// Emphase blue a bit in darker places
|
// Emphase blue a bit in darker places
|
||||||
// See C++ implementation in mapblock_mesh.cpp finalColorBlend()
|
// See C++ implementation in mapblock_mesh.cpp finalColorBlend()
|
||||||
|
|
|
@ -32,11 +32,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "util/directiontables.h"
|
#include "util/directiontables.h"
|
||||||
|
|
||||||
static void applyContrast(video::SColor& color, float factor)
|
static void applyFacesShading(video::SColor& color, float factor)
|
||||||
{
|
{
|
||||||
color.setRed(core::clamp(core::round32(color.getRed()*factor), 0, 255));
|
color.setRed(core::clamp(core::round32(color.getRed()*factor), 0, 255));
|
||||||
color.setGreen(core::clamp(core::round32(color.getGreen()*factor), 0, 255));
|
color.setGreen(core::clamp(core::round32(color.getGreen()*factor), 0, 255));
|
||||||
color.setBlue(core::clamp(core::round32(color.getBlue()*factor), 0, 255));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1142,21 +1141,22 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data, v3s16 camera_offset):
|
||||||
|
|
||||||
for(u32 j = 0; j < p.vertices.size(); j++)
|
for(u32 j = 0; j < p.vertices.size(); j++)
|
||||||
{
|
{
|
||||||
// Note applyContrast second parameter is precalculated sqrt from original
|
// Note applyFacesShading second parameter is precalculated sqrt
|
||||||
// values for speed improvement
|
// value for speed improvement
|
||||||
|
// Skip it for lightsources and top faces.
|
||||||
video::SColor &vc = p.vertices[j].Color;
|
video::SColor &vc = p.vertices[j].Color;
|
||||||
if(p.vertices[j].Normal.Y > 0.5) {
|
if (!vc.getBlue()) {
|
||||||
applyContrast (vc, 1.095445);
|
if (p.vertices[j].Normal.Y < -0.5) {
|
||||||
} else if (p.vertices[j].Normal.Y < -0.5) {
|
applyFacesShading (vc, 0.447213);
|
||||||
applyContrast (vc, 0.547723);
|
} else if (p.vertices[j].Normal.X > 0.5) {
|
||||||
} else if (p.vertices[j].Normal.X > 0.5) {
|
applyFacesShading (vc, 0.670820);
|
||||||
applyContrast (vc, 0.707107);
|
} else if (p.vertices[j].Normal.X < -0.5) {
|
||||||
} else if (p.vertices[j].Normal.X < -0.5) {
|
applyFacesShading (vc, 0.670820);
|
||||||
applyContrast (vc, 0.707107);
|
} else if (p.vertices[j].Normal.Z > 0.5) {
|
||||||
} else if (p.vertices[j].Normal.Z > 0.5) {
|
applyFacesShading (vc, 0.836660);
|
||||||
applyContrast (vc, 0.894427);
|
} else if (p.vertices[j].Normal.Z < -0.5) {
|
||||||
} else if (p.vertices[j].Normal.Z < -0.5) {
|
applyFacesShading (vc, 0.836660);
|
||||||
applyContrast (vc, 0.894427);
|
}
|
||||||
}
|
}
|
||||||
if(!enable_shaders)
|
if(!enable_shaders)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue