Hello!
There are some mods which create mesh objects, like advtrains. The problem is that all these meshes don’t look really 3D, because they don’t get face shading applied. Example image (actual/expected):
At least since Minetest 5.4.0-dev, it is possible to enable vertex shading with one of the shader checkboxes in the Settings tab. But that makes train models look really ugly. They wouldn’t have the bottom faces darker, but some random spots somewhere else, just because a downward looking face is nearby.
I looked at the C++ code, primarlily on src/client/mesh.cpp and src/client/content_cao.cpp, but I don’t have the impression that there is a way to apply face shading to a mesh. There is a face shading function, but that one is used only for mapblock meshes. This will apply face shading to mesh nodes, but not to any objects like trains.
So my question is: how are mods supposed to create mesh objects which have face shading applied? Is this even possible? And if not possible, what is the preferred way to maybe make it possible in the future?
[Solved] How to get face shading for objects with "mesh" drawtype?
-
- Member
- Posts: 70
- Joined: Wed Dec 16, 2020 16:52
- GitHub: doxygen-spammer
[Solved] How to get face shading for objects with "mesh" drawtype?
- Attachments
-
- shader_actual_expected.png (480.21 KiB) Viewed 533 times
Last edited by doxygen_spammer on Thu Jan 27, 2022 08:45, edited 1 time in total.
- Nathan.S
- Member
- Posts: 1147
- Joined: Wed Sep 24, 2014 17:47
- GitHub: NathanSalapat
- IRC: NathanS21
- In-game: NathanS21
- Location: Bigsby Texas
- Contact:
Re: How to get face shading for objects with "mesh" drawtype?
The only way I know of is to do an AO (Ambient Occlusion) bake on your mesh in whatever software you are using to make it, (Blender, Maya, Max, etc) and mix that together with your texture when creating the texture to get lighting that looks more realistic.
I record Minetest videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website, and brand new Minetest Modding Course
Check out my website, and brand new Minetest Modding Course
-
- Member
- Posts: 70
- Joined: Wed Dec 16, 2020 16:52
- GitHub: doxygen-spammer
Re: How to get face shading for objects with "mesh" drawtype?
I use Blender. (Ok, I used a semi-old version 6 years ago...)
There is probably a way to bake lighting in Blender, and export it together with the UV map, so I can use it as Multiply layer in GIMP. As soon as Minetest supports shading, I just remove the Multiply layer.
This is somehow what I expected, but I wonder whether a mod may set some table values besides visual="mesh", which might be supported in the future. Maybe shading="none", to prevent double face shading when it exists? Probably not?
Another thought: Make sharp edges double, so faces are not connected over the edges. That should prevent vertex shading across the edge. But that would probably somehow bleed the environment through the edge, I wouldn’t like to do that.
There is probably a way to bake lighting in Blender, and export it together with the UV map, so I can use it as Multiply layer in GIMP. As soon as Minetest supports shading, I just remove the Multiply layer.
This is somehow what I expected, but I wonder whether a mod may set some table values besides visual="mesh", which might be supported in the future. Maybe shading="none", to prevent double face shading when it exists? Probably not?
Another thought: Make sharp edges double, so faces are not connected over the edges. That should prevent vertex shading across the edge. But that would probably somehow bleed the environment through the edge, I wouldn’t like to do that.
-
- Member
- Posts: 70
- Joined: Wed Dec 16, 2020 16:52
- GitHub: doxygen-spammer
Re: How to get face shading for objects with "mesh" drawtype?
By now, I have learned that the current B3D exporter in Blender produces meshes on which face shading works. Previously it appeared to produce meshes with custom normals towards -Y on every face, turning white sheeps dark grey and trains very boring. But it is still buggy nowadays, once in a few cases it still shows such problems.
And this actually happens, the split edge does not look nice.Another thought: Make sharp edges double, so faces are not connected over the edges. That should prevent vertex shading across the edge. But that would probably somehow bleed the environment through the edge, I wouldn’t like to do that.
- Blockhead
- Member
- Posts: 1696
- Joined: Wed Jul 17, 2019 10:14
- GitHub: Montandalar
- IRC: Blockhead256
- In-game: Blockhead Blockhead256
- Location: Land Down Under
- Contact:
Re: How to get face shading for objects with "mesh" drawtype?
Oh, I had always thought that our oldest models, which were made by mbb in Blender 2.7x series, had custom normals done by him, which I always thought were very weird ones, but I actually find it much more believable that the exporter was that cause of these bad normals. I thought this because I've only ever used Blender > 2.8 (for serious work, I've tried 2.79 and immediately discarded it) - 2.8 was brand new when I was just getting into blender and honestly just looking at 2.79's interface was enough to put a lot of people off.doxygen_spammer wrote: ↑Thu Jan 27, 2022 08:45By now, I have learned that the current B3D exporter in Blender produces meshes on which face shading works. Previously it appeared to produce meshes with custom normals towards -Y on every face, turning white sheeps dark grey and trains very boring. But it is still buggy nowadays, once in a few cases it still shows such problems.
And this actually happens, the split edge does not look nice.Another thought: Make sharp edges double, so faces are not connected over the edges. That should prevent vertex shading across the edge. But that would probably somehow bleed the environment through the edge, I wouldn’t like to do that.
It's a shame that we don't have a B3D importer that preserves animation, because it would be good to go and fix some bad normals on the older models if we could, but animation isn't part of my skill set yet. I did it once with the linetrack boat door then promptly forgot it.
Also I'm somewhat attached to the current shading on the industrial engine, but yeah it would probably be better with sharp edges.
/˳˳_˳˳]_[˳˳_˳˳]_[˳˳_˳˳\ Advtrains enthusiast | My map: Noah's Railyard | My Content on ContentDB ✝️♂
-
- Member
- Posts: 70
- Joined: Wed Dec 16, 2020 16:52
- GitHub: doxygen-spammer
Re: How to get face shading for objects with "mesh" drawtype?
I didn’t touch 2.7, but for my taste the color scheme was better than in 2.8. I still miss the general UI concept of 2.5, which is when I used Blender the last time before Minetest.
Nah, might also be a good thing. Animations in some models are broken. The subway wagons from basic_trains have doors that dance around wildly instead of sliding in their rails. I think that is another problem of the B3D exporter, it apparently applies scaling instead of rotation to inverse kinematic bones, instead of using the actual result of the inverse kinematic. I could only fix this by adding extra bones which just copy location and rotation of the relevant bones.It's a shame that we don't have a B3D importer that preserves animation, because it would be good to go and fix some bad normals on the older models if we could
Who is online
Users browsing this forum: No registered users and 12 guests