raduprv / Eternal-Lands

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

2d objects not showing at all in unknown circumstances #88

Closed feeltheburn closed 3 years ago

feeltheburn commented 3 years ago

Below is at 235, 280 in Iscalrith (map id 85).

I was going to use 2d objects to clean up the jagged unnatural ground tiling as seen by the red line in the client view.

I opened up the map in the editor to see what you see on the left... that there's already a ton of 2d objects covering up the jagged line. They're just not showing in the client view.

Now those are from the original mapmaker from when the map was added, not me.

However, I added a 2d object (marked with the green arrow) to the map and reloaded the client, and IT appeared. Though still no sign of the older 2d objects.

I checked that they're linking to correct 2d images, and the one I added is one used a lot along the jagged line.

The confusing part is that SOME old 2d objects are showing on the map. You can see a couple snow ones along the jagged line, and (it's outside of the client view but) the 2d dark grass in the top right of the map editor is showing in the client.

It's possible this phenomenon occurs elsewhere, but I honestly haven't noticed it until this, and I've done a lot of 2d work on most every map fixing "flickering".

Isca-bad-2d

I'm having a hard time finding other maps to confirm this, as on other snow maps, 3d snow mounds are used to cover ground tile jaggedness rather than 2d as seen here.

feeltheburn commented 3 years ago

Yeah, I can't say for certain this isn't an issue elsewhere but for now I can't find any other maps showing this issue, at least not in any obvious manner.

If the problem can't be found, I'll just fix it up the way the other cold maps are, with 3d objects. Or redoing the 2d objects since adding new ones seems to work.

gvissers commented 3 years ago

Huh, interesting.I can confirm this issue. I'll try to see if I can figure out what's causing the objects to not show on the client.

gvissers commented 3 years ago

The objects are correctly read and stored in the map data structure, but it looks that when it's time to draw them, they aren't found by the bounding box intersection code. As to why that is, I do not yet know. Looks like I'll be working through a few thousand lines of not very approachable code. Joy! :wink:

feeltheburn commented 3 years ago

A JSON dump of the elm file doesn't show anything unusual. Below is the JSON info of a non-showing snow2 object, and a showing grass object.

The 2d0 file itself is not the issue, as the same 2d0 appears in other locations. No other elm details seen below seem to be abnormal.

The full JSON dump can be seen here if needed for some reason: https://burningdownthe.net/tempstuff/cont2map24.txt (~7.8MB)

` INVISIBLE 2D OBJECT: 'entity_name' => './2dobjects/ground/snow2.2d0', '__unused' => [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], 'rotation' => [ '0', '0', '-100' ], 'id' => 48, 'position' => [ '118.510810852051', '140.991088867188', '0.0209999997168779' ]

VISIBLE 2D OBJECT

                            'position' => [
                                            '115.740310668945',
                                            '127.664520263672',
                                            '0.0109999999403954'
                                          ],
                            'id' => 456,
                            'rotation' => [
                                            '0',
                                            '0',
                                            '-50'
                                          ],
                            '__unused' => [
                                            0,
                                            0,
                                            0,
                                            0,
                                            0,
                                            0,
                                            0,
                                            0,
                                            0,
                                            0,
                                            0,
                                            0,
                                            0,
                                            0,
                                            0,
                                            0,
                                            0,
                                            0,
                                            0,
                                            0,
                                            0,
                                            0,
                                            0,
                                            0
                                          ],
                            'entity_name' => './2dobjects/ground/grass3.2d0'`
gvissers commented 3 years ago

they aren't found by the bounding box intersection code.

Or I might be a complete idiot. Looks like the bbox tree is fine (on the plus side: I learned a lot today wading through the code :)). The problem seems to be in multitexturing. Turn off cloud shadow and shadow mapping, and the objects appear also in the game client. Enable multitexturing in the map editor, and they disappear there. I'll try to investigate what goes wrong, but I'm far from an expert in OpenGL, so if anyone has any ideas, I'd love to hear them.

feeltheburn commented 3 years ago

I can only barely comprehend some of the code because I learned Perl so I can understand some basic coding, but actually trying to write anything in-depth for the client would be impossible here.

That is a very odd bug though. Especially since it doesn't effect all 2d objects.

gvissers commented 3 years ago

Well, that was a right pain to track down. Have I mentioned I am not remotely an expert in OpenGL?

Looks like the alpha value of the parts of the 2D objects that are darkened by clouds was lowered in the whole multitexturing process. This is mostly noticeable on snow objects, as the alpha cutoff value in the 2d0 file is quite high for these (0.9). As a result, most of the objects just disappeared completely.

I have committed a fix. It is only lightly tested here, and I am not altogether confidant that is the right fix. It seems to work here in all scenarios (w/ or w/o shadow mapping, day and night), but please test if I did not mess something else up.

feeltheburn commented 3 years ago

Seems good so far.

I'll close, re-open if any issues come up.