The International Simutrans Forum

 

Author Topic: Broken shore texture on Pak256-Ex  (Read 1049 times)

0 Members and 1 Guest are viewing this topic.

Offline Phystam jp

  • *
  • Posts: 248
  • Pak256.Ex developer
  • Languages: JP, EN, EO
Broken shore texture on Pak256-Ex
« on: January 09, 2019, 12:03:33 PM »
Hi,

As titled, we can see many broken shore textures on Pak256-Ex, like this:


I find that this problem is from boden/grund.cc:1177
Code: [Select]
//animate
display_alpha( ground_desc_t::sea->get_image(0, wasser_t::stage), ground_desc_t::get_beach_tile( slope, water_corners ), ALPHA_RED, xpos, ypos, 0, 0, true, dirty|wasser_t::change_stage CLIP_NUM_PAR );

when I changed this part to:
Code: [Select]
//animate
display_alpha( ground_desc_t::get_water_tile(slope), ground_desc_t::get_beach_tile( slope, water_corners ), ALPHA_RED, xpos, ypos, 0, 0, true, dirty|wasser_t::change_stage CLIP_NUM_PAR );
then the shore is not bloken, like this:


Yes, I understand that this is not essential fix. I do not know the difference between "ground_desc_t::get_water_tile(slope)" and "ground_desc_t::sea->get_image(0, wasser_t::stage)", both of which returns image_id.
The difference is animation, but when I turned off the animation (stage=0), still the broken texture was seen.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 18745
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Broken shore texture on Pak256-Ex
« Reply #1 on: January 09, 2019, 12:19:39 PM »
Thank you for this. I know very little about the graphics code, as I have really not looked into this at all. Is this behaviour any different in Standard than Extended? If so, is the relevant part of the code different in Standard than Extended?

Does the code change above have any side effects? You write, "the difference is animation"; does that mean that the sea animation does not work with the substituted code?

I should be very grateful if any of the Standard developers who have knowledge of the graphics code could comment on this if any of them are able to do so.

Offline Phystam jp

  • *
  • Posts: 248
  • Pak256.Ex developer
  • Languages: JP, EN, EO
Re: Broken shore texture on Pak256-Ex
« Reply #2 on: January 09, 2019, 12:39:06 PM »
Thank you for quick response. In this part, as far as I know, There is no differences between Standard and Extended.
Actually, the difference is only refferense of image. Using function(display_alpha) is same as other slope tile. I hardly understand why the texture broken occurs...

I saw display_base_img_alpha() function in simgraph16.cc, but I cannot find where is incorrect.
I also saw ground_desc_t::sea->get_image(0, wasser_t::stage) and ground_desc_t::get_water_tile(slope) in descriptor/ground_desc.cc, but there was no suspicious part.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 18745
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Broken shore texture on Pak256-Ex
« Reply #3 on: January 09, 2019, 12:41:46 PM »
Very odd. Can I check whether there are any side effects of your code modification?

Offline Phystam jp

  • *
  • Posts: 248
  • Pak256.Ex developer
  • Languages: JP, EN, EO
Re: Broken shore texture on Pak256-Ex
« Reply #4 on: January 09, 2019, 12:54:38 PM »
the change is here: https://github.com/Phystam/simutrans-extended/tree/shore-texture-fix
In my conclusion, when we use animated water texture (obj=ground, name=Water), the shore will be broken.
On the other hand, when we use water climate texture (obj=ground, name=ClimateTexture, image[0][0]), the shore will not be broken.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 18745
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Broken shore texture on Pak256-Ex
« Reply #5 on: January 09, 2019, 01:03:12 PM »
I am still not clear; does this change break animation of the water?

Offline Phystam jp

  • *
  • Posts: 248
  • Pak256.Ex developer
  • Languages: JP, EN, EO
Re: Broken shore texture on Pak256-Ex
« Reply #6 on: January 09, 2019, 01:09:29 PM »
Only shore. on the sea or lake tile, it is still animated.

Offline Ranran jp

  • *
  • Posts: 483
  • Languages: ja
Re: Broken shore texture on Pak256-Ex
« Reply #7 on: January 09, 2019, 01:10:48 PM »
Probably that method is a wrong solution.
Originally, that tile is the animation tile, this change removes wave animation from such tile in other paksets.



For example, in pak128.Britain, this tile no longer animates.

And when it is sufficiently zoomed out, it is displayed correctly in pak256.
So I suspect It may be a issue caused by large size pakset.
If standard has 256 size pakset, I think the same symptoms may be seen.

Offline Phystam jp

  • *
  • Posts: 248
  • Pak256.Ex developer
  • Languages: JP, EN, EO
Re: Broken shore texture on Pak256-Ex
« Reply #8 on: January 09, 2019, 01:28:49 PM »
yes, I understand this solution is not essential solution and this may be one of the hint for the true solution.

when I zoomed out to 128 size, the shore is still broken...
But pak128.Britain-Ex shore is not broken, whenever I zoomed in to 256 size, actually.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 18745
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Broken shore texture on Pak256-Ex
« Reply #9 on: January 09, 2019, 05:15:26 PM »
I think that I had better not apply a fix which breaks animation of the sea on the shoreline. I will move this to the Standard bug reports section, as this appears not to be specific to Extended; other moderators: do feel free to move it back if it can be confirmed that this cannot be reproduced in Standard.

Offline Phystam jp

  • *
  • Posts: 248
  • Pak256.Ex developer
  • Languages: JP, EN, EO
Re: Broken shore texture on Pak256-Ex
« Reply #10 on: January 11, 2019, 05:23:47 AM »
I researched more --- which objects of ground_desc_t will break the shore tile.

Experiment 1: ground_desc_t::outside


Experiment 2: ground_desc_t::get_beach_tile() (red=water, green=shore, blue=land)


Probably, 'direct draw'( which means that there is no need to convert from square-size texture to tile, such as water animation and outside) tile will break the shore but 'indirect draw' (other climate texture) will not break the shore.
I will focus on 'direct draw' texture.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4601
  • Languages: EN, DE, AT
Re: Broken shore texture on Pak256-Ex
« Reply #11 on: January 11, 2019, 07:24:27 AM »
The display_alpha routines expects that the alpha map and the image contain exactly the same pixels. Maybe something is wrong with your animated sea tiles?

You could add in display_img_alpha_wc after the lines runlen = *sp++ as assertion of the type assert( runlen == *alphamap) or assert( runlen == *alphamap & ~TRANSPARENT_RUN) to debug this.

Offline Phystam jp

  • *
  • Posts: 248
  • Pak256.Ex developer
  • Languages: JP, EN, EO
Re: Broken shore texture on Pak256-Ex
« Reply #12 on: January 11, 2019, 07:55:29 AM »
Here is the source of sea tile:

Code: [Select]
#!pak256
#-------------------------------------------------------------------------------
#
#                                   Water
#
#-------------------------------------------------------------------------------
Obj=ground
Name=Water
# hangtyp * animation
Image[0][0]=../images/water-256.0.0
Image[1][0]=../images/water-256.1.0
Image[2][0]=../images/water-256.2.0
Image[3][0]=../images/water-256.3.0
Image[0][1]=../images/water-256.0.1
Image[1][1]=../images/water-256.1.1
Image[2][1]=../images/water-256.2.1
Image[3][1]=../images/water-256.3.1
Image[0][2]=../images/water-256.0.2
Image[1][2]=../images/water-256.1.2
Image[2][2]=../images/water-256.2.2
Image[3][2]=../images/water-256.3.2
Image[0][3]=../images/water-256.0.3
Image[1][3]=../images/water-256.1.3
Image[2][3]=../images/water-256.2.3
Image[3][3]=../images/water-256.3.3
--------------------------------------------------------------------------------

Offline Leartin at

  • Devotee
  • *
  • Posts: 1267
  • PAK-DEV P192C
  • Languages: DE, EN
Re: Broken shore texture on Pak256-Ex
« Reply #13 on: January 11, 2019, 08:31:03 AM »
Just in case you did not know:
Code: [Select]
Image[0-3][0-3]=../images/water-256.<$0>.<$1>Would be the same as your 16 lines. ;)

EDIT: This is not ment as solution to the problem, as it is literally the same.
« Last Edit: January 11, 2019, 10:39:36 AM by Leartin »

Offline Phystam jp

  • *
  • Posts: 248
  • Pak256.Ex developer
  • Languages: JP, EN, EO
Re: Broken shore texture on Pak256-Ex
« Reply #14 on: January 11, 2019, 09:26:53 AM »
Oh, good, it works :)
However the broken shore texture is still seen...

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4601
  • Languages: EN, DE, AT
Re: Broken shore texture on Pak256-Ex
« Reply #15 on: January 11, 2019, 11:19:43 AM »
Did you try this with the asserts that I suggested above? I suspect that these animated water tiles do not contain the same pixels as the image[0][0] in LightTexture.

Offline Phystam jp

  • *
  • Posts: 248
  • Pak256.Ex developer
  • Languages: JP, EN, EO
Re: Broken shore texture on Pak256-Ex
« Reply #16 on: January 11, 2019, 12:57:57 PM »
No, I have not...
I could find that lines but I could not understand what you say ><
I will check the light map first, and after that I will check that part in simgraph16.cc.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4601
  • Languages: EN, DE, AT
Re: Broken shore texture on Pak256-Ex
« Reply #17 on: January 11, 2019, 03:36:29 PM »
something like this
Code: [Select]
diff --git a/simutrans/trunk/display/simgraph16.cc b/simutrans/trunk/display/simgraph16.cc
index b88c2b8de..e07fc546b 100644
--- a/simutrans/trunk/display/simgraph16.cc
+++ b/simutrans/trunk/display/simgraph16.cc
@@ -3568,6 +3568,7 @@ static void display_img_alpha_wc(KOORD_VAL h, const KOORD_VAL xp, const KOORD_VA
 
                        // display image
                        uint16 runlen = *sp++;
+                       assert(runlen == *alphamap);
                        alphamap++;
 
                        do {
@@ -3576,6 +3577,7 @@ static void display_img_alpha_wc(KOORD_VAL h, const KOORD_VAL xp, const KOORD_VA
 
                                // now get colored pixels
                                runlen = ((*sp++) & ~TRANSPARENT_RUN);
+                               assert(runlen == *alphamap);
                                alphamap++;
 
                                // Hajo: something to display?

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4601
  • Languages: EN, DE, AT
Re: Broken shore texture on Pak256-Ex
« Reply #18 on: January 11, 2019, 06:27:39 PM »
You could also checkout this patch: https://forum.simutrans.com/index.php/topic,18704.msg177415.html#msg177415

It might fix the crash as well.

Offline Phystam jp

  • *
  • Posts: 248
  • Pak256.Ex developer
  • Languages: JP, EN, EO
Re: Broken shore texture on Pak256-Ex
« Reply #19 on: January 12, 2019, 01:07:16 AM »
Now the bug is fixed!
The inconsistency between lightmap tile and water tile caused the broken texture.

Before:

After:


Then the broken tile was fixed like this:


I will relase the bug fix update for pak256-Ex. Thank you so much :)