mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Improve mesh shading (#5172)
This commit is contained in:
parent
f2f9a92351
commit
80c75272a6
1 changed files with 7 additions and 6 deletions
13
src/mesh.cpp
13
src/mesh.cpp
|
@ -44,12 +44,13 @@ void applyFacesShading(video::SColor &color, const v3f &normal)
|
||||||
{
|
{
|
||||||
// Many special drawtypes have normals set to 0,0,0 and this
|
// Many special drawtypes have normals set to 0,0,0 and this
|
||||||
// must result in maximum brightness (no face shadng).
|
// must result in maximum brightness (no face shadng).
|
||||||
if (normal.Y < -0.5f)
|
float x2 = normal.X * normal.X;
|
||||||
applyShadeFactor (color, 0.447213f);
|
float y2 = normal.Y * normal.Y;
|
||||||
else if (normal.X > 0.5f || normal.X < -0.5f)
|
float z2 = normal.Z * normal.Z;
|
||||||
applyShadeFactor (color, 0.670820f);
|
if (normal.Y < 0)
|
||||||
else if (normal.Z > 0.5f || normal.Z < -0.5f)
|
applyShadeFactor(color, 0.670820f * x2 + 0.447213f * y2 + 0.836660f * z2);
|
||||||
applyShadeFactor (color, 0.836660f);
|
else if ((x2 > 1e-3) || (z2 > 1e-3))
|
||||||
|
applyShadeFactor(color, 0.670820f * x2 + 1.000000f * y2 + 0.836660f * z2);
|
||||||
}
|
}
|
||||||
|
|
||||||
scene::IAnimatedMesh* createCubeMesh(v3f scale)
|
scene::IAnimatedMesh* createCubeMesh(v3f scale)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue