32 bpp Vehicles / Company colours?

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

Moderator: Graphics Moderators

Post Reply
temporal8
Route Supervisor
Route Supervisor
Posts: 429
Joined: 17 May 2019 14:15

32 bpp Vehicles / Company colours?

Post by temporal8 »

I'm working on my new grf of industries and as I have new cargo types i think create some vehicles, but unlike Real Cars that are more oriented to eye-candy or traffic I want these vehicles to be more playable with which something necessary is that they can change color based on the colors of different companies/players.

In 8 bpp it´s just a palette colour but i need for 32 bpp, it´s some kind or mask o what? exist any NML example?

Thanks in advance.
Real Projects 32bpp releases:

Real Semi Trucks 32bpp: viewtopic.php?t=90996
Real Houses Eyecandy Objects 32bp: viewtopic.php?t=90767
Real Ships 32bpp: viewtopic.php?t=90733
Real Industries 32bpp: viewtopic.php?t=90183
Real Houses Townset 32bp: viewtopic.php?p=1254605
Real Stations 32bpp: viewtopic.php?p=1255635
Real Cars 32bpp: viewtopic.php?p=1249244
Real Vehicles 32bpp: viewtopic.php?p=1253581
Real Bus 32bpp: viewtopic.php?p=1249245
Real Trucks 32bpp: viewtopic.php?p=1254468
Real Parks 32bpp: viewtopic.php?p=1250255
Argentina World Cup 2022 Champions Bus 32bpp viewtopic.php?p=1257026
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5601
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: 32 bpp Vehicles / Company colours?

Post by PikkaBird »

Yes, you just need an 8bpp mask with the company colour(s). The format for encoding in NML is here. If the mask image is the same size and layout as the base sprite image, you just need to provide the filename - simples.
Class20_new.png
Class20_new.png (27.58 KiB) Viewed 2364 times
Class20_new_mask.png
Class20_new_mask.png (9.51 KiB) Viewed 2364 times
temporal8
Route Supervisor
Route Supervisor
Posts: 429
Joined: 17 May 2019 14:15

Re: 32 bpp Vehicles / Company colours?

Post by temporal8 »

Thank you very much for reply, so I would have to do 32 mask graphics per vehicle? I mean 16 for the unloaded truck and 16 for the loaded truck. (16 company colours)

And of course multiplying that for each truck/cargo is insane! :D
I'm starting to change my mind about company colors. :lol:
Real Projects 32bpp releases:

Real Semi Trucks 32bpp: viewtopic.php?t=90996
Real Houses Eyecandy Objects 32bp: viewtopic.php?t=90767
Real Ships 32bpp: viewtopic.php?t=90733
Real Industries 32bpp: viewtopic.php?t=90183
Real Houses Townset 32bp: viewtopic.php?p=1254605
Real Stations 32bpp: viewtopic.php?p=1255635
Real Cars 32bpp: viewtopic.php?p=1249244
Real Vehicles 32bpp: viewtopic.php?p=1253581
Real Bus 32bpp: viewtopic.php?p=1249245
Real Trucks 32bpp: viewtopic.php?p=1254468
Real Parks 32bpp: viewtopic.php?p=1250255
Argentina World Cup 2022 Champions Bus 32bpp viewtopic.php?p=1257026
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5601
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: 32 bpp Vehicles / Company colours?

Post by PikkaBird »

No. :lol: One mask with the same "magic" palette colours as normal 8bpp sprites - blue for first cc, green for second. :)
temporal8
Route Supervisor
Route Supervisor
Posts: 429
Joined: 17 May 2019 14:15

Re: 32 bpp Vehicles / Company colours?

Post by temporal8 »

Some Progress but one Bug,

EDIT: Nevermind, I solved, it was a mask.png error, i replaced the red background for blue.

The masked vehicle areas changes color ok but the rest of the vehicle (unmasked parts) are animated / alternates between black and red colors when moving on the road.

error.jpg
error.jpg (708.14 KiB) Viewed 2293 times
realtruck_32.png
realtruck_32.png (99.44 KiB) Viewed 2293 times
real_trucks_mask.png
real_trucks_mask.png (5.8 KiB) Viewed 2293 times

Code: Select all

/* Sprite template for a realtruck full*/
template tmpl_realtruck_full(x) {
	[18,     8,   48,   70,   -26,  -40, NOANIM]
	[82,     8,   81,   60,   -58,  -21, NOANIM]
	[178,    8,  103,   48,   -56,  -27, NOANIM]
	[290,    8,   79,   63,   -27,  -25, NOANIM]
	[386,    8,   48,   75,   -27,  -48, NOANIM]
	[445,    8,   80,   63,   -54,  -23, NOANIM]
	[532,    8,   94,   48,   -50,  -26, NOANIM]
	[635,    8,   80,   60,   -27,  -26, NOANIM]
}

template tmpl_32_realtruck_full(x) {
	[0,     0,   48,   93,   -24,  -46, NOANIM]
	[51,    0,   116,  93,   -67,  -36, NOANIM] 
	[171,   0,   127,  93,   -67,  -43, NOANIM]
	[303,   0,   116,  93,   -47,  -38, NOANIM]
	[423,   0,   48,   93,   -23,  -43, NOANIM]
	[474,   0,   116,  93,   -69,  -35, NOANIM]
	[594,   0,   131,  93,   -65,  -57, NOANIM]
	[728,   0,   116,  93,   -46,  -39, NOANIM]
}

template tmpl_32_realtruck_full_MASK(x) {
	[0,     0,   48,   93,   -24,  -46, NOANIM, mask]
	[51,    0,   116,  93,   -67,  -36, NOANIM, mask] 
	[171,   0,   127,  93,   -67,  -43, NOANIM, mask]
	[303,   0,   116,  93,   -47,  -38, NOANIM, mask]
	[423,   0,   48,   93,   -23,  -43, NOANIM, mask]
	[474,   0,   116,  93,   -69,  -35, NOANIM, mask]
	[594,   0,   131,  93,   -65,  -57, NOANIM, mask]
	[728,   0,   116,  93,   -46,  -39, NOANIM, mask]
}

/* Sprite template for a realtruck empty*/
template tmpl_realtruck_empty(x) {
	[18,     8,   48,   70,   -26,  -40, NOANIM]
	[82,     8,   81,   60,   -58,  -21, NOANIM]
	[178,    8,  103,   48,   -56,  -27, NOANIM]
	[290,    8,   79,   63,   -27,  -25, NOANIM]
	[386,    8,   48,   75,   -27,  -48, NOANIM]
	[445,    8,   80,   63,   -54,  -23, NOANIM]
	[532,    8,   94,   48,   -50,  -26, NOANIM]
	[635,    8,   80,   60,   -27,  -26, NOANIM]
}

template tmpl_32_realtruck_empty(x) {
	[0,     96,   48,   93,   -24,  -46, NOANIM]
	[51,    96,   116,  93,   -67,  -36, NOANIM] 
	[171,   96,   127,  93,   -67,  -43, NOANIM]
	[303,   96,   116,  93,   -47,  -38, NOANIM]
	[423,   96,   48,   93,   -23,  -43, NOANIM]
	[474,   96,   116,  93,   -69,  -35, NOANIM]
	[594,   96,   131,  93,   -65,  -57, NOANIM]
	[728,   96,   116,  93,   -46,  -39, NOANIM]
}

template tmpl_32_realtruck_empty_MASK(x) {
	[0,     96,   48,   93,   -24,  -46, NOANIM, mask]
	[51,    96,   116,  93,   -67,  -36, NOANIM, mask] 
	[171,   96,   127,  93,   -67,  -43, NOANIM, mask]
	[303,   96,   116,  93,   -47,  -38, NOANIM, mask]
	[423,   96,   48,   93,   -23,  -43, NOANIM, mask]
	[474,   96,   116,  93,   -69,  -35, NOANIM, mask]
	[594,   96,   131,  93,   -65,  -57, NOANIM, mask]
	[728,   96,   116,  93,   -46,  -39, NOANIM, mask]
}

spriteset(realtruck_empty, "gfx/realtruck.png") { tmpl_realtruck_empty(0) }
alternative_sprites(realtruck_empty, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP, "gfx/realtruck_32.png","gfx/real_trucks_mask.png")  
{ tmpl_32_realtruck_empty(0) }

spriteset(realtruck_full, "gfx/realtruck.png") { tmpl_realtruck_full(0) }
alternative_sprites(realtruck_full, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP, "gfx/realtruck_32.png","gfx/real_trucks_mask.png")  
{ tmpl_32_realtruck_full(0) }

spritegroup realtruck {
    loaded: [realtruck_empty,realtruck_full];
    loading: [realtruck_empty,realtruck_full];
}

/* Purchase Menu Image */
spriteset(spriteset_realtruck_purchase, "gfx/realtruck.png") {[0,0,1,1,0,0]}
alternative_sprites(spriteset_realtruck_purchase, ZOOM_LEVEL_IN_2X, BIT_DEPTH_32BPP, "gfx/realtruck_32.png","gfx/real_trucks_mask.png") {[594,0,131,93,-65,-55]} 

/* Properties */

/* Define the road vehicle */
item(FEAT_ROADVEHS, flatbed_realtruck_1) {
    property {
        /* Properties common to all vehicle types */
        name: string(STR_NAME_realtruck_1);
        climates_available: ALL_CLIMATES;
        road_type: ROAD;
        introduction_date: date(1980,01,01);
        model_life: VEHICLE_NEVER_EXPIRES;
        /* retire_early not set, use default retirement behaviour */
        vehicle_life: 255;
        reliability_decay: 20;
        non_refittable_cargo_classes: bitmask(CC_PIECE_GOODS);
        default_cargo_type: STEL;
        cargo_allow_refit: [];
        cargo_disallow_refit: []; // we allow other cargoes, if class matches
        loading_speed: 8;
        cost_factor: 30;
        running_cost_factor: 20;
        /* cargo_age_period is left at default */

        /* RV-specific properties */
        sprite_id: SPRITE_ID_NEW_ROADVEH;
        speed: 90 km/h;
        misc_flags: bitmask(ROADVEH_FLAG_NO_BREAKDOWN_SMOKE);
        refit_cost: 0; // Refitting is free
        /* callback_flags are not set, no need to manually enable callbacks */
        running_cost_base: RUNNING_COST_NONE;
        power: 163 hp;
        weight: 2 ton;
        /* TE and air drag coefficient is left at default */
        cargo_capacity: 5;
        sound_effect: SOUND_BUS_START_PULL_AWAY;
        /* Visual effect is left at default (no effect) */
    }

    graphics {
        default: realtruck; 
        purchase: spriteset_realtruck_purchase;
    }
}
Last edited by temporal8 on 26 Jun 2022 17:46, edited 1 time in total.
Real Projects 32bpp releases:

Real Semi Trucks 32bpp: viewtopic.php?t=90996
Real Houses Eyecandy Objects 32bp: viewtopic.php?t=90767
Real Ships 32bpp: viewtopic.php?t=90733
Real Industries 32bpp: viewtopic.php?t=90183
Real Houses Townset 32bp: viewtopic.php?p=1254605
Real Stations 32bpp: viewtopic.php?p=1255635
Real Cars 32bpp: viewtopic.php?p=1249244
Real Vehicles 32bpp: viewtopic.php?p=1253581
Real Bus 32bpp: viewtopic.php?p=1249245
Real Trucks 32bpp: viewtopic.php?p=1254468
Real Parks 32bpp: viewtopic.php?p=1250255
Argentina World Cup 2022 Champions Bus 32bpp viewtopic.php?p=1257026
temporal8
Route Supervisor
Route Supervisor
Posts: 429
Joined: 17 May 2019 14:15

Re: 32 bpp Vehicles / Company colours?

Post by temporal8 »

Fixed Mask:
real_trucks_mask.png
real_trucks_mask.png (5.67 KiB) Viewed 2286 times

The only thing I noticed is that the light company colors appear burnt. Is this due to the blue tone or because of the original yellow base?

some-colours-sample.png
some-colours-sample.png (206.95 KiB) Viewed 2284 times
Real Projects 32bpp releases:

Real Semi Trucks 32bpp: viewtopic.php?t=90996
Real Houses Eyecandy Objects 32bp: viewtopic.php?t=90767
Real Ships 32bpp: viewtopic.php?t=90733
Real Industries 32bpp: viewtopic.php?t=90183
Real Houses Townset 32bp: viewtopic.php?p=1254605
Real Stations 32bpp: viewtopic.php?p=1255635
Real Cars 32bpp: viewtopic.php?p=1249244
Real Vehicles 32bpp: viewtopic.php?p=1253581
Real Bus 32bpp: viewtopic.php?p=1249245
Real Trucks 32bpp: viewtopic.php?p=1254468
Real Parks 32bpp: viewtopic.php?p=1250255
Argentina World Cup 2022 Champions Bus 32bpp viewtopic.php?p=1257026
User avatar
Quast65
Tycoon
Tycoon
Posts: 2654
Joined: 09 Oct 2011 13:51
Location: The Netherlands

Re: 32 bpp Vehicles / Company colours?

Post by Quast65 »

temporal8 wrote: 26 Jun 2022 17:16 or because of the original yellow base?
Because of this.
As you can see in Pikka's example, use grey tones in the "original" drawing for the parts that you want to mask.
That way the colors stay what they have to be.

Edit:
Also dont forget to use different tones of the CC-blue and CC-green (lighter/darker tones of those colors), for the shading-effect.
Projects: http://www.tt-forums.net/viewtopic.php?f=26&t=57266
Screenshots: http://www.tt-forums.net/viewtopic.php?f=47&t=56959
Scenario of The Netherlands: viewtopic.php?f=60&t=87604

Winner of the following screenshot competitions:
sep 2012, jan 2013, apr 2013, aug 2013, mar 2014, mar 2016, oct 2020
All my work is released under GPL-license (either V2 or V3), if not clearly stated otherwise.
temporal8
Route Supervisor
Route Supervisor
Posts: 429
Joined: 17 May 2019 14:15

Re: 32 bpp Vehicles / Company colours?

Post by temporal8 »

Thanks a lot pal. :bow:
Real Projects 32bpp releases:

Real Semi Trucks 32bpp: viewtopic.php?t=90996
Real Houses Eyecandy Objects 32bp: viewtopic.php?t=90767
Real Ships 32bpp: viewtopic.php?t=90733
Real Industries 32bpp: viewtopic.php?t=90183
Real Houses Townset 32bp: viewtopic.php?p=1254605
Real Stations 32bpp: viewtopic.php?p=1255635
Real Cars 32bpp: viewtopic.php?p=1249244
Real Vehicles 32bpp: viewtopic.php?p=1253581
Real Bus 32bpp: viewtopic.php?p=1249245
Real Trucks 32bpp: viewtopic.php?p=1254468
Real Parks 32bpp: viewtopic.php?p=1250255
Argentina World Cup 2022 Champions Bus 32bpp viewtopic.php?p=1257026
User avatar
stefino_cz
Transport Coordinator
Transport Coordinator
Posts: 268
Joined: 02 Jul 2015 08:05
Location: Czech Republic
Contact:

Re: 32 bpp Vehicles / Company colours?

Post by stefino_cz »

Hi, I'm using this topic for a similar question, but not for company colors but for "refit" colors. Somebody wrote me that it is possible to code this refit without a special cargo label. Now, we use our own cargo label for it and it is a problem in a case the player has full cargo labels. Then this refit doesn't work. We use NML for coding. Thanks :)
Image
Brickblock1
Engineer
Engineer
Posts: 117
Joined: 04 Apr 2022 12:44
Location: The openttd discord server

Re: 32 bpp Vehicles / Company colours?

Post by Brickblock1 »

stefino_cz wrote: 14 Apr 2023 07:28 Hi, I'm using this topic for a similar question, but not for company colors but for "refit" colors. Somebody wrote me that it is possible to code this refit without a special cargo label. Now, we use our own cargo label for it and it is a problem in a case the player has full cargo labels. Then this refit doesn't work. We use NML for coding. Thanks :)
You should be able to use the label for passengers if you set the capacity to zero with the cargo_capacity callback
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 4 guests