Transport Fever 2

Transport Fever 2

Create your own game world!
Give your game a personal touch and change it to your liking. Create, share and install mods. Customize the game with new landscapes, vehicles, stations, assets and more.
RadiKyle 6 6 May, 2024 @ 8:58am
How to render part of a mesh (a .mtl) as completely invisible?
Hey all, I'm slowly learning some modding... Currently I'm trying to make part of a vanilla model invisible, to avoid creating a new mesh with that part removed.

I'm struggling with making a .mtl that is completely invisible, there is always some ghosting visible. I'm probably doing it all wrong so can someone here suggest the best way to do it please?

In the .mdl file, I replaced the .mtl I want invisible with a sample transparency .mtl from the modding manual site (transparency_transparent.mtl). I made sure I included the .mtl's referenced files in my test mod (albedo / ao / normal map .tga files).

I've tried various combinations of the following and got some improved level of invisibility, but there is still some ghosting visible:
- changing type from PHYS_TRANSPARENT_NRML_MAP to PHYS_TRANSPARENT to get rid of the normal map;
- changing alphaScale to 0;
- changing the fade_out_range values to 0; and
- removing refs to the albedo / ao / normal maps (set to "" ).
(Note that .mtl file also had alpha_test cutout and two_sided values all set true, which I changed to false.)

I then changed the polygon_offset factor to z-buffer it "out of existence", used 10000 lol. It "worked", I don't see any ghost of that part of the mesh anymore, but I feel dirty about it. I'm worried it's not the cleanest way to do this, especially for performance or avoiding other unwanted effects.

Note when I removed the .tga map file refs from the .mtl, it seems the game substituted other default files in their place (I could see them referenced in-game using debug view, they had "default" in their file names).

It's starting to feel like I need to create my own albedo / ao maps that render invisibly somehow? Or is there a much easier way to do this? I simply want the part of the mesh that has a specific .mtl assigned to disappear, without having to model a new mesh with that part physically removed.

Many thanks!
Last edited by RadiKyle; 6 May, 2024 @ 9:01am
< >
Showing 1-4 of 4 comments
Jones 37 6 May, 2024 @ 12:26pm 
You have to also make the albedo texture have transparent section where the part is located, edit the alpha channel and save the texture as DDS file with DXT5 compression. Gimp has built in DDS exporter in it. Material type PHYS_TRANSPARENT should then work fine if you don't need normal maps or any other.

If the part you wish to make invisible is separated .msh file that is listed in the .mdl, you can delete its block from .mdl. This way you don't need to touch textures and create own .mtl file for it.
RadiKyle 6 6 May, 2024 @ 1:33pm 
Hi @Jones, many thanks for the info!

Does it matter which DXT5 option I use? There is BC3, RXGB, Alpha Exponent, and two YCoCg options.

Unfortunately it's a single mesh using two .mtl for different parts. Agree it would be so much easier if each "part" had it's own mesh.
Jones 37 6 May, 2024 @ 1:42pm 
Ah yea forgot there are many to choose from, BC3 DXT5 is compatible, others not I believe
RadiKyle 6 6 May, 2024 @ 1:59pm 
Ok awesome thanks!

Success! The albedo .tga I got from the sample mod was not completely transparent, it had a gradient. So I deleted that to make it 100% transparent, saved it as BC3 .dds, and the "ghosting" was instantly gone. And now it doesn't care whether or not I link any ao or normal maps.

I also had to change the alphaThreshold to 1 (actually just anything greater than 0) so the invisible geometry doesn't cast shadows on other surfaces.

No more sloppy z-buffer hiding haha! Thanks!
< >
Showing 1-4 of 4 comments
Per page: 1530 50