[2.0.55] Excessive overdraw during the rendering of elevated rails.

Bugs that are actually features.
WildWolf
Inserter
Inserter
Posts: 33
Joined: Mon Dec 15, 2014 1:25 pm
Contact:

[2.0.55] Excessive overdraw during the rendering of elevated rails.

Post by WildWolf »

I started experiencing large framerate dips when there were a bunch of elevated rail segments on the screen during draw and decided to dig some more into it with NVIDIA Nsight and found large amounts of wasted pixel space being used to draw a singular track segment when it was elevated

The section in blue is the current-drawn section when the max that is technically needed for the texture is highlighted in cyan just for a straight track.
07-10-2025, 06-02-49.png
07-10-2025, 06-02-49.png (2.68 MiB) Viewed 333 times
Everything that is with the red squares and diagonal lines is the current-drawn vertices.

This same thing can be found during the rendering of curved elevated rails, but here it is even worse due to each segment being drawn individually.
Event 588:
07-10-2025, 06-06-05.png
07-10-2025, 06-06-05.png (4.05 MiB) Viewed 333 times
Event 593:
07-10-2025, 06-06-22.png
07-10-2025, 06-06-22.png (4.09 MiB) Viewed 333 times
Here I will not include the boxes due to the visual indicator of what actually is being drawn vs what space is being badly used.

Here is a collection of screenshots when a track on the ground is being drawn with the full viewport visible.
07-10-2025, 06-09-06.png
07-10-2025, 06-09-06.png (8.36 MiB) Viewed 333 times
07-10-2025, 06-09-17.png
07-10-2025, 06-09-17.png (8.4 MiB) Viewed 333 times
07-10-2025, 06-09-27.png
07-10-2025, 06-09-27.png (8.45 MiB) Viewed 333 times
07-10-2025, 06-09-49.png
07-10-2025, 06-09-49.png (8.45 MiB) Viewed 333 times
07-10-2025, 06-09-59.png
07-10-2025, 06-09-59.png (8.5 MiB) Viewed 333 times
07-10-2025, 06-11-07.png
07-10-2025, 06-11-07.png (9.03 MiB) Viewed 333 times
07-10-2025, 06-11-21.png
07-10-2025, 06-11-21.png (9.05 MiB) Viewed 333 times
Brought to you by a crappy pc...
WildWolf
Inserter
Inserter
Posts: 33
Joined: Mon Dec 15, 2014 1:25 pm
Contact:

Re: [2.0.55] Excessive overdraw during the rendering of elevated rails.

Post by WildWolf »

Here is a collection of screenshots when an elevated track is being drawn with the full viewport visible.
factorio_f5fc8794c3.jpg
factorio_f5fc8794c3.jpg (1.77 MiB) Viewed 325 times
factorio_e464e3bb3d.jpg
factorio_e464e3bb3d.jpg (1.77 MiB) Viewed 325 times
factorio_0b1af12366.jpg
factorio_0b1af12366.jpg (1.81 MiB) Viewed 325 times
factorio_c3009a2b79.jpg
factorio_c3009a2b79.jpg (1.81 MiB) Viewed 325 times
factorio_60a2564086.jpg
factorio_60a2564086.jpg (1.81 MiB) Viewed 325 times
factorio_fa46db948b.jpg
factorio_fa46db948b.jpg (1.84 MiB) Viewed 325 times
factorio_e946de5987.jpg
factorio_e946de5987.jpg (1.81 MiB) Viewed 325 times
factorio_97e292fb28.jpg
factorio_97e292fb28.jpg (1.81 MiB) Viewed 325 times
factorio_9c2a43555b.jpg
factorio_9c2a43555b.jpg (1.84 MiB) Viewed 325 times
factorio_8e44d81542.jpg
factorio_8e44d81542.jpg (1.81 MiB) Viewed 325 times
factorio_24d7f81f7e.jpg
factorio_24d7f81f7e.jpg (1.81 MiB) Viewed 325 times
07-10-2025, 06-22-38.png
07-10-2025, 06-22-38.png (9.1 MiB) Viewed 325 times
07-10-2025, 06-22-52.png
07-10-2025, 06-22-52.png (9.09 MiB) Viewed 325 times
07-10-2025, 06-23-57.png
07-10-2025, 06-23-57.png (9.03 MiB) Viewed 325 times
07-10-2025, 06-24-47.png
07-10-2025, 06-24-47.png (9.1 MiB) Viewed 325 times
This is while using the hd_age packs
Brought to you by a crappy pc...
WildWolf
Inserter
Inserter
Posts: 33
Joined: Mon Dec 15, 2014 1:25 pm
Contact:

Re: [2.0.55] Excessive overdraw during the rendering of elevated rails.

Post by WildWolf »

Looking at the drawing with just the base game, it seems there is a trim step missing from the texture loading during mods that isn't being processed to pack the textures or that the mod itself needs to properly trim the excess as this is the result for drawing elevated rails without the hd_age pack
07-10-2025, 06-52-28.png
07-10-2025, 06-52-28.png (9 MiB) Viewed 308 times
Posted it to the creator on the mod discussion in case it is deemed to be a mod issue and not a processing step issue.
Brought to you by a crappy pc...
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 4030
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [2.0.55] Excessive overdraw during the rendering of elevated rails.

Post by boskid »

I will throw this to Not a bug. Looking at the sprite cropping code, it fails to crop those sprites because in the bitmap data, first pixel has alpha value of 1/256th instead of being 0. That means it is a mod issue.
Ingo-Igel
Burner Inserter
Burner Inserter
Posts: 6
Joined: Sun Nov 03, 2024 7:01 pm
Contact:

Re: [2.0.55] Excessive overdraw during the rendering of elevated rails.

Post by Ingo-Igel »

Hi, I am the author of the HD-Age mod.

In my image editing program, the alpha value is given in 8-bit from 0 to 255, and this value is 0 in the corresponding areas of the textures on the Alpha Channel. When transferred to the specification, 1/256 corresponds to this value. How is an alpha value of 0 defined in Factorio?

If the alpha channel is 0, then the RGB values are greater than 0 due to compression. Are these values also checked to be 0?
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 4030
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [2.0.55] Excessive overdraw during the rendering of elevated rails.

Post by boskid »

Ingo-Igel wrote: Thu Jul 10, 2025 7:56 am Hi, I am the author of the HD-Age mod.

In my image editing program, the alpha value is given in 8-bit from 0 to 255, and this value is 0 in the corresponding areas of the textures on the Alpha Channel. When transferred to the specification, 1/256 corresponds to this value. How is an alpha value of 0 defined in Factorio?

If the alpha channel is 0, then the RGB values are greater than 0 due to compression. Are these values also checked to be 0?
I am not able to tell you exact details as i am not working with graphics, i just see code for cropping sprites takes uncompressed sprites in something that looks like ARGB_8888 format, and when cropping those sprites, most of the pixels at the beginning of bitmap data are correctly 0x00000000, but the first pixel (and i would guess possibly the last pixel) reports as being 0x01000000 which has a non transparent alpha value causing it to not crop. When i temporarily changed the cropping code to ignore lowest bit of alpha value the sprites were cropped in a way that looked "correct".
Rseding91
Factorio Staff
Factorio Staff
Posts: 15871
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [2.0.55] Excessive overdraw during the rendering of elevated rails.

Post by Rseding91 »

Looking at the PNGs - they have non-zero RGB pixels with an alpha value of zero. The game won't strip those out for different reasons.

If I batch go over every PNG in the mod and for each alpha-zero pixel set the entire thing to 0 (0 r, 0 g, 0 b, 0 a), the graphics engine will then crop all of those transparent pixels away.
If you want to get ahold of me I'm almost always on Discord.
Post Reply

Return to “Not a bug”