Scripts / [SOLVED] Flame Animation Control

Author
Message
GreekToMe
14
Years of Service
User Offline
Joined: 27th Oct 2009
Location: Colorado, USA
Posted: 14th Dec 2019 15:36
Hi,
Well, trying to figure out an animation script and before I start making changes(by guessing) on the .FX file, I thought I drop you guys a note and perhaps some of you have already gone down this path and you could save me some time, or tell me that I am off to the wrong trail.
In the entity bank under decals, there is a "Fire1" entity, which is an animated fire usable in a lot of different situations. The FPE file points here : effectbank\reloaded\decal_animate4.fx.
First of, have you guys ever tried to open this file, or any other file of this type (which program?) and work with it?
I am trying to control the flame, by making it a bit more "lazy" rather than the default speed of a furious crackling fire.
I thought I would import the FX file in a program which is suitable and then "play" with the script and decipher which lines of code control the flame speed.
Any help/direction will be much appreciated!
Cheers!
Alexis A

The author of this post has marked a post as an answer.

Go to answer
PM
GreekToMe
14
Years of Service
User Offline
Joined: 27th Oct 2009
Location: Colorado, USA
Posted: 14th Dec 2019 16:16
After some more looking around, perhaps the solution lies in the "settings.fx" file ?
Cheers!
Alexis A
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 14th Dec 2019 20:40
fx is a shader file and can be opened with any notepad or word type program, i'm not very good at shaders (especially GG shaders as they are kinda unfriendly to read) but you should be able to adjust either the loop time or the fps

i think the part after " >= " is the intended target so >= 25 is 25fps / or >= 100 is 100 milliseconds so either reduce the fps or increase the milliseconds to slow it down
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 14th Dec 2019 20:57
One thing to note is that *all* your decals using the same shader will animate identically, so basically they will *all* show frame N at the same time.

You can get around this by making them particle effects and controlling the animation rate on a per emitter basis.
Been there, done that, got all the T-Shirts!
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 14th Dec 2019 22:57 Edited at: 14th Dec 2019 22:58
true, a combination of decal and particles is best and i'm sure there would be a way to add some random to the time or perhaps some form of noise variance but not sure how it's done in GG's shaders

i also forgot to mention that you need to change forcereloadtestgameshaders = 1 (or something like that) in settings.ini for any shader changes to have an effect (you can set it back to 0 once you're happy with the changes)
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
GreekToMe
14
Years of Service
User Offline
Joined: 27th Oct 2009
Location: Colorado, USA
Posted: 15th Dec 2019 17:37
Many thanks to all!
Off to try different ideas/solutions...
I will keep you posted once i have something to report.
Unfortunately, obligations in the next few days will limit the time I have available for GG.
You know, some times I dream of solutions in my sleep and amazingly enough I remember everything when I wake up. Perhaps your suggestions will "brew" something.
Thanks again!
Cheers!
Alexis A
PM
GreekToMe
14
Years of Service
User Offline
Joined: 27th Oct 2009
Location: Colorado, USA
Posted: 24th Dec 2019 18:11
I am not getting anywhere with this with simple number adjustments. It will require (IMHO) some deeper digging. Just as easy ( a good exercise for me anyway ) to make one from scratch ?... Ho Ho Ho!
Thanks for all the help!!!
Alexis A
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 26th Dec 2019 13:57 Edited at: 26th Dec 2019 14:01
are you closing GG / placing the decal down from the entity selection screen each time you change the shader? i don't think existing map entities will be changed, GG can be a little weird like that.
works fine for me, i just copied the originals and made new versions so as not to change anything else and because it's a new shader i didn't even need to worry about setup.ini (but for changes to take effect you need to close and re-open GG if you want to tweak the shader afterwards)

as i said, if you want to adjust the speed you change
float FramesPerSec : Power
<
string UIName = "Frames Per Second";
string UIWidget = "slider";
float UIMin = 0.0;
float UIMax = 30.0;
float UIStep = 0.5;
> = 1.000000;

the last line is the value you change so >=1.0 is slow, >=100 is faster
as you can see i made the fire much slower
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11

Attachments

Login to view attachments
GreekToMe
14
Years of Service
User Offline
Joined: 27th Oct 2009
Location: Colorado, USA
Posted: 26th Dec 2019 14:54
Ahh! Bonehead approach! No, never closed GG after each change. I was just restarting the test level thinking that the entity will update. I guess not. I had and have updated entities on the fly before without problems. Things like changing the number of lives, strength, other properties etc. Just need to be more careful/diligent in the future.
I will be on it later today and will report the results.
THANKS, for keeping me straight and not giving up!
Cheers!
Alexis A
PM
GreekToMe
14
Years of Service
User Offline
Joined: 27th Oct 2009
Location: Colorado, USA
Posted: 26th Dec 2019 15:14
BTW, you gave me plenty to study for the next couple of weeks. THANKS!
Cheers!
Alexis A
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 26th Dec 2019 15:32 Edited at: 26th Dec 2019 15:36
i believe if you change the line forceloadtestgameshaders=0 to 1 in setup.ini you don't need to restart GG as when set to 0 this line tells GG to pre-load/convert all the shaders and they will not be changing but you should always replace the entities on the map and reload the map as GG does not update in real time - as i knew i would only be making a quick edit i was ok with simply closing and reopening GG (and deleting the .blob shader file if needed) though if you were to spend more time editing shaders i would highly recommend simply leaving the setting at 1

but yes, scripts don't require GG to be restarted or even reloading the map, you can simply re-enter test game mode... shaders are not strictly scripts though they are more related to the material / texture of the model, it's just the way you edit them that makes it feel like scripting
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
GreekToMe
14
Years of Service
User Offline
Joined: 27th Oct 2009
Location: Colorado, USA
Posted: 26th Dec 2019 20:00
At some point I would like to get a bit more "educated" on the shaders. So, in order for the flame to be controlled, at least for me, I edit the .fx file to the desired value, then change the forceloadtestgameshaders=0 to 1. Restart GG, import the entities in question, then save your level , then re-edit the setup.in to the =0 value.
Then the entities, after they were saved, work as desired and also maintain their new properties, for re-using them in the future.
So, I am guessing that someone can make changes to multiple animated entities and after changing the .ini file, save them all as new entities with new frame animations. I will try it in a day or two.
One item of note, when I changed the setting on the .ini file to 1, it took quite a bit of time for GG to load, for obvious reasons, the test level stayed in a black screen with white border some time as well, before loading the test level. So, FYI, GG is not locked up. Just be patient .
Afterwards, (return the .ini to 0) it all returned to normal.
Thanks to all one more time!
I learned a lot with this "drill".
Cheers!
PS I attach a short video of POOR quality.

Alexis A

Attachments

Login to view attachments
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 26th Dec 2019 20:15
'forcereload' is not really a correct term as what it is actually doing is recompiling all the shaders not just reloading them.

If you are familiar with other engines like U4 this is the same this as it does when it goes of for a few hours whilst compiling, it isn't a quick process by any means.

Luckily at runtime it will simply load the precompiled .blob files which is a lot quicker.

You can by the way change shader variables from within a Lua script.
Been there, done that, got all the T-Shirts!
PM
GreekToMe
14
Years of Service
User Offline
Joined: 27th Oct 2009
Location: Colorado, USA
Posted: 26th Dec 2019 21:27
This post has been marked by the post author as the answer.
Thank you AmenMoses!
"You can by the way change shader variables from within a Lua script"... I will visit with this again.
All noted and filed as needed for present and future reference.
Cheers!
Alexis A
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 29th Dec 2019 18:58
Quote: "You can by the way change shader variables from within a Lua script."

sure but does anyone actually have any clue how that works in GG? i mean if you wanted to do the above example of slowing down / speeding up the fire via lua... is it possible? i had an attempt and got nothing to change
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 29th Dec 2019 19:36
All I know is that the command exists, I haven't actually tried it out myself.

I vaguely recall a post from Preben with an example of usage but that was quite some time ago.
Been there, done that, got all the T-Shirts!
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 29th Dec 2019 20:13
yep but it's not listed in the global.lua and there's very little info anywhere except a very small bit here
https://forum.game-guru.com/thread/219792#msg2602101
but that only gives a real quick single line example and trying to replicate it doesn't seem to work (probably because i don't understand how the shader is expecting to update from the lua value given - the above example is not very useful now as most of the code it seems to be changing is marked as "old"

my thinking was that you would need a variable in the shader you can adjust (like "WaterCol") and then it will need to have some function to make the changes... but it doesn't appear to work
so in the shader we pass in a variable
i.e.
float frameRate = 25;
then in the update part we use the new variable to change the setting
i.e.
float speed =(Time*frameRate) - (offset*frameRate);

of course this is using the lua command like
function adjust_decal_init(e)
SetShaderVariable(0,"frameRate", 1, 0)
end
(which should reduce the speed of the decal to 1)
note: i have no idea what the 0's do but they were in the original example
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11

Attachments

Login to view attachments
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 31st Dec 2019 17:27 Edited at: 31st Dec 2019 17:49
Just looked in the code and the SetShaderVariable call requires at least 6 parameters. They are:

ShaderIndex : if this is 0 it will apply the value to all shaders!
ConstantName : Name of the "EffectParameter"
fValue1 : floating point values
fValue2 : passed to a function called
fValue3 : SetEffectConstantVEx in a
fValue4 : 'Vector4' format.
others : ignored

Edited to add:
So for your example above try -
SetShaderVariable( 0, "FramesPerSec", 10, 0, 0, 0 )
Been there, done that, got all the T-Shirts!
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 3rd Jan 2020 21:51
Btw, the ParticlesLoadEffect command returns the shader index so you can use this returned value in a SetShaderVariable call, should allow some spectacular things to be done!

I don't think there is any way of getting the shader index for any other shaders in Lua though.
Been there, done that, got all the T-Shirts!
PM
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 4th Jan 2020 04:03
Maybe this might help a bit.


Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM

Login to post a reply

Server time is: 2024-04-18 10:53:16
Your offset time is: 2024-04-18 10:53:16