News:

Simutrans.com Portal
Our Simutrans site. You can find everything about Simutrans from here.

Improved high stations display (foreground and background)

Started by gauthier, August 15, 2013, 02:36:49 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

prissi

This cannot be solved, since the pillar and the station are on the same tile. Simutrans could only forbid to build that.

gauthier

Quote from: prissi on October 21, 2013, 07:38:33 PM
This cannot be solved, since the pillar and the station are on the same tile. Simutrans could only forbid to build that.
Eeer ... no, they are not on the same tile. The station is on a tile before pillar's one.

Dwachs

Quote from: gauthier on October 21, 2013, 07:32:13 PM
By the way, see the attached picture : there are also problems involving other structures (bridges here).
This is a limitation of the pillar graphics system: you cannot have pillars that have graphics left and right of the track on the same tile. For asymmetric-pillars, all the graphics of the pillar has to be in front of the tracks.

The 'bug' in this post
http://forum.simutrans.com/index.php?topic=12363.msg125195#msg125195
is a glitch in the graphics itself. You cannot expect that a station building overlaps another building that is in front of the first one.

Edit: regarding the original extension request. As the original problem is that  the front image contains too much stuff, the bug will not disappear if higher front images would be possible and more could be put into front images, it would only get worse.
Parsley, sage, rosemary, and maggikraut.

gauthier

QuoteThe 'bug' in this post
http://forum.simutrans.com/index.php?topic=12363.msg125195#msg125195
is a glitch in the graphics itself. You cannot expect that a station building overlaps another building that is in front of the first one.
I don't understand what is exactly your point here. Could you explain please ?

Dwachs

Quote from: gauthier on December 19, 2013, 07:47:20 PM
I don't understand what is exactly your point here. Could you explain please ?
Hm. Maybe this is because I did not understood what actually is the bug there. Could you please explain what you expect to see there?
Parsley, sage, rosemary, and maggikraut.

gauthier

bridge (the bridge itself, its pillar aren't involved here) is on a tile which is "farther" (north-westward) from the player than the tile which has the station on it. I expect to see the station being displayed before the bridge, but it's not.

As far as I understood, the current drawing system draws all back images, then all front images. Maybe this is nice in theory, surely it leads to graphical glitches like the ones I posted here.

I suggest(ed) two solutions :
_ draw back image, then front image, of each tile individually. If this solution doesn't work, tell me why so I can think to another solution.
_ use the same drawing system as the one which works during fast forward and which doesn't lead to the graphical glitches I posted. (maybe it's the same solution as above ?). I would also like you to tell why this solution can't be implemented.

You told me it is a problem in my graphics, so attached a picture with the same glitch, with a station from the official pak128.

Ters

Quote from: gauthier on December 20, 2013, 09:00:03 PM
As far as I understood, the current drawing system draws all back images, then all front images.

No it doesn't, because that won't work at all. There is some other algorithm at play, which I can only assume has been made to solve a problem. But the pillar problem exists regardless of that: it can't be both in front of and behind vehicles. The only solution for that is to give pillars backimages and frontimages. This would likely solve this station problem as well.

Dwachs

gauthier, I meant this post:
http://forum.simutrans.com/index.php?topic=12363.msg125195#msg125195
Something with stations.

The bridge problem is sort of known, it has to do with the fact that bridge pillars only have either front or back images.

Quote from: gauthier on December 20, 2013, 09:00:03 PM
As far as I understood, the current drawing system draws all back images, then all front images. Maybe this is nice in theory, surely it leads to graphical glitches like the ones I posted here.

I suggest(ed) two solutions :
_ draw back image, then front image, of each tile individually. If this solution doesn't work, tell me why so I can think to another solution.
_ use the same drawing system as the one which works during fast forward and which doesn't lead to the graphical glitches I posted. (maybe it's the same solution as above ?). I would also like you to tell why this solution can't be implemented.

The drawing algorithm does the following. Consider this situation

W   N
  X
S    E

When drawing tile X it does:
(1) draw background of neighbour tiles W and N, but only those pixels that are over the tile X
(2) draw background images of objects on X, but only those pixels that are over the tile X
(3) draw background images of neighbour tiles S and E, but only those pixels that are over the tile X
(4) draw vehicles in a certain way (does not apply here), but only those pixels that are over the tile X
(5) draw complete front images of tile X

Of course, this algorithm still has problems: long vehicles on crossings; problems with pillars of elevated ways; problems with pedestrians, buses and trams on one tile; airplanes over bridges; maybe more.

The original glitch (first post) is due to the steps (3) and (5): there are pixels in the front image on X that are supposed to be overdrawn by pixels in front images of tiles S/E, which does not work. Hence my advise to put as much of the image into the back image.

Your suggestion seems to be to use the same algorithm as is used in fast-forward mode. This would be: draw back images on tile X, then all front images (steps (1) and (3) left out). However, this algorithm produces a lot of glitches with long vehicles. It is the same algorithm used in versions before 110.0. I think you can force simutrans to use this algorithm with changing some settings.
Parsley, sage, rosemary, and maggikraut.

gauthier

Quote from: Dwachs on December 21, 2013, 07:35:21 PM
gauthier, I meant this post:
http://forum.simutrans.com/index.php?topic=12363.msg125195#msg125195
Something with stations.

The bridge problem is sort of known, it has to do with the fact that bridge pillars only have either front or back images.

The drawing algorithm does the following. Consider this situation

W   N
  X
S    E

When drawing tile X it does:
(1) draw background of neighbour tiles W and N, but only those pixels that are over the tile X
(2) draw background images of objects on X, but only those pixels that are over the tile X
(3) draw background images of neighbour tiles S and E, but only those pixels that are over the tile X
(4) draw vehicles in a certain way (does not apply here), but only those pixels that are over the tile X
(5) draw complete front images of tile X

Of course, this algorithm still has problems: long vehicles on crossings; problems with pillars of elevated ways; problems with pedestrians, buses and trams on one tile; airplanes over bridges; maybe more.

The original glitch (first post) is due to the steps (3) and (5): there are pixels in the front image on X that are supposed to be overdrawn by pixels in front images of tiles S/E, which does not work. Hence my advise to put as much of the image into the back image.

Your suggestion seems to be to use the same algorithm as is used in fast-forward mode. This would be: draw back images on tile X, then all front images (steps (1) and (3) left out). However, this algorithm produces a lot of glitches with long vehicles. It is the same algorithm used in versions before 110.0. I think you can force simutrans to use this algorithm with changing some settings.
Well, at least we finally got to understand each other :) . Thus I have a much better view on the problem. I'm going to try some changes on my stations and tell you about the results.

gauthier

Hi again.

After some attempts to fix this glitch from the source images, I am finally unable to solve the problem with more-than-one-square-high stations, anyway I solved the other glitches as you can see in the three first following pictures (2 linked and 1 attached).

Another problem : fixing these (by moving the shelter formerly in backimage into frontimage), a glitch with smokes appeared (see the second attached picture). I also noticed other glitches which seem to have the same cause (see the two next and last attached pictures)

I thought about the drawing algorithm and came up with a simple idea. In spite of my programming skills, I still never worked around with Simutrans'code and I have very few experience with C++, so perhaps this idea is stupid ... anyway :

I noticed two facts :
_ The program is able to do some carving in images ("(1) draw background of neighbour tiles W and N, but only those pixels that are over the tile X") - yes it can be obvious for you, but not for me :p
_ With a very simple algorithm like I proposed earlier (Drawing backimage then frontimage for each tile individually (and then, draw tiles from north-west to south-east), drawing everything in the right order on each tile), all should work nice (if not, please give me an example) until vehicles come as they are often over two (ore more) tiles at the same time.

My idea consists in drawing everything like said in the previous point except for when it comes to drawing vehicles. At this moment, doing some carving with the vehicles (draw only the part of the vehicle which is over a tile on this tile) should prevent glitches from displaying.

To sum up :
On each tile, from the top left (or right ... as you wish) one to the bottom right (or left) one on the screen, and eventually lower than the bottom of the screen for high buildings located there :
1) draw the terrain if necessary
2) draw the way if there's one
3) draw backimages (signal, station, or whatever, or simple building)
4) draw vehicles : only the part that are on the tile (it's probably a little performance-saving to say only the part below the two top lines of the tile)
5) draw vehicles'smoke : [...]
5) draw frontimages ([...])
6) did I forget anything ?

Last : the pictures :




Ters

Quote from: gauthier on August 30, 2014, 09:12:34 PM
6) did I forget anything ?

What's the performance hit of doing the rendering more complex?

gauthier

Quote(it's probably a little performance-saving to say only the part below the two top lines of the tile)
That implies a little less image carving than "the part on the tile", though not a big deal. Parts under the tile limit would be overdrawn by next tiles, so there's no need to carve it. That's what I'm saying. I did not compare performance of this algorithm to that of the current drawing algorithm (and I have no idea which one would be the best regarding performance).

Anyway, thinking about that last night, I just realized there's a glitch in what I said, backimage of a tile would draw on a small part of vehicle placed on this tile and the tile behind. Would it be possible to carve parts of vehicles over the backimages of a tile instead of over the tile itself ?