The International Simutrans Forum

 

Author Topic: Improved high stations display (foreground and background)  (Read 17409 times)

0 Members and 1 Guest are viewing this topic.

Offline gauthier

  • Devotee
  • *
  • Posts: 3629
    • SNFOS'website (in both FR and EN)
  • Languages: FR, EN, JP
Improved high stations display (foreground and background)
« on: August 15, 2013, 02:36:49 PM »
Trying to make "big" stations, I got two problems (windows 7 with makeobj 55, as the link to makeobj 55.2, provided here, is broken, playing with Simutrans 112.4 nightly - r6585 for windows (SDL version)).

First : makeobj doesn't like "frontimage[ * ][0][0][1]" (see attached picture). I don't know why ... that looks silly ... Anyway I replaced this type of frontimage by backimage.

Second : it obviously lead to graphical glitches :


I'm confused since "high" stations look possible :

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5478
  • Languages: EN, NO
Re: r6585 WIN pak128 : high stations display bug
« Reply #1 on: August 15, 2013, 07:13:09 PM »
Simutrans only support front images one level high, as the message tells you. As I understand it, front images are just a workaround to place images in front of vehicles, and vehicles aren't more than one level high either (usually much less).

The high station you post has likely been carefully crafted so that front and back images join together properly. I imagine that this is easier for standardized layouts than repeated elements that can be combined this way and that, like your station hall.

Getting all images to draw in the correct order is perhaps the biggest problem in the Simutrans renderer. It bogged down my OpenGL renderer rather seriously.

Offline gauthier

  • Devotee
  • *
  • Posts: 3629
    • SNFOS'website (in both FR and EN)
  • Languages: FR, EN, JP
Re: r6585 WIN pak128 : high stations display bug
« Reply #2 on: August 15, 2013, 07:34:00 PM »
Quote
Simutrans only support front images one level high, as the message tells you. As I understand it, front images are just a workaround to place images in front of vehicles, and vehicles aren't more than one level high either (usually much less).
That's the way I understand it too. Anyway, on the picture of my station, it's obvious that backimages placed on tile A are rendered before backimages placed on tile B while tile B is before tile A. I call that a bug, anyway perhaps it's intended ... I don't know much about Simutrans'code.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5478
  • Languages: EN, NO
Re: r6585 WIN pak128 : high stations display bug
« Reply #3 on: August 15, 2013, 07:53:27 PM »
There are some cases where Simutrans just gives up. Those are not bugs, but technical limitations. The one I know is related to slopes, which I guess could look a bit like this when some parts of the rearmost image is transparent, but it may be unrelated. The way Simutrans determines how to draw the landscape is unknown to me, too.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9460
  • Languages: De,EN,JP
Re: r6585 WIN pak128 : high stations display bug
« Reply #4 on: August 15, 2013, 08:44:37 PM »
It could be an artefact of the new code, which alaso redraw stuff to the left and front if there are ways below. Does the disappear during fast forward?

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4568
  • Languages: EN, DE, AT
Re: r6585 WIN pak128 : high stations display bug
« Reply #5 on: August 15, 2013, 08:46:39 PM »
That's the way I understand it too. Anyway, on the picture of my station, it's obvious that backimages placed on tile A are rendered before backimages placed on tile B while tile B is before tile A. I call that a bug, anyway perhaps it's intended ... I don't know much about Simutrans'code.
This should not happen if the backimage is not wider then the tile it is on. Can you upload dat/png/pak?

Offline gauthier

  • Devotee
  • *
  • Posts: 3629
    • SNFOS'website (in both FR and EN)
  • Languages: FR, EN, JP
Re: r6585 WIN pak128 : high stations display bug
« Reply #6 on: August 16, 2013, 10:40:46 AM »
It could be an artefact of the new code, which alaso redraw stuff to the left and front if there are ways below. Does the disappear during fast forward?
Yes, it does. (that's weird lol)

dat, png and paks of this station are here.

Offline gauthier

  • Devotee
  • *
  • Posts: 3629
    • SNFOS'website (in both FR and EN)
  • Languages: FR, EN, JP
Re: r6585 WIN pak128 : high stations display bug
« Reply #7 on: August 16, 2013, 10:15:12 PM »
In fact, height is not the problem ...

EDIT : Maybe it's not the same problem. A frontimage is involved here.

EDIT² : disappears with fast forward too.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9460
  • Languages: De,EN,JP
Re: r6585 WIN pak128 : high stations display bug
« Reply #8 on: August 26, 2013, 09:01:17 PM »
Disappearing with fast forward is a strong indication that the new (improved) drawing code is to blame. However, how I have to look deeper into it.

Offline gauthier

  • Devotee
  • *
  • Posts: 3629
    • SNFOS'website (in both FR and EN)
  • Languages: FR, EN, JP
Re: r6585 WIN pak128 : high stations display bug
« Reply #9 on: August 26, 2013, 10:23:58 PM »
Thanks a lot. I'm looking forward to see this glitch fixed so I can release a complete addon of train stations for pak128.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4568
  • Languages: EN, DE, AT
Re: r6585 WIN pak128 : high stations display bug
« Reply #10 on: August 31, 2013, 10:58:14 AM »
This glitch is due to the display algorithm:

To draw one station tile it does the following: (vehicles left out)
- draw its background
- draw background of connected tiles in front (south / east)
- draw foreground

The problem in your station is: the roof element that shines through is in the foreground image, whereas the roof that should be painted to hide this element is in the background image. Both things have to be either in the foreground image or both in the background image.

To fix the station you could try to move the top of the roof to the background image. The station is still high enough to not lead to glitches with trains.

Offline gauthier

  • Devotee
  • *
  • Posts: 3629
    • SNFOS'website (in both FR and EN)
  • Languages: FR, EN, JP
Re: r6585 WIN pak128 : high stations display bug
« Reply #11 on: August 31, 2013, 01:09:08 PM »
The problem in your station is: the roof element that shines through is in the foreground image
I'm not sure if I have well understood. What do you mean exactly with "foreground image" ? frontimage ?

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4568
  • Languages: EN, DE, AT
Re: r6585 WIN pak128 : high stations display bug
« Reply #12 on: August 31, 2013, 01:20:34 PM »
Sorry, foreground = front image, background = back image.

I think, if put the high roof into the back image then the glitch will disappear, hopefully.

Offline gauthier

  • Devotee
  • *
  • Posts: 3629
    • SNFOS'website (in both FR and EN)
  • Languages: FR, EN, JP
Re: r6585 WIN pak128 : high stations display bug
« Reply #13 on: August 31, 2013, 05:09:46 PM »
Quote
First : makeobj doesn't like "frontimage[ * ][0][0][1]" (see attached picture).
It's impossible, makeobj refuses that.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5478
  • Languages: EN, NO
Re: r6585 WIN pak128 : high stations display bug
« Reply #14 on: August 31, 2013, 05:32:32 PM »
It's impossible, makeobj refuses that.
That was the statement for front image, the suggestion was to use back image. I'm not sure that's a valid suggestion, though.

Offline gauthier

  • Devotee
  • *
  • Posts: 3629
    • SNFOS'website (in both FR and EN)
  • Languages: FR, EN, JP
Re: r6585 WIN pak128 : high stations display bug
« Reply #15 on: August 31, 2013, 10:16:45 PM »
Well ... Maybe I'm misunderstanding something. Although, I already put everything in backimage as I can't use frontimage.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4568
  • Languages: EN, DE, AT
Re: r6585 WIN pak128 : high stations display bug
« Reply #16 on: September 01, 2013, 07:17:57 AM »
You should try to move more pixels to the backimage: in particular the complete roof of the high station building.

Edit: could not pak your image ???

You should try to move the high roof sections of these images
Code: [Select]
frontimage[0][0][0][0][0]=SNFOSstations3.2.6
frontimage[1][0][0][0][0]=SNFOSstations3.2.7
frontimage[8][0][0][0][0]=SNFOSstations3.5.0
frontimage[9][0][0][0][0]=SNFOSstations3.5.1
frontimage[10][0][0][0][0]=SNFOSstations3.5.2
frontimage[11][0][0][0][0]=SNFOSstations3.5.3
frontimage[12][0][0][0][0]=SNFOSstations3.5.4
frontimage[13][0][0][0][0]=SNFOSstations3.5.5
frontimage[14][0][0][0][0]=SNFOSstations3.5.6
frontimage[15][0][0][0][0]=SNFOSstations3.5.7
into the corresponding backimages.
« Last Edit: September 01, 2013, 09:43:20 AM by Dwachs »

Offline gauthier

  • Devotee
  • *
  • Posts: 3629
    • SNFOS'website (in both FR and EN)
  • Languages: FR, EN, JP
Re: r6585 WIN pak128 : high stations display bug
« Reply #17 on: September 02, 2013, 11:36:22 AM »
I moved the part of frontimage which was drawn over (a 32px high rectangle on top of it), but it just moved the problem downward. I could move a better shaped part, though this is going really tedious, not only for me but for anyone trying to make high stations. I would do that if there's no other way to fix the glitch but I'd like to know first if coders have found an easy way to do it.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5478
  • Languages: EN, NO
Re: r6585 WIN pak128 : high stations display bug
« Reply #18 on: September 02, 2013, 03:11:06 PM »
It seems to me that the only part of the roof structure that needs to be in the front image is the right hand pillar, the crossbeam from it and to slightly beyond the wires and perhaps the lowest part of the vertical beam in the middle. Smoke from the trains might seep through the roof in an odd fashion, though.

Offline greenling

  • Lounger
  • *
  • Posts: 1728
  • Simutransarchology it my hobby!
  • Languages: DE,EN
Re: r6585 WIN pak128 : high stations display bug
« Reply #19 on: September 15, 2013, 06:47:53 PM »
Hello gauthier
The Station looks very good out.

Offline gauthier

  • Devotee
  • *
  • Posts: 3629
    • SNFOS'website (in both FR and EN)
  • Languages: FR, EN, JP
Re: r6585 WIN pak128 : high stations display bug
« Reply #20 on: September 17, 2013, 05:33:19 PM »
Thanks Greenling. It's really sad to be bothered with this bug.

It seems to me that the only part of the roof structure that needs to be in the front image is the right hand pillar, the crossbeam from it and to slightly beyond the wires and perhaps the lowest part of the vertical beam in the middle. Smoke from the trains might seep through the roof in an odd fashion, though.
Unfortunately, I got back to studies, so I don't have much time to work on this again. I will tell you if there are news about this.

Disappearing with fast forward is a strong indication that the new (improved) drawing code is to blame. However, how I have to look deeper into it.
Why not just using the same drawing code for not-fast-forward mode ?

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5478
  • Languages: EN, NO
Re: r6585 WIN pak128 : high stations display bug
« Reply #21 on: September 17, 2013, 05:43:13 PM »
Why not just using the same drawing code for not-fast-forward mode ?

Unless someone has done something really strange, it's because the fast-forward drawing mode sacrifices accuracy for speed. While it makes your station look good on its own, other things (likely vehicles) will be drawn wrong in relation to each other.

Offline gauthier

  • Devotee
  • *
  • Posts: 3629
    • SNFOS'website (in both FR and EN)
  • Languages: FR, EN, JP
Re: r6585 WIN pak128 : high stations display bug
« Reply #22 on: September 19, 2013, 04:34:58 PM »
It seems to me that the only part of the roof structure that needs to be in the front image is the right hand pillar, the crossbeam from it and to slightly beyond the wires and perhaps the lowest part of the vertical beam in the middle. Smoke from the trains might seep through the roof in an odd fashion, though.
Though, even if I'm able to fix the problem with each type of station alone, it would still be a mess if I use different stations together (see attached picture).

I still think there is a problem in the drawing code.
Quote
it's obvious that backimages placed on tile A are rendered before backimages placed on tile B while tile B is before tile A.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4568
  • Languages: EN, DE, AT
Re: r6585 WIN pak128 : high stations display bug
« Reply #23 on: September 19, 2013, 04:47:06 PM »
? Whats the problem in the picture you posted (besides the filename) ?

Edit:  If the graphics overlaps to neighboring tiles then glitches can appear.
« Last Edit: September 19, 2013, 04:52:30 PM by Dwachs »

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5478
  • Languages: EN, NO
Re: r6585 WIN pak128 : high stations display bug
« Reply #24 on: September 19, 2013, 05:50:50 PM »
There are unsolved problems in the drawing code, that is well known. We just haven't figured out how to solve all problems. The odd drawing algorithm causing problems here is likely to solve another problem.

Offline gauthier

  • Devotee
  • *
  • Posts: 3629
    • SNFOS'website (in both FR and EN)
  • Languages: FR, EN, JP
Re: r6585 WIN pak128 : high stations display bug
« Reply #25 on: September 28, 2013, 07:46:21 PM »
? Whats the problem in the picture you posted (besides the filename) ?

Edit:  If the graphics overlaps to neighboring tiles then glitches can appear.

Offline Fabio

  • Devotee
  • Administrator
  • *
  • Posts: 2898
  • The Pak128 Guy
    • Visit me on Facebook
  • Languages: EN, IT, RO, FR
Re: r6585 WIN pak128 : high stations display bug
« Reply #26 on: October 17, 2013, 11:34:42 AM »
Couldn't front images be allowed also for a second tile height?
Would it cause worse glitches?

I'm experimenting a new station concept:

Here all roof is painted in a higher tile and then lowered with offsets. Thus, hiding buildings (normal or smart hiding) will hide the roof showing what's below. It might allow better results with non transparent roofs.
Also I believed that the upper tile background is painted above the lower tile foreground (and vehicles, of course!), but apparently it's not that way. :-[

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4568
  • Languages: EN, DE, AT
Re: Improved high stations display (foreground and background)
« Reply #27 on: October 17, 2013, 11:51:41 AM »
The drawing order on one tile is: all backimages, then all front images.

Offline Fabio

  • Devotee
  • Administrator
  • *
  • Posts: 2898
  • The Pak128 Guy
    • Visit me on Facebook
  • Languages: EN, IT, RO, FR
Re: Improved high stations display (foreground and background)
« Reply #28 on: October 17, 2013, 12:35:02 PM »
Hence, any chance of front image for higher tiles? ???

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5478
  • Languages: EN, NO
Re: Improved high stations display (foreground and background)
« Reply #29 on: October 17, 2013, 03:02:07 PM »
For what? Front images are there to appear in front of vehicles. Do you have multistory vehicles?

Offline Fabio

  • Devotee
  • Administrator
  • *
  • Posts: 2898
  • The Pak128 Guy
    • Visit me on Facebook
  • Languages: EN, IT, RO, FR
Re: Improved high stations display (foreground and background)
« Reply #30 on: October 17, 2013, 04:10:03 PM »
For what? Front images are there to appear in front of vehicles. Do you have multistory vehicles?

See:
I'm experimenting a new station concept:

Here all roof is painted in a higher tile and then lowered with offsets. Thus, hiding buildings (normal or smart hiding) will hide the roof showing what's below. It might allow better results with non transparent roofs.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4568
  • Languages: EN, DE, AT
Re: Improved high stations display (foreground and background)
« Reply #31 on: October 17, 2013, 06:28:02 PM »
This picture does not tell much? What are you trying to say?

Offline VS

  • Senior Plumber (Devotee)
  • Devotee
  • *
  • Posts: 4855
  • Vladimír Slávik
    • VS's Simutrans site
  • Languages: CS,EN
Re: Improved high stations display (foreground and background)
« Reply #32 on: October 17, 2013, 08:05:41 PM »
Fabio wants a station that "opens its roof" when you hide buildings. Since that works by hiding images higher than ground level, he put roofs into that second level.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5478
  • Languages: EN, NO
Re: Improved high stations display (foreground and background)
« Reply #33 on: October 17, 2013, 08:11:33 PM »
That's in serious risk of running into all kinds of problems. Higher level images are assumed to be higher level. If there aren't features based on such assumptions now, there might be in the future. It's certainly an assumptions in my not so successful attempts at hardware rendering.

Offline gauthier

  • Devotee
  • *
  • Posts: 3629
    • SNFOS'website (in both FR and EN)
  • Languages: FR, EN, JP
Re: Improved high stations display (foreground and background)
« Reply #34 on: October 21, 2013, 07:32:13 PM »
The drawing order on one tile is: all backimages, then all front images.
That's the point.
Drawing backimage then frontimage for each tile individually (and then, draw tiles from north-west to south-east) would be more appropriate and would solve the problem.

By the way, see the attached picture : there are also problems involving other structures (bridges here).