Long vehicles + other graphic bugs (32 bpp)

Discussions about the technical aspects of graphics development, including NewGRF tools and utilities.

Moderator: Graphics Moderators

Post Reply
User avatar
stefino_cz
Transport Coordinator
Transport Coordinator
Posts: 268
Joined: 02 Jul 2015 08:05
Location: Czech Republic
Contact:

Long vehicles + other graphic bugs (32 bpp)

Post by stefino_cz »

Hey guys. I found this bug in graphic. I made new bus stop and rear sprite gives this bug. I know, that it is caused due long vehicle. But - is there any way how to fix it? On my new 32bpp vehicles I have invisible parts at front and rear part of the vehicle to avoid clashes. But the problem is still there. It looks like main part of the sprite has to be in" contact" with sprite - in this case sprite of bus stop - to bring vehicle above the bus stop sprite. And second part of the question - why this bug appear only at one side of bus stop? Thanks
bug.png
(1.24 MiB) Not downloaded yet
Last edited by stefino_cz on 18 Apr 2017 08:13, edited 1 time in total.
Image
TadeuszD
Transport Coordinator
Transport Coordinator
Posts: 329
Joined: 07 Nov 2011 19:32
Location: PL

Re: Long vehicles - graphic bug?

Post by TadeuszD »

stefino_cz wrote:It looks like main part of the sprite has to be in" contact" with sprite - in this case sprite of bus stop - to bring vehicle above the bus stop sprite. And second part of the question - why this bug appear only at one side of bus stop?
It happens, bacause OTTD is not real 3D game. The 3-rd dimension is created using sprite sorter, which determines the order of sprite drawing. Typically sprites are drawn from the farthest to the nearest.
In your two 'red' cases the bus is logically located on the further tile than the bus stop tile. It causes that the bus is drawn earlier than the bus stop.
Image
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: Long vehicles - graphic bug?

Post by Alberth »

Lots of details about this in bug 119: https://bugs.openttd.org/task/119
Bottom line: It's not really fixable in the current implementation.

If you really want to fix it, I think your best shot may be with an opengl z-buffer (but no idea if it will fly), but using opengl has a s*** of problems on its own too.
Being a retired OpenTTD developer does not mean I know what I am doing.
User avatar
stefino_cz
Transport Coordinator
Transport Coordinator
Posts: 268
Joined: 02 Jul 2015 08:05
Location: Czech Republic
Contact:

Re: Long vehicles - graphic bug?

Post by stefino_cz »

Okey :) Thanks for answers. And similar question - about tram troley. This is the same problem?
ottdd.jpg
(598.54 KiB) Not downloaded yet
Image
TadeuszD
Transport Coordinator
Transport Coordinator
Posts: 329
Joined: 07 Nov 2011 19:32
Location: PL

Re: Long vehicles - graphic bug?

Post by TadeuszD »

stefino_cz wrote:about tram troley. This is the same problem?
Yes, it is.
Technically, you can fix some problems with described glitches by splitting long vehicle into two or more shorter vehicles with custom sprites. But it needs A LOT OF CODE to prevent other glitches, for example - when the vehicle turns.
Image
User avatar
stefino_cz
Transport Coordinator
Transport Coordinator
Posts: 268
Joined: 02 Jul 2015 08:05
Location: Czech Republic
Contact:

Re: Long vehicles - graphic bug?

Post by stefino_cz »

Yes, I understand :) I think, that it is OK and if I dont like "sprite-flashing" in case of street drawings on bus stop, I'll remove it :)
Image
User avatar
stefino_cz
Transport Coordinator
Transport Coordinator
Posts: 268
Joined: 02 Jul 2015 08:05
Location: Czech Republic
Contact:

Re: Long vehicles - graphic bug?

Post by stefino_cz »

One more question again. If I have articulated train of 3 parts for example, I define 3 parts and in the end I merge it together into one unit. But in purchase menu are these 3 parts and one final unit. How to show these 3 parts? My code here - I have long vehicles so need 2 invisible parts in front and rear part of the vehicle - due vehicle graphic clash.

Tatra T3 Single is finished without 2 invisible parts. Is here any way how to put them into exist code or I have to make new vehicle like Tatra T3 double?
Tatra T3 Double is finished but as I wrote - I have in purchase menu all 4 parts.
----------------------------------
// define the newgrf
grf {
grfid: "MI\02\02";
name: string(STR_GRF_NAME);
desc: string(STR_GRF_DESC);
version: 1;
min_compatible_version: 1;
}

template template_PLACEHOLDER () {
[0, 0, 64, 64, -32, -32]
[0, 0, 64, 64, -32, -32]
[0, 0, 64, 64, -32, -32]
[0, 0, 64, 64, -32, -32]
[0, 0, 64, 64, -32, -32]
[0, 0, 64, 64, -32, -32]
[0, 0, 64, 64, -32, -32]
[0, 0, 64, 64, -32, -32]
}

template template_tram_T3() {
//[left_x, upper_y, width, height, offset_x, offset_y]
[0, 0, 57, 114, -46, -49]
[70, 0, 140, 100, -90, -45]
[220, 0, 180, 65, -84, -43]
[405, 0, 139, 90, -65, -36]
[550, 0, 56, 111, -36, -49]
[625, 0, 139, 90, -92, -35]
[770, 0, 179, 64, -84, -37]
[960, 0, 140, 99, -67, -45]
}

//Invisible_1


spriteset(spriteset_invisible_1, "gfx/PLACEHOLDER.png") {
template_PLACEHOLDER()
}


item (FEAT_ROADVEHS, item_invisible_1) {
property {
name: string(STR_NAME_INVISIBLE_1); //název z .lng
introduction_date: date(1700,1,1);
model_life: VEHICLE_NEVER_EXPIRES;
retire_early: 0;
vehicle_life: 100;
loading_speed: 100;
cost_factor: 0;
running_cost_factor: 112;
speed: 300 km/h;
power: 966 hp;
weight: 0 ton;
length: 3;
cargo_capacity: 0;
tractive_effort_coefficient: 0.5;
air_drag_coefficient: 0;
//sound_effect: no sound
//visual_effect: use default (none)

//callback_flags: no need to set this
reliability_decay: 20;
climates_available: ALL_CLIMATES;
refittable_cargo_classes: bitmask(CC_PASSENGERS);
sprite_id: SPRITE_ID_NEW_ROADVEH; //use custom sprites
misc_flags: bitmask(ROADVEH_FLAG_TRAM); //make this a tram
refit_cost: 0; //refits are free
running_cost_base: RUNNING_COST_ROADVEH;
}

graphics {
default: spriteset_invisible_1; // default graphic
}


}

//Invisible_2


spriteset(spriteset_invisible_2, "gfx/PLACEHOLDER.png") {
template_PLACEHOLDER()
}


item (FEAT_ROADVEHS, item_invisible_2) {
property {
name: string(STR_NAME_INVISIBLE_2); //název z .lng
introduction_date: date(1700,1,1);
model_life: VEHICLE_NEVER_EXPIRES;
retire_early: 0;
vehicle_life: 100;
loading_speed: 100;
cost_factor: 0;
running_cost_factor: 112;
speed: 300 km/h;
power: 966 hp;
weight: 0 ton;
length: 4;
cargo_capacity: 0;
tractive_effort_coefficient: 0.5;
air_drag_coefficient: 0;
//sound_effect: no sound
//visual_effect: use default (none)

//callback_flags: no need to set this
reliability_decay: 20;
climates_available: ALL_CLIMATES;
refittable_cargo_classes: bitmask(CC_PASSENGERS);
sprite_id: SPRITE_ID_NEW_ROADVEH; //use custom sprites
misc_flags: bitmask(ROADVEH_FLAG_TRAM); //make this a tram
refit_cost: 0; //refits are free
running_cost_base: RUNNING_COST_ROADVEH;
}

graphics {
default: spriteset_invisible_2; // default graphic
}


}


//TATRA T3 Single


spriteset(spriteset_tatra_t3_default, "gfx/PLACEHOLDER.png") {
template_PLACEHOLDER()
}
alternative_sprites(spriteset_tatra_t3_default, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP, "gfx/tramset.png") {
template_tram_T3()
}

item (FEAT_ROADVEHS, item_tram_tatra_t3) {
property {
name: string(STR_NAME_TATRA_T3); //název z .lng
introduction_date: date(1962,1,1);
model_life: VEHICLE_NEVER_EXPIRES;
retire_early: 0;
vehicle_life: 25;
loading_speed: 25;
cost_factor: 224;
running_cost_factor: 112;
speed: 65 km/h;
power: 966 hp;
weight: 16 ton;
length: 8;
cargo_capacity: 60;
tractive_effort_coefficient: 0.5;
air_drag_coefficient: 0;
//sound_effect: no sound
//visual_effect: use default (none)

//callback_flags: no need to set this
reliability_decay: 20;
climates_available: ALL_CLIMATES;
refittable_cargo_classes: bitmask(CC_PASSENGERS);
sprite_id: SPRITE_ID_NEW_ROADVEH; //use custom sprites
misc_flags: bitmask(ROADVEH_FLAG_TRAM); //make this a tram
refit_cost: 0; //refits are free
running_cost_base: RUNNING_COST_ROADVEH;
}

graphics {
default: spriteset_tatra_t3_default; // default graphic
}


}




//TATRA T3 Double


//set number of articulated parts
switch (FEAT_ROADVEHS, SELF, switch_articulated_t3, extra_callback_info1) {
1: return item_tram_tatra_t3;
2: return item_invisible_2;
3: return item_invisible_1;
4: return item_tram_tatra_t3;
5: return item_invisible_2;
return CB_RESULT_NO_MORE_ARTICULATED_PARTS; //stop adding vehicle parts
}

//set capacity of each part
switch (FEAT_ROADVEHS, SELF, switch_capacity_t3, position_in_consist ) {

2: return 0;
3: return 0;
5: return 0;
return 60; //default
}


item (FEAT_ROADVEHS, item_tram_tatra_t3_double) {
property {
name: string(STR_NAME_TATRA_T3_DOUBLE); //název z .lng
introduction_date: date(1962,1,1);
model_life: VEHICLE_NEVER_EXPIRES;
retire_early: 0;
vehicle_life: 25;
loading_speed: 25;
cost_factor: 224;
running_cost_factor: 112;
speed: 65 km/h;
power: 966 hp;
weight: 16 ton;
length: 3;
cargo_capacity: 120;
tractive_effort_coefficient: 0.5;
air_drag_coefficient: 0;
//sound_effect: no sound
//visual_effect: use default (none)

//callback_flags: no need to set this
reliability_decay: 20;
climates_available: ALL_CLIMATES;
refittable_cargo_classes: bitmask(CC_PASSENGERS);
sprite_id: SPRITE_ID_NEW_ROADVEH; //use custom sprites
misc_flags: bitmask(ROADVEH_FLAG_TRAM); //make this a tram
refit_cost: 0; //refits are free
running_cost_base: RUNNING_COST_ROADVEH;
}


graphics {
default: spriteset_invisible_1;
articulated_part: switch_articulated_t3;
cargo_capacity: switch_capacity_t3;
}


}

----------------------------------------------
Image
TadeuszD
Transport Coordinator
Transport Coordinator
Posts: 329
Joined: 07 Nov 2011 19:32
Location: PL

Re: Long vehicles - graphic bug?

Post by TadeuszD »

stefino_cz wrote:One more question again. If I have articulated train of 3 parts for example, I define 3 parts and in the end I merge it together into one unit. But in purchase menu are these 3 parts and one final unit. How to show these 3 parts?
I'm using completely different style of programming. First of all, I'm using dedicated sprites for purchase menu. Something like this:

Code: Select all

graphics {
    purchase:                   sset_my_vehicle_purchase_sprite;
    ...
    }
Next, almost all my vehicles are using single ID for all articulated parts. All differentiates (spritesets, length, capacity, etc.) are programmed in callbacks.
And the last thing. You are using 'fake' sprites instead of base 8bpp sprites for your vehicle. It is weird, because your set wil not work with OTTD configed to use only 8bpp blitter.
Image
User avatar
stefino_cz
Transport Coordinator
Transport Coordinator
Posts: 268
Joined: 02 Jul 2015 08:05
Location: Czech Republic
Contact:

Re: Long vehicles - graphic bug?

Post by stefino_cz »

:arrow: Yes yes, I'm going to add purchase sprite in my code :) What size of sprite do you use for purchase menu?
:arrow: Your program style looks more simple. Can you write code for one vehicle for better imagination? Here or PM? Thanks
:arrow: And about 8bpp - my opinion is to make only 32bit version, cause I used a lot of things what are unreal in 8bpp (transparency, shadows, coronas ahead of lights etc.) So yes - I know, that my sets will works only on 32bpp OTTD. This is my target and there is a lot of work for one man. I have no idea how hard is to make 8bpp from 32bpp, but I have "no time" to make sprites in zoom1, zoom2, zoom4 and in 8bpp and 32bpp :) Thats the reason, why I'm using placeholder in 8bpp and have only zoomx4 in 32bpp. It is the best way how to reach my goal, because redraw all the OTTDs world is a long-term work :)
Mratanava Transport, 19. kvě 2000.png
(1.95 MiB) Not downloaded yet
Image
TadeuszD
Transport Coordinator
Transport Coordinator
Posts: 329
Joined: 07 Nov 2011 19:32
Location: PL

Re: Long vehicles - graphic bug?

Post by TadeuszD »

stefino_cz wrote:What size of sprite do you use for purchase menu?
I'm using 50x12px sprites. But you can use bigger pictures. OTTD automatically resize the grid in purchase window to the largest sprite. IIRC, purchase menu sprite should be standard 8bpp picture.
Can you write code for one vehicle for better imagination? Here or PM?
You can check my source files for Polish PKP trainset. Good example is this wagon:
https://dev.openttdcoop.org/projects/pk ... /bipa.pnml
Here you find sprites:
https://dev.openttdcoop.org/projects/pk ... x/bipa.png
It is long, articulated vehicle with refit option to 2, 3 or 4 parts. Road vehicles should work with the same ideas.
Image
User avatar
stefino_cz
Transport Coordinator
Transport Coordinator
Posts: 268
Joined: 02 Jul 2015 08:05
Location: Czech Republic
Contact:

Re: Long vehicles + other graphic bugs (32 bpp)

Post by stefino_cz »

Thanks :)

I found another graphic problem. I made a smoke, but in some cases there is a problem with "animation" . This problem is only at 2 od 3 chimneys (industries) of all FIRS's graphics but it is there. This smokes are split into two parts - one part is static and second part is moving ok. But as you can see in the picture, near this bugged smoke are 2 more smokes and they are ok. THe second thing what I know is that if I move with screen or zoom out - size of the static area will be smaller and I get 2/3 of smoke what is OK instead of 1/3 like in the picture. At next chimney the static area is only at last 1/4 of the sprite size so the bugs are not same (all bugged smokes have different size of the static part). Have anybody any idea where the problem is? Thanks :)
smoke.jpg
(748.25 KiB) Not downloaded yet
Image
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: Long vehicles + other graphic bugs (32 bpp)

Post by Alberth »

It seems to me that your "not ok" part is outside the foot-print of the industry, and as such not updated at the same time as the industry.

Edit: "outside" in the purely vertical sense (that is, the columns of smoke pixels are not above a tile of the industry), without taking depth into account; openttd doesn't have depth in graphics.
Being a retired OpenTTD developer does not mean I know what I am doing.
User avatar
stefino_cz
Transport Coordinator
Transport Coordinator
Posts: 268
Joined: 02 Jul 2015 08:05
Location: Czech Republic
Contact:

Re: Long vehicles + other graphic bugs (32 bpp)

Post by stefino_cz »

Mmm, I understand. But look at this two pictures? One is OK and second has split graphic and in this case is that part not static but deleted. I only move a view a little bit down.
1.jpg
(671.39 KiB) Not downloaded yet
2.jpg
(675.63 KiB) Not downloaded yet
And a video of this problem to better understanding
https://youtu.be/4nWsVkGwytw
Image
TadeuszD
Transport Coordinator
Transport Coordinator
Posts: 329
Joined: 07 Nov 2011 19:32
Location: PL

Re: Long vehicles + other graphic bugs (32 bpp)

Post by TadeuszD »

stefino_cz wrote:But look at this two pictures? One is OK and second has split graphic and in this case is that part not static but deleted.
These glitches occurs, because OTTD does not refresh whole scene at every frame. OTTD optimizes this process and refreshes "dirty blocks" only. "Dirty block" are registered only when ground/industry/house tile changes the state.
In your case, the smoke extends beyond the "dirty block", which is triggered by corresponding industry tile. In the effect, the right part of smoke is repainted correctly, but left part of smoke is repainted randomly, only when other tiles need refresh. If other tiles doesn't need refresh (i.e. static ground tiles), left part of smoke will not be refreshed too.

Edit:
You can analyze "dirty blocks" by enabling developer option ("newgrf_developer_tools = true" in your openttd.cfg file) and by setting "Toggle colouring of dirty blocks" in Info menu.
Image
michael blunck
Tycoon
Tycoon
Posts: 5948
Joined: 27 Apr 2005 07:09
Contact:

Re: Long vehicles + other graphic bugs (32 bpp)

Post by michael blunck »

You can set the "tile refresh offset" by action0D, writing vars 93 .. 96.

regards
Michael
Image
User avatar
andythenorth
Tycoon
Tycoon
Posts: 5656
Joined: 31 Mar 2007 14:23
Location: Lost in Music

Re: Long vehicles + other graphic bugs (32 bpp)

Post by andythenorth »

FIRS has some pretty frequent bugs with smoke pausing, as above. :twisted: Causes for this are likely one or both of
(1) inappropriate extents set on the sprites (fixed for some cases, but not released as of April 2017).
(2) smoke not marked dirty because it extends beyond the animated tile boundary (historically fixed in some cases by animating all tiles, or by moving the smoke position)

The case in the screenshots above is somewhat complicated because I use baseset smoke sprites in FIRS. For the smoke sprites shown, the original baseset and opengfx baseset have them going to the right (wind from SW). The 32bpp sprites are going to the left (wind from SE). This may be moving the smoke sprites outside the industry tile boundary. :| There is nothing useful I can further say about that today.
User avatar
stefino_cz
Transport Coordinator
Transport Coordinator
Posts: 268
Joined: 02 Jul 2015 08:05
Location: Czech Republic
Contact:

Re: Long vehicles + other graphic bugs (32 bpp)

Post by stefino_cz »

Thanks a lot of these answers :)
Image
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 4 guests