ZylonBane on 4/7/2020 at 20:20
You know that mysterious
Spark property that's always been sitting in DromEd under SFX, seemingly unimplemented? This week I figured I'd finally wade into the leaked source and see how much, if any, code was written for it. After much weeping and gnashing, turns out it's almost completely functional. But... it's also pretty much useless.
I'd always assumed from the name that Spark was intended to be a sort of particle that elongated in in its direction of motion, to simulate the trailing visual effect of bright sparks. Well, it's not. All it is is a single flickering triangle. Quoting from Irrational's SS2 Grimoire:
Quote:
Dramatic Spark Shower
If you want a repeating spark shower, just put down the RepeatingSpark SFX object (not implemented yet). This is for a specific spark shower that happens as the player is walking down a corridor, or otherwise at key dramatic times. This recipe can be easily altered to throw out debris or other.
Apparently the idea was that you'd create a shower of sparks by using an emitter to spawn a dozen or so of these Spark objects. They were coded to render very fast, similar to the old square particles. Like particles, they always face the player and are unaffected by lighting. In fact they don't even clip against the screen edges; as soon as one gets near a screen edge it just disappears. This wouldn't have been a problem in practice since they were intended to be tiny.
At some point someone presumably realized Sparks were just duplicating the functionality of the particle system and stopped work on them, even though they were like 90% completed. But that 90% does work!
How to Create a SparkThe first step was the most maddening to figure out. You need to place a bitmap in the resource folder SFX/TXT. It doesn't matter what it is. It can be a single pixel. The engine doesn't use it, it just needs it to exist. It can be named anything, but for this example we'll call it "spark.gif".
Now create a new object in DromEd and give it the Shape/Model Name property. For the value, enter "fx_s_spark". The value must be whatever you named your bitmap, prefixed with "fx_s_".
Finally, add the SFX/Spark property. It has the following sub-properties:
flags: This would have allowed setting some alternate rendering modes and enabling texture mapping of the spark. As is, it discards any value you enter besides 1. If you leave it at 0 the spark will crash the engine in game mode.
color: A standard DromEd 0 - 255 hue value. 30 gives a nice orangeish-yellow.
angle offset 1, angle offset 2, angle offset 3: These are polar coordinates that offset the points on the triangle, in case you want something less equilateral. Values appear to be in the 0 - 65536 range.
angle jitter: Random angular offset applied to each point every frame. Same range as above.
size 1, size 2, size 3: Distance from center of each point. Definitely not DromEd units. It takes a value of at least 1000 in each to make a barely visible spark.
size jitter: Random variation in distance applied to each point every frame, as a percentage. E.g. 0.1 would jitter the size by 10%.
light: Brightness. Sparks are unlit, so a light value of 0 will always be black no matter the surrounding light level. Range 0.0 - 1.0.
light jitter: Random variation in brightness applied individually to each vertex, every frame. 0 gives no jitter. Floating point values above 0 give progressively more strength to the full light setting vs zero lighting. E.g. 1 gives a balanced mix of light and dark, while 10 very strongly favors being fully lit.
A nice touch is that you can preview all these settings in DromEd, since it fully renders the spark every time it updates your view. Sparks support transparency, blend modes, and being scaled.
Now let's check it out. First, a single absurdly large spark.
[video=youtube;JqeSamF6t5U]https://www.youtube.com/watch?v=JqeSamF6t5U[/video]
Here's a setup of how I believe sparks were intended to be used, spewed
en masse from an emitter. These were also given physics, so they interact realistically with the environment.
[video=youtube;ktKtwAO3XYo]https://www.youtube.com/watch?v=ktKtwAO3XYo[/video]
As you can see, the flickering effect on Sparks is actually pretty nice, but the problem is that they're unmistakably triangles. This would have been acceptable for a software renderer back in the late 90s, but in the age of 3D acceleration, and especially at modern resolutions, it looks ridiculous. This issue could have been resolved if texturing support worked, but as noted above, there would be little point, since particles do almost everything sparks do. Even if you wanted to go with the approach of spewing each particle as an individual object, a worldspace bitmap could accomplish the same thing.
Anyway, mystery solved.