Page 1 of 1
[2.0.55] Excessive overdraw during the rendering of elevated rails.
Posted: Thu Jul 10, 2025 4:20 am
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 (2.68 MiB) Viewed 364 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 (4.05 MiB) Viewed 364 times
Event 593:

- 07-10-2025, 06-06-22.png (4.09 MiB) Viewed 364 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 (8.36 MiB) Viewed 364 times

- 07-10-2025, 06-09-17.png (8.4 MiB) Viewed 364 times

- 07-10-2025, 06-09-27.png (8.45 MiB) Viewed 364 times

- 07-10-2025, 06-09-49.png (8.45 MiB) Viewed 364 times

- 07-10-2025, 06-09-59.png (8.5 MiB) Viewed 364 times

- 07-10-2025, 06-11-07.png (9.03 MiB) Viewed 364 times

- 07-10-2025, 06-11-21.png (9.05 MiB) Viewed 364 times
Re: [2.0.55] Excessive overdraw during the rendering of elevated rails.
Posted: Thu Jul 10, 2025 4:27 am
by WildWolf
Re: [2.0.55] Excessive overdraw during the rendering of elevated rails.
Posted: Thu Jul 10, 2025 4:52 am
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 (9 MiB) Viewed 339 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.
Re: [2.0.55] Excessive overdraw during the rendering of elevated rails.
Posted: Thu Jul 10, 2025 6:14 am
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.
Re: [2.0.55] Excessive overdraw during the rendering of elevated rails.
Posted: Thu Jul 10, 2025 7:56 am
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?
Re: [2.0.55] Excessive overdraw during the rendering of elevated rails.
Posted: Thu Jul 10, 2025 8:30 am
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".
Re: [2.0.55] Excessive overdraw during the rendering of elevated rails.
Posted: Thu Jul 10, 2025 2:13 pm
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.