Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: Nightmare on July 15, 2018, 01:18:59 am

Title: Particle effect testing
Post by: Nightmare on July 15, 2018, 01:18:59 am
I've been playing with the Particle Effect from the wiki ( http://wiki.hard-light.net/index.php/Particle_Effects ), trying to work around the issues I had with the Death flash script (lag, not working on debug builts) and the description of "$Ship Death Effect:" ( http://wiki.hard-light.net/index.php/Ships.tbl#.24Ship_Death_Effect: ) seemed just to fullfill all my needs. When I used it however, the effect that worked with the script did not show up, not matter what I did.

First I've tried something that equals the description on the wiki:

Code: [Select]
#Particle Effects
$Effect: TestTest
$Type: Single
+Filename: ExpFlashBlue
+Size: (19000)
#End

After that didn't worked I also took a look at the JAD table, but it did not work either. (I did a couple more attempts, but neither worked).

Code: [Select]
#Particle Effects
$Effect: TestTest
$Type: Single
+Filename: ExpFlashBlue
+Size: (19000)
+Lifetime: (1000)
+Duration: Always
#End

The only thing there was in the Debug log is following:

Quote
TBM  =>  Starting parse of 'ExploNew-part.tbm' ...
BMPMAN: Found EFF (ExpFlashBlue.eff) with 39 frames at 10 fps.

Any thoughts?
Title: Re: "$Ship Death Effect:" not working
Post by: Nightmare on July 15, 2018, 12:51:23 pm
OK, I've managed to find the problem- apparently $Ship Death Effect: is simply not working. I used the same TestTest particle effect as weapon impact, and it worked properly. One thing I've noticed though, is that the quality of the effect is extreme low, as if the resolution of the effect used (1024*1024 png) would've been just 64*64 pcx files. In case somebody wants to fix this someday, would it be possible to have them in full quality (or atleast, higher)?
Title: Re: "$Ship Death Effect:" not working
Post by: m!m on July 15, 2018, 12:59:48 pm
 :banghead:

Quick test, try to add a dummy effect before your real particle effect. That should fix it. This is another instance of stuff not working because a single character is missing (https://github.com/scp-fs2open/fs2open.github.com/blob/master/code/ship/ship.cpp?utf8=%E2%9C%93#L8002). While I'm working on the particle code I might as well fix this by using a better type for these handles...

EDIT: This should fix the death effect: https://github.com/scp-fs2open/fs2open.github.com/pull/1797
Title: Re: "$Ship Death Effect:" not working
Post by: Nightmare on July 15, 2018, 01:34:16 pm
Ah, OK thank you! :) :yes:

Maybe you could link the detail level to "+Size:" of the particle effect? I like the idea of having some sort of native "Death flash" rather than the scripted one, but it looks horibble underdetailed (I can add pics if required).
Title: Re: "$Ship Death Effect:" not working
Post by: Nightmare on December 16, 2018, 01:58:39 am
I've got another problem. I'm using following code:

Code: [Select]
$Effect: Hecate
$Type: Composite
+Child effect: $New Effect
$Type: Cone
+Filename: CapFlash
+Size: (15)
+Lifetime: (4)
+Deviation: 180
+Velocity: (500)
+Number: (1)
+Direction: Reflected
+Trail effect: $New Effect
$Type: Single
+Filename: exp20
+Size: (150)
+Lifetime: (6)
+Duration: Always
+Duration: (4)
+Delay: (2)
+Child effect: $New Effect
$Type: Cone
+Filename: CapFlash
+Size: (15)
+Lifetime: (4)
+Deviation: 180
+Velocity: (1250)
+Number: (1)
+Direction: Reflected
+Trail effect: $New Effect
$Type: Single
+Filename: exp20
+Size: (150)
+Lifetime: (4)
+Duration: Always
+Duration: (4)
+Delay: (2)

As far as I understood the wiki, I should be seeing 2 effects, each with a particle trail; with effect generation starting 2 seconds after the effect is triggered (i.e. ship destroyed) and last for 4 seconds. The delay works as far as I can see this, but the engine creates about 2 dozen effects from this, and every number larger than 2 entered in "+Number:" will cause FPS to drop below 10.
Title: Re: "$Ship Death Effect:" not working
Post by: m!m on December 16, 2018, 09:57:03 am
Do you have a test mod I could test this with? That would make it much easier to reproduce and fix this bug.
Title: Re: "$Ship Death Effect:" not working
Post by: Nightmare on December 16, 2018, 11:39:27 am
I've noticed another thing- while using these tables with my mod, they create a sphere, but when I'm using the isolated files they always only produce a forward cone, even though I use exactly stats. It's still a forward-only cone if I set "deviation" to 360. The problem with the number of generated effects is the same, however.

[attachment eaten by a Shivan]
Title: Re: "$Ship Death Effect:" not working
Post by: m!m on December 16, 2018, 12:06:41 pm
Thank you very much! That will help me immensely. I can reproduce the bug so I'll investigate what is going wrong here.
Title: Re: "$Ship Death Effect:" not working
Post by: Nightmare on December 16, 2018, 12:12:22 pm
Thanks for your efforts! :)

One thing that I forgot to say - I'm wondering that I have to specify "+Duration" 2 times in a row. As it's only a optional field, I don't understand how the game can distinguish whether it was relating to the main effect or the particle trail if only one is specified.
Title: Re: "$Ship Death Effect:" not working
Post by: m!m on December 16, 2018, 12:18:29 pm
When the engine parses a $New Effect construct it consumes all the options that are possible for that effect. So, when the engine is at line 18 of your file it is currently in the process of parsing a "Single" type effect. "+Duration" is a valid option for that so it will use that if it exists. If you specify that in line 18 (regardless of indentation) then the engine will not be intelligent enough to figure out that you may want to specifcy that for the "Cone" effect.

That is actually a bug in the parsing code since such ambiguities should be avoided when writing such code. I will have to do something clever here to avoid breaking old tables but I will move the +Trail effect: to the end of the list which will fix that ambiguity.
Title: Re: "$Ship Death Effect:" not working
Post by: m!m on December 16, 2018, 12:52:27 pm
So, I figured out what is wrong here. If you specify a duration for an effect that means that for that time new particles of this effect are generated. So, with your config the engine would try to create effects for 4 seconds after the delay. That gets cut down to a lot less since the host of the effect (the ship) is invalid shortly thereafter but there are still a few frames in which the engine will create new particles with particle trails.

So, if you want to only create very few particles you should specify a very short duration for the Cone effects. You can't use "Onetime" though since that only works if you don't specify a delay.

Even though I think the described issue is a configuration issue you still found some issues that I improved upon so I'll submit a pull request with those changes soon.
Title: Re: "$Ship Death Effect:" not working
Post by: Nightmare on December 16, 2018, 01:06:26 pm
So +Number is not good for handling how many effects are being created? I hoped that  if I set +Number to, say, 60 and duration to 4 that 15 effects are being created per second. Would it be possible to implement something like that in in the future, possibly through a new option? It would make the effect easier to specify, as it seems to be a guessing game right now (one that is a bit hard to solve, for me at least).
Title: Re: "$Ship Death Effect:" not working
Post by: m!m on December 16, 2018, 01:10:58 pm
No, that is not how +Number works. That specifies how many particles are created per frame.

A "particles per second" specifier would be interesting but I'll have to think about how such an option could be implemented in this system since the system is specifically designed to that sources do not have effect type specific data in them so I'll have to figure out a generic way of producing a consistent number of particles per frame even if the frame rate is very high or very low.
Title: Re: "$Ship Death Effect:" not working
Post by: Nightmare on December 16, 2018, 01:18:54 pm
OK I didn't knew that, the only thing the wiki told me about +Number: was

Quote
Sets the amount of created particles.
Title: Re: "$Ship Death Effect:" not working
Post by: m!m on December 16, 2018, 01:21:24 pm
Yes, that's pretty vague. I changed it to be more precise.
Title: Re: Particle effect testing
Post by: Nightmare on December 29, 2018, 07:16:21 pm
I'm sorry but I found some more issues (and I had a couple ideas).

-1. Would it be possible to define how many effects "+Trail effect:" creates, something like "+Time:" in $PSpew: at the weapons.tbl? So far, it just keeps making as many as it can until my FPS drops to 30 or below, what is far more than what I would need.

-2. I had the idea that it could be possible to evade the current lack of a "Effects per second:"-feature by creating the same effects several times in a row (with "+Delay:" being the only difference - for example 1, 2, 3 etc). However, when I use +Delay: without specifying +Duration: (see table below) I receive following error although the Wiki does not indicate a dependency as both are optional fields:
Code: [Select]
Error: ExploNew-part.tbm(line 47):
Error: Missing required token: [#End]. Found [(2)] instead.

File: parselo.cpp
Line: 303
I managed to work around this issue though by setting Duration to 0.1 though.

-3. If you quit/reload the mission while the particle effect is active, the next mission you load (or the reloaded mission) will have a lower standard FPS rate. For example, my test mission had 60 FPS as standard (which is also pretty much the default on my PC). After reloading, the exact same mission had a FPS standard of 30-40 FPS using the 29th December Nightly. For some reason this only seems to occur when my FPS drops below 30 during the active effect.

-4. While I have no clue about coding, I just had an idea regarding the "constant particle generation at dynamic FPS" needed to define "+Particles per Second:": I remember that for quite a long time there was a bug with beam damage variating at different FPS or time compression, but I was told it has been fixed in the mean time. Could it be helpful to look at that code, or maybe the one used for $PSpew:?

Test table (the rest is still the same):
Code: [Select]
$Effect: Hecate
$Type: Composite
+Child effect: $New Effect;Inner Part
$Type: Cone
+Filename: CapFlash
+Size: (15)
+Lifetime: (4)
+Deviation: 180
+Velocity: (500)
+Number: (10)
+Direction: Reflected
; +Duration: (0.1)
+Delay: (2)
+Trail effect: $New Effect
$Type: Single
+Filename: exp20
+Size: (200)
+Lifetime: (6)
+Duration: Always
+Child effect: $New Effect
$Type: Cone
+Filename: CapFlash
+Size: (15)
+Lifetime: (4)
+Deviation: 180
+Velocity: (500)
+Number: (10)
+Direction: Reflected
; +Duration: (0.1)
+Delay: (3)
+Trail effect: $New Effect
$Type: Single
+Filename: exp20
+Size: (200)
+Lifetime: (6)
+Duration: Always


+Child effect: $New Effect;Outer Part
$Type: Cone
+Filename: CapFlash
+Size: (15)
+Lifetime: (4)
+Deviation: 180
+Velocity: (1250)
+Number: (22)
+Direction: Reflected
; +Duration: (0.1)
+Delay: (2)
+Trail effect: $New Effect
$Type: Single
+Filename: exp20
+Size: (200)
+Lifetime: (4)
+Duration: Always
+Child effect: $New Effect
$Type: Cone
+Filename: CapFlash
+Size: (15)
+Lifetime: (4)
+Deviation: 180
+Velocity: (1250)
+Number: (22)
+Direction: Reflected
; +Duration: (0.1)
+Delay: (3)
+Trail effect: $New Effect
$Type: Single
+Filename: exp20
+Size: (200)
+Lifetime: (4)
+Duration: Always
Title: Re: Particle effect testing
Post by: Nightmare on January 04, 2019, 11:56:11 am
Anybody? :nervous:
Title: Re: Particle effect testing
Post by: Nightmare on January 09, 2019, 06:39:33 pm
Is there some coder who still cares about the things above, now or at some future point? Especially something with that Particle Trail effect creation could be tamed would be useful...
Title: Re: Particle effect testing
Post by: m!m on January 10, 2019, 12:24:48 pm
Sorry, I forgot to answer here...

I will try to take a look at this soon but unfortunately I cannot promise anything.
Title: Re: Particle effect testing
Post by: Nightmare on January 10, 2019, 03:30:58 pm
Alright - no pressure here, I just wanted to know if there was a chance for this within the next months or whether I should work on something different. :)
Title: Re: Particle effect testing
Post by: m!m on January 13, 2019, 08:35:34 am
I think I build a reasonably efficient implementation of the "Effects per second" feature that we require. Here are some test builds: http://swc.fs2downloads.com/builds/test/effectsPerSecond/

This adds a new optional property "+Effects per second" which specifies how many times per second this effect will generate its particles. The option must be specified after the point where "+Delay" is expected. This should produce consistent effects regardless of framerate. The value of "+Effects per second" must be positive and may not be 0. Above that, every value should "just work". I took special care that you could specify values that are above the usual framerate and still have the option do what you expect but please check if that actually works as intended.

I will have to take a look at the issue you described in your third point since that sounds very weird.
Title: Re: Particle effect testing
Post by: Nightmare on January 13, 2019, 09:59:42 am
Should I set +Number (which is required according to the wiki) simply to 1? Also, does this also work the same way for +Trail effect?
Title: Re: Particle effect testing
Post by: m!m on January 13, 2019, 10:06:46 am
There are no further changes changes to the effect required for making use of the new feature. The other options still have the same meaning but now they are only used N times per second instead of every frame. The new option works everywhere, where "+Duration" and "+Delay" is supported so yes, trail effects should also work with this.
Title: Re: Particle effect testing
Post by: Nightmare on January 13, 2019, 10:39:35 am
Thanks a million! Everythings working super-super smoothly now. I have several cool ideas where I can use this. :)
Title: Re: Particle effect testing
Post by: Nightmare on June 17, 2019, 04:42:07 pm
I'm sorry to come here again, but I ran into an annoying bug that caused me to debug my entire modpack. All I did was adding following entry (without having it used by any weapon/ship) to the tbl:

Code: [Select]
$Effect: Firespew
$Type: Cone
+Filename: ParticleSmoke01
+Size: (50)
+Lifetime: (10)
+Deviation: 0
+Velocity: (10 30)
+Number: (1)
 +Direction: Reverse
+Duration: (1)
+Effects Per Second: 2

The result of this was that debug builts (both FRED and FS2, using the recentmost nightly - 20190514 and your SMAA builts) would no longer start but crash with the error message attached below; which occured immediatly after the preload screen. I checked the wiki to make sure everything was configured correctly. No trace of the cause was left in the debug log. It didn't cause any issues on regular builts, and the effect was working as intended.

[attachment eaten by a Shivan]
Title: Re: Particle effect testing
Post by: m!m on June 18, 2019, 12:03:38 pm
I think the problem here is +Deviation: 0 since that doesn't make sense for normal distributions. Could you try replacing that with something greater than zero?
If that solves the issue, I'll add some error handling to make sure it gives you an actual error message and not just a crash...
Title: Re: Particle effect testing
Post by: Nightmare on June 18, 2019, 12:17:02 pm
Setting the value to 0.1 seems to have fixed it. :nod:

If it is actually an error the wiki page should be updated as I don't see any warning there yet.
Title: Re: Particle effect testing
Post by: Nightmare on June 20, 2019, 09:18:00 am
Added the warning to the wiki. "Revision information" hasn't been updated in a while though.