aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRealBadAngel <maciej.kasatkin@o2.pl>2014-06-16 18:51:01 +0200
committerRealBadAngel <maciej.kasatkin@o2.pl>2014-06-17 00:56:17 +0200
commita0f78659f31abdce973bc6641b5b5a58f2ba9afc (patch)
tree61aafd24c4a46a6fa74343489de77b8a6a3e5af0 /src
parent9f46cb6745a03f3a435a5a1f8a28a778971f3668 (diff)
downloadminetest-a0f78659f31abdce973bc6641b5b5a58f2ba9afc.tar.gz
minetest-a0f78659f31abdce973bc6641b5b5a58f2ba9afc.tar.bz2
minetest-a0f78659f31abdce973bc6641b5b5a58f2ba9afc.zip
Improved faces shading with and without shaders.
Diffstat (limited to 'src')
-rw-r--r--src/mapblock_mesh.cpp33
1 files changed, 26 insertions, 7 deletions
diff --git a/src/mapblock_mesh.cpp b/src/mapblock_mesh.cpp
index bf62fe8b4..1f2f6cd8c 100644
--- a/src/mapblock_mesh.cpp
+++ b/src/mapblock_mesh.cpp
@@ -1397,13 +1397,32 @@ bool MapBlockMesh::animate(bool faraway, float time, int crack, u32 daynight_rat
u8 night = j->second.second;
finalColorBlend(vertices[vertexIndex].Color,
day, night, daynight_ratio);
- // Brighten topside (no shaders)
- if(vertices[vertexIndex].Normal.Y > 0.5)
- {
- video::SColor &vc = vertices[vertexIndex].Color;
- vc.setRed (srgb_linear_multiply(vc.getRed(), 1.3, 255.0));
- vc.setGreen(srgb_linear_multiply(vc.getGreen(), 1.3, 255.0));
- vc.setBlue (srgb_linear_multiply(vc.getBlue(), 1.3, 255.0));
+ // Make sides and bottom darker than the top
+ video::SColor &vc = vertices[vertexIndex].Color;
+ if(vertices[vertexIndex].Normal.Y > 0.5) {
+ vc.setRed (srgb_linear_multiply(vc.getRed(), 1.2, 255.0));
+ vc.setGreen(srgb_linear_multiply(vc.getGreen(), 1.2, 255.0));
+ vc.setBlue (srgb_linear_multiply(vc.getBlue(), 1.2, 255.0));
+ } else if (vertices[vertexIndex].Normal.Y < -0.5) {
+ vc.setRed (srgb_linear_multiply(vc.getRed(), 0.3, 255.0));
+ vc.setGreen(srgb_linear_multiply(vc.getGreen(), 0.3, 255.0));
+ vc.setBlue (srgb_linear_multiply(vc.getBlue(), 0.3, 255.0));
+ } else if (vertices[vertexIndex].Normal.X > 0.5) {
+ vc.setRed (srgb_linear_multiply(vc.getRed(), 0.8, 255.0));
+ vc.setGreen(srgb_linear_multiply(vc.getGreen(), 0.8, 255.0));
+ vc.setBlue (srgb_linear_multiply(vc.getBlue(), 0.8, 255.0));
+ } else if (vertices[vertexIndex].Normal.X < -0.5) {
+ vc.setRed (srgb_linear_multiply(vc.getRed(), 0.8, 255.0));
+ vc.setGreen(srgb_linear_multiply(vc.getGreen(), 0.8, 255.0));
+ vc.setBlue (srgb_linear_multiply(vc.getBlue(), 0.8, 255.0));
+ } else if (vertices[vertexIndex].Normal.Z > 0.5) {
+ vc.setRed (srgb_linear_multiply(vc.getRed(), 0.5, 255.0));
+ vc.setGreen(srgb_linear_multiply(vc.getGreen(), 0.5, 255.0));
+ vc.setBlue (srgb_linear_multiply(vc.getBlue(), 0.5, 255.0));
+ } else if (vertices[vertexIndex].Normal.Z < -0.5) {
+ vc.setRed (srgb_linear_multiply(vc.getRed(), 0.5, 255.0));
+ vc.setGreen(srgb_linear_multiply(vc.getGreen(), 0.5, 255.0));
+ vc.setBlue (srgb_linear_multiply(vc.getBlue(), 0.5, 255.0));
}
}
}