Fade/scale over duration parameters for rendering.draw_sprite / draw_animation

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
User avatar
Smart Inserter
Smart Inserter
Posts: 2393
Joined: Fri Nov 06, 2015 7:41 pm

Fade/scale over duration parameters for rendering.draw_sprite / draw_animation

Post by Deadlock989 »

Explosions have these parameters:

Code: Select all

fade_in_duration	::	uint8 (optional)
fade_out_duration	::	uint8 (optional)
scale_end	::	float (optional)
scale_initial	::	float (optional)
But explosions can't be scaled independently in the x and y axes or rotated to arbitrary RealOrientations by script. Rendered sprites and animations can, but they don't have any fade or scale over duration parameters.

Use case: I have some relatively large sprites (the largest is 16 x 4 tiles) that are rendered to make an animation (the lightning strikes below). I really just want it to fade away. I can't use an explosion because the sprite needs to be scaled along its X axis only, depending on the distance it needs to be drawn over (the bolt uses an L-system algorithm to connect two points); it also needs to be rotated with precision.

Currently I have two options:

1. Make it an animation, which means hugely multiplying the sprite atlas usage of the effect when the main thing it needs to do is simply fade away. There are 8 variations of 3 sizes of sprite and that's already a non-insignificant use of atlas space even with just 1 frame. It needs at least 30 steps to look good.

2. Make it a sprite, and use conditional on_tick shenanigans over the lifetime of the sprite to set the alpha and multiply the RGB channels by the alpha.

The latter is what I'm currently doing, and taking the opportunity to slightly adjust the y_scale of the sprite as well so it distorts as it fades. Performance is actually not too bad, but obviously it's worse if there are many of these things firing at once. The turret entity in question is inactive most of the time in a typical game but in theory someone could spam hundreds of them down in hotspots which could tank UPS.

Request: allow us to set initial tint and final tint for a sprite; if they are defined, interpolate between them during the sprite's lifetime.

Bonus points: allow x_scale_initial, x_scale_final, y_scale_initial and y_scale_final as well which are also interpolated over the TTL.
"If Stalin had a good writeup on programming, would linking that be dangerous?"

User avatar
Burner Inserter
Burner Inserter
Posts: 10
Joined: Tue Sep 22, 2020 7:50 am

Re: Fade/scale over duration parameters for rendering.draw_sprite / draw_animation

Post by Zetabite »

I think something that would be nice to have in animations and sprites too, would be scheduling animations if that would be possible. So that when I know I need to create animation B at time X that I can create it, without to check every tick to create it at the correct time. Currently what I do for that when i need to schedule an animation, I check every tick if my previous animations deadline is done and my next animation can start.
So the property could look something like this:

Code: Select all

start_tick	::	uint8 (optional)
start_tick_offset	::	signed int8 (optional)
Defaults to current tick when no value given or value smaller than current tick, else sets the number given. Alternatively could be just an offset, that is 0 or larger.

Post Reply

Return to “Modding interface requests”