The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: Phystam on January 09, 2019, 12:03:33 PM

Title: Broken shore texture on Pak256-Ex
Post by: Phystam on January 09, 2019, 12:03:33 PM
Hi,

As titled, we can see many broken shore textures on Pak256-Ex, like this:
(https://cdn.discordapp.com/attachments/514739526330220547/532524913056284683/f202e46a8935124e.PNG)

I find that this problem is from boden/grund.cc:1177

//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:

//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:
(https://cdn.discordapp.com/attachments/514739526330220547/532527572790149146/16684857160dee1b.PNG)

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.
Title: Re: Broken shore texture on Pak256-Ex
Post by: jamespetts 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.
Title: Re: Broken shore texture on Pak256-Ex
Post by: Phystam 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.
Title: Re: Broken shore texture on Pak256-Ex
Post by: jamespetts on January 09, 2019, 12:41:46 PM
Very odd. Can I check whether there are any side effects of your code modification?
Title: Re: Broken shore texture on Pak256-Ex
Post by: Phystam on January 09, 2019, 12:54:38 PM
the change is here: https://github.com/Phystam/simutrans-extended/tree/shore-texture-fix (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.
Title: Re: Broken shore texture on Pak256-Ex
Post by: jamespetts on January 09, 2019, 01:03:12 PM
I am still not clear; does this change break animation of the water?
Title: Re: Broken shore texture on Pak256-Ex
Post by: Phystam on January 09, 2019, 01:09:29 PM
Only shore. on the sea or lake tile, it is still animated.
Title: Re: Broken shore texture on Pak256-Ex
Post by: Ranran(retired) 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.
(https://i.imgur.com/tze4VAY.png)

(https://i.imgur.com/Yac5hwg.png)
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.
Title: Re: Broken shore texture on Pak256-Ex
Post by: Phystam 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.
Title: Re: Broken shore texture on Pak256-Ex
Post by: jamespetts 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.
Title: Re: Broken shore texture on Pak256-Ex
Post by: Phystam 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
(https://cdn.discordapp.com/attachments/514739526330220547/533152214282403850/outside.png)

Experiment 2: ground_desc_t::get_beach_tile() (red=water, green=shore, blue=land)
(https://cdn.discordapp.com/attachments/514739526330220547/533152211971080203/test1.png)

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.
Title: Re: Broken shore texture on Pak256-Ex
Post by: Dwachs 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.
Title: Re: Broken shore texture on Pak256-Ex
Post by: Phystam on January 11, 2019, 07:55:29 AM
Here is the source of sea tile:
(https://cdn.discordapp.com/attachments/514739526330220547/533191813389877248/water-256.png)

#!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
--------------------------------------------------------------------------------
Title: Re: Broken shore texture on Pak256-Ex
Post by: Leartin on January 11, 2019, 08:31:03 AM
Just in case you did not know:
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.
Title: Re: Broken shore texture on Pak256-Ex
Post by: Phystam on January 11, 2019, 09:26:53 AM
Oh, good, it works :)
However the broken shore texture is still seen...
Title: Re: Broken shore texture on Pak256-Ex
Post by: Dwachs 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.
Title: Re: Broken shore texture on Pak256-Ex
Post by: Phystam 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.
Title: Re: Broken shore texture on Pak256-Ex
Post by: Dwachs on January 11, 2019, 03:36:29 PM
something like this

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?
Title: Re: Broken shore texture on Pak256-Ex
Post by: Dwachs 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.
Title: Re: Broken shore texture on Pak256-Ex
Post by: Phystam 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:
(https://cdn.discordapp.com/attachments/514739526330220547/533448637267574794/ground-shade-256-old.png)
After:
(https://cdn.discordapp.com/attachments/514739526330220547/533448633950142464/ground-shade-256.png)

Then the broken tile was fixed like this:
(https://cdn.discordapp.com/attachments/514739526330220547/533447943814905866/3436afc6b34d5a2b.PNG)

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