News:

Simutrans Wiki Manual
The official on-line manual for Simutrans. Read and contribute.

Broken shore texture on Pak256-Ex

Started by Phystam, January 09, 2019, 12:03:33 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Phystam

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

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


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.

jamespetts

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.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Phystam

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.

jamespetts

Very odd. Can I check whether there are any side effects of your code modification?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Phystam

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.

jamespetts

I am still not clear; does this change break animation of the water?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Phystam

Only shore. on the sea or lake tile, it is still animated.

Ranran

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.

Phystam

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.

jamespetts

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.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Phystam

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.

Dwachs

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.
Parsley, sage, rosemary, and maggikraut.

Phystam

Here is the source of sea tile:


#!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
--------------------------------------------------------------------------------

Leartin

#13
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.

Phystam

Oh, good, it works :)
However the broken shore texture is still seen...

Dwachs

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.
Parsley, sage, rosemary, and maggikraut.

Phystam

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.

Dwachs

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?
Parsley, sage, rosemary, and maggikraut.

Dwachs

Parsley, sage, rosemary, and maggikraut.

Phystam

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