raduprv / Eternal-Lands

http://www.eternal-lands.com
Other
158 stars 57 forks source link

Wacky backface culling #185

Closed NetSysFire closed 2 years ago

NetSysFire commented 2 years ago

Backface culling sometimes affects things you can see, resulting in missing faces of objects.

I have often seen this affecting logs. This one is in VOTD, the "beaver dam": el backface culling The Desert Pines storage cave entry also looks weird at specific angles without even trying to trigger this backface culling behavior but I do not have a screenshot of this yet.

When viewing a characters head at specific angles, especially if wearing armor, you can also see how backface culling culls faces you can actually see. el backface culling 2

I would rate this issue as pretty minor. It is not gamebreaking and not too annoying either. I could imagine there being a backface culling setting, with a more lax setting fixing the issue but degrading performance.

gvissers commented 2 years ago

I could imagine there being a backface culling setting, with a more lax setting fixing the issue but degrading performance.

You would no longer be able to see your character if the camera is inside an object (e.g. house or rock) if backface culling is disabled.

That log does indeed look silly though, it should have been closed at the bottom.

NetSysFire commented 2 years ago

That log does indeed look silly though, it should have been closed at the bottom.

Well yes but actually no. The reason for that is because of performance reasons because you would otherwise never see the bottom of that log since it is actually a dead tree (and therefore this part would be underground so it can really never be seen). It has been re-used but it illustrates the problem with simple meshes which do not have any "thickness" to them, like the helmet and the characters hair.

NetSysFire commented 2 years ago

el backface culling 3

Here is the example with cave entraces. This specific one is the one with the airship thingy leading you to Irillion. This can also be reproduced with many other cave entraces, like, as already mentioned, the Desert Pines storage cave entrance.

The specific problem with all these cases is the algorithm culling faces you can actually see, which is unintended.

raduprv commented 2 years ago

Yes, some objects such as the log were used wrongly by the map makers. Some like that cave entrance might have the wrong normals. The solution I guess is to remake those objects, not to disable backface cooling.

NetSysFire commented 2 years ago

I am not asking to disable backface culling as it is important due to how stuff works and because of performance reasons. However it is culling faces that should not be culled - this is most notably impacting "zero-width" objects like armor, parts of the hair and some other objects, like this log which should also illustrate the problem well, even if it should never have been used in this way. That means that backface culling needs to behave differently here.

gvissers commented 2 years ago

And how would you determine how it needs to behave?

NetSysFire commented 2 years ago

As seen just above, this is a legitimate example of something that should not happen:

These culled faces would clearly be visible yet they are gone. The log which should not have been used is also an example of a face that would be visible yet it is not. All of those objects are pretty low poly and therefore have no "thickness" to them as already mentioned.

gvissers commented 2 years ago

I can see the problem just fine. But you seem to be asking for backface culling not to be performed in these exact situations. And I was wondering how to identify these situations, and how to distinguish them from a situation where e.g. a tree is standing upright and the inside is invisible.

If instead you're saying the models should be fixed, there's something to be said for that.

NetSysFire commented 2 years ago

Ahhhh alright, I misunderstood what you were asking for.

I think in terms of objects in the environment there may just not be any cases, at least I have not noticed any legitimate cases. We got a case of a misused object and some faulty normals, but maybe make an exception for the character and its armor and/or do some fancy graphics filtering tricks to double-check if a face is in the current camera view before it would be culled. I have no idea how to implement that though, yet it might be costly in terms of performance. However it might be just fine if it is restricted to only the player.

Another thing to think about is whether applying this lax backface culling should also be applied to other characters.

To be clear here, I am not sure if you even can have two different modes of backface culling at the same time but I hope you get what I mean. Selectively disable backface culling for a group of objects. Maybe even make that configurable, so you can choose between:

gvissers commented 2 years ago

In theory it could be toggled at any point. But checking if a face is visible is pointless, might as well draw it and let OpenGL determine if it's visible in that case. Also remember that branches (if statements) aren't free, and potentially costly. In the case of the tree, you'd be better of closing the tree at the bottom. I have no idea what's wrong with the arch, but I doubt its the normals. Front/back face is determined by the winding direction of the triangle, not the normals at the vertices. Those would affect lighting, though.

NetSysFire commented 2 years ago

I have absolutely no idea about the internals here. In theory one could also just draw the faces regardless and do not do any backface culling for the player and its armor since it should hardly be a difference in performance due to the low poly models and low-res textures. But this is a guess and I do not know what the actual performance impact would be here.

feeltheburn commented 2 years ago

Mapwise I've actually fixed a huge ton of incorrectly placed items during the past 3 client updates, that have a "see-through side" on their bottom end. There's a ton of rocks/mountains along with the many different trees that have these. I recall Tahraji Desert being a nightmare, as a ton of random rocks were placed around it "on their sides" so they disappeared depending even at the standard camera height.

I continue to fix these (a side tree could get rocks or 3D grass mound object or such covering the see-through end for example, or rotation normally to put the see-through part underground where it was intended) but not all can be fixed, and something like the cave entrance viewed in an odd rotation like seen above... not much can be done about.

I'd be careful with the idea to "fix the models" though, as this could lead to issues on other maps. There's some places where this see-through gets intentional usage, and I'm not sure I could remember them all. Could lead to different map issues. Not easy keeping track of everything on so many maps that I didn't initially build.

As for stuff on the characters like the helm shown above, that's... well, as a map editor I don't care what gets done with that. ;)

gvissers commented 2 years ago

Right, with that I think we're not going to make code changes to try and fix this, it's just not worth the hassle. Keeping the issue open for now in case peopke want to alert Burn to map problems like these.

feeltheburn commented 2 years ago

Not here... Better posted in Map Bugs forum: http://www.eternal-lands.com/forum/index.php?/forum/128-map-bugs/

It'll just get lost here since it'll be a few months before I consider more map work. As well, Acelon's active again and is working on some map stuff even now so he might end up doing some fixes if he sees them posted there.

gvissers commented 2 years ago

Closing as WONTFIX. Please continue to report map bugs though, our map makers can fix at least some of these issues.