Search Unity

ReadyMade FX: RMFX Core Framework

Discussion in 'Works In Progress - Archive' started by faust, Sep 28, 2013.

  1. faust

    faust

    Joined:
    Dec 19, 2007
    Posts:
    64
    I publish a character-centric effects pack in the Asset Store called Acts of Magic. This WIP thread is not about the AoM pack but about the underlying C# scripting framework we use to build the effects in AoM. We call this framework RMFX Core and we intend to utilize it to build more special effects content packs. This thread will illustrate the new things we are adding to the framework.
    Intro to RMFX Core

    This is supposed to be a “work in progress” thread, so I’ll get to what we’re working on shortly, but first, here’s a quick intro to RMFX Core and what it’s supposed to do. RMFX Core is a C# framework for creating high-level special effects in Unity. Unity comes with a strong suite of effects technologies, (particle-systems, dynamic lighting, sound effects, projectors, materials, shaders, etc.), but these are just building blocks.

    Consider a burning torch… an easy effect, right? A torch is not just a particle-system on a stick. Except in the simplest of cases, a torch requires more than that. Sure, you’ll probably want at least one ParticleSystem for fire and maybe another for smoke, but a torch emits light, so you’ll likely want to add a Point Light, and you’ll probably want that light to flicker. Maybe you even want it to flicker in response to wind forces. And don’t forget audio. A crackling fire sound is essential. Suddenly this simple effect is looking a bit more complicated. And this is just the beginning. How does the torch become ignited and extinguished? Does it inflict damage when wielded like a weapon? Can it be used to set other things on fire?

    The goal of RMFX Core is to help you realize high-level conceptual effects (like the burning torch) by coordinating the diverse effect technologies that Unity offers. In truth, you can do it all in script, but RMFX Core provides useful tools and methodologies for special effects crafting so you don’t have to build each effect from scratch, or implement your own system.

    Special effects creation in Unity is a very wide topic and there is much space for RMFX Core to evolve and fill. The current available version of RMFX Core, the one included with AoM, is fairly narrow. Most of the base architecture is in place, but since AoM was our first Asset Store product, it contains just enough to realize the first collection of spell effects. As we develop new capabilities for RMFX Core, we’ll show them here in this WIP thread.

    So, what are we currently developing for RMFX Core?
    Selectrons

    Recently, we’ve started adding selectron capability to RMFX Core. What is a selectron? For those of you who are unfamiliar with the term, selectron is a nickname we use for selection effects, those common effects used to indicate that a character, object, or unit is selected. Conceptually selectrons are part of the user interface, but they typically feature effect elements that are integrated with other 3D scene elements. Also, unlike other special effects in networked multiplayer scenarios, an active selectron is typically running on a single client.

    This video shows a selected character as the demo cycles through 8 different selectron implementations.



    Although not shown in the video, selectrons are also useful for free-targeting, where you want to interactively place an arbitrary target for certain kinds of spells and weapons. They might even be used for structure placement in an RTS game or in a level editor.

    You can use just about any building-block effect in a selectron. Projector-based zodiac effects are really useful when you want to show that a character is selected, but there are many other possibilities. Selectrons in this series also make use of mesh effects, particle-system effects, sound effects and lighting. Selection effects may seem like simple effects, but you can go much further than just placing a decal at a character’s feet.

    Like other effect categories in RMFX Core, selectrons can be highly adaptive to context. For example, effect parameters, such as scale, can be modified on a per-character basis, so that the same selectron fits a small halfling character differently than a large troll. Portions of a selectron can be unique to a specific character type, while other effects used by the selectron will be the same across all selectable character types. Characters can even be configured to react when targeted by a specific selectron. In the video, for one of the selectrons, the character automatically reacts to being selected and temporarily goes into an alternative idle animation.

    $rmfx_fireball_at_sele.jpg

    In support of Selectrons, we’ve also added a basic one-at-a-time selection system to the demo that goes with RMFX Core. It works a lot like the selection system used in World of Warcraft and other RPGs. The image above shows the system working in combination with Acts of Magic. A fireball spell has been cast at the goblin character which the red arrow selectron indicates as the selected target.

    Acts of Magic Forums Thread

    Goblin Warrior by Mister Necturus

    Animated Wizard by Mister Necturus

    Landscapes Part 1 by Manufactura K4
     
  2. faust

    faust

    Joined:
    Dec 19, 2007
    Posts:
    64
    One of our Acts of Magic customers expressed an interest in having better control over color ranges and dynamics. This WIP update shows some experiments implementing new effect types that dynamically manipulate Materials and Shaders.

    [video=youtube_share;GgAH-8-eMr4]http://youtu.be/GgAH-8-eMr4

    In this video, I’ve modified the Ring of Fire spell from Acts of Magic to demonstrate some material swapping and manipulation. I’m not trying to improve the Ring of Fire spell here. I’m just using it to show some effects in action. Also, I should mention that I’m using a couple of nice shaders from CharacterFX, a fine product from the Unity Asset Store.

    The most obvious effect in the video is a Ghost shader applied to the spellcasting avatar. Near the start of the spell, the spellcaster’s primary Material is replaced with a Material using the Ghost shader. Then, while the character is ghosted, the _RimColor parameter of the Ghost shader is animated with the help of a color Gradient. Colors in the the gradient were chosen to be obvious and were also timed to coordinate with the actions of the character. When the character strikes the ground with her staff, you should observe sudden color shifts.

    $gradient_component.jpg

    Another, less obvious (but more realistic) material effect is applied to the goblin characters. When a goblin is set on fire by the Ring of Fire spell, the Up In Flames special condition is applied to it. This effect attaches flame effects to the goblin, plays one of it’s death animations, and then removes it from the scene. For this demo, a new material effect has been added. It replaces the goblin’s primary Material with one based on the Disintegration shader from CharacterFX. Disintegration is one of those shaders that uses the “clip” function and a grayscale texture to gradually mask out pixels of another texture. In this case, the Up In Flames effect animates the _DisintegrateAmount parameter of Disintegrate to make the goblin’s corpse appear to be consumed by the flames.

    $goblin_dematerialize.jpg
     
  3. pixelsteam

    pixelsteam

    Joined:
    May 1, 2009
    Posts:
    924
    Looks just fantastic!!!
     
  4. faust

    faust

    Joined:
    Dec 19, 2007
    Posts:
    64
    For the last few weeks I’ve been spending quite a bit of time integrating many of the new capabilities described in this thread into an update of the RMFX Core Framework. Unfortunately, code refactoring, testing, and debugging does not tend to produce a lot of new imagery, so this thread has been quite.

    However, I did find time over the weekend to capture a quick video of some recent experiments with Explosion Force Effects.



    Applying an explosion force to simple prop objects is quite easy, but applying an explosion force to a character can be considerably more difficult, especially if the character (like the goblin in the video) is controlled using a system built around the standard Character Controller component.

    In the video we cast a simple freely targeted spell that applies an explosion force to nearby objects. For the first three castings we apply the force using a technique that temporarily disengages the goblin's Character Controller while engaging a Rigidbody/Collider combo to respond to the force. It also switches the goblin to a flailing type animation to make the effect look more convincing. The Rigidbody is constrained to remain upright so that control can be easily restored to the Character Controller once the goblin lands on back on the ground.

    The fourth casting of the spell uses a more severe technique that replaces the goblin with a ragdoll version and applies the force to the ragdoll. It's very difficult to animate convincingly from a collapsed ragdoll back to an upright stance so we consider the goblin killed and dissolve its corpse out of the scene.

    Note that this video also demonstrates use of a free targeting Selectron to trigger the explosion force at arbitrary locations on the terrain.
     
  5. pixelsteam

    pixelsteam

    Joined:
    May 1, 2009
    Posts:
    924
    Ola Faust.
    Has this been rolled into the latest build yet? Looks great!
     
  6. faust

    faust

    Joined:
    Dec 19, 2007
    Posts:
    64
    @ pixelsteam -- A big update for the Acts of Magic product is coming real soon. It's in the final stages of preparation.
     
  7. faust

    faust

    Joined:
    Dec 19, 2007
    Posts:
    64
    One of the best ways to improve a software API or scripting framework is to have it used in a big production project. It puts important, hard to predict, pressure on the software that reveals bugs and exposes weaknesses while simultaneously driving innovation and enhancement.

    For new software, big projects are not always readily available and willing to be middleware guinea pigs, so when developing special effects software, I’ve found that the next best thing is to have an experienced effect designer build some effects with the system. Preferably, large-scale epic effects , conceptualized from the top down, that push the boundaries of the software’s capabilities.

    For a number of weeks now, Matthew Durante, a long-time collaborator of mine, has been designing and developing a large-scale effect using Unity with the RMFX Core special effects framework. Matt likes to design really epic and grandiose effects and he’s fearless about pushing for bigger and better results. He also rarely pre-conceptualizes his designs to workaround any apparent limitations, which makes him perfect for the task. Along the way, I provide support and just try to keep up. I steer him toward the software’s strengths, I repair what breaks, I complete those features I left unfinished, and I add new effects and capabilities as needed. Gradually, Matt’s effect takes shape and the RMFX Core framework evolves and becomes more robust.

    Currently, Matt’s effect is still a work-in-progress, but I’ve finally got some video captures of what it currently looks like. The effect is an electric/lightning themed magic spell we’ve dubbed Sparks of the Tempest. Technically, the spell has a single target, but it inflicts a lot of area damage along the way and the final impact damages much more than the intended target.

    This first video is a continuous shot in which a female wizard casts Sparks of the Tempest three times in the midst of a large horde of goblin warriors.



    In this second video, we see a single casting of Sparks of the Tempest where the camera tracks the flight path of the projectile from a fairly close distance.



    This third video shows the full spell sequence in slow motion with the Unity timeScale set to 0.5.



    In addition to the RMFX Core, this demo makes use of several quality add-on packs from the Unity Asset Store:
    - Animated Wizard by Mr Necturus
    - Goblin Warrior by Mr Necturus
    - Landscapes Part 1 by Manufactura K4
    - CharacterFX Shader Pack by Aztica
     
  8. faust

    faust

    Joined:
    Dec 19, 2007
    Posts:
    64
    I forgot to point out that the videos of Sparks of the Tempest in the last post don't have any audio. Sound effects are a major piece of the effect that are still missing, so I left them silent. Would it be too cheesy to hook them up with some free YouTube music?
     
  9. MDurante

    MDurante

    Joined:
    Aug 27, 2013
    Posts:
    2
    Nice videos Mr. Faust!

    I've been doing effects stuff with Faust on and off for many years on many projects and many engines. Unity, and Faust's RMFX framework, are the most powerful toolsets I've used yet. Hopefully I can push it 'til it breaks because that's what I do.

    Sparks of the Tempest needs some tweaking... And it's missing a casting effect of some kind. Right now the spellcaster just tosses the missile, but it needs a better build-up...
     
  10. faust

    faust

    Joined:
    Dec 19, 2007
    Posts:
    64
    Here is an interesting outtake from that last batch of Sparks of the Tempest videos...



    Near the beginning of the shot watch for the odd flight one of the goblins takes out of the picture towards the left in response to one of the lightning impacts. He appears to survive the force effect and reenters the shot running back towards the right. Usually the impact response is not so strong so I suspect that particular goblin might have picked up forces from more than one impact.
     
  11. pixelsteam

    pixelsteam

    Joined:
    May 1, 2009
    Posts:
    924
    Fantastic work. Will any of the be rolled out in the new release?
     
  12. faust

    faust

    Joined:
    Dec 19, 2007
    Posts:
    64
    There is a lot from the Sparks of the Tempest effort that is rolled into the new release of Acts of Magic but it's mostly subtle stuff, not big explosions and lightning bolts and stuff. The Sparks effect is in our Dev branch which is at Unity 4.3 and the AoM branch is maintained as a Unity 4.0 project and I was constantly moving code back and forth between the branches.

    The big thing AoM gets from Sparks is greater robustness. The big effect broke the core scripts in a lot of places and it exposed some big holes, such as the fact that I had never implemented effect fading on ParticleSystem effects. Also, by closely observing someone else use the software it became obvious what aspects are most misunderstood and prone to errors.

    I think the way controlled characters can now respond to force effects comes from Sparks as well as some refinement of the DeMaterialize effect.

    There’s a lot of custom coding going on in Sparks of the Tempest and it’s still very much a prototype. I’ll be carefully going through all the pieces, looking for ways to improve it and also looking for general mechanisms that can be moved into RMFX Core. Most likely this will also spin off some standalone effects like a lightning-bolt effect and some explosions.

    I’m particularly interested in how we implemented the dust cloud effect that triggers when the goblin bodies strike the terrain. For practical reasons, we ended up attaching it to the goblin ragdoll, but I’ve got some ideas for a special kind of collision effect that would trigger per-object effects on both objects participating in a collision. In that case, the dust effect would be associated with the terrain instead of the goblin with the potential that the terrain could be rigged to trigger different effects depending on where on the terrain the impact occurred.
     
  13. MDurante

    MDurante

    Joined:
    Aug 27, 2013
    Posts:
    2
    Working on "Sparks of the Tempest" casting…. I see a mighty electrical ball forming about the spell caster, then shooting out…

    $SoT_casting1.jpg
     
  14. faust

    faust

    Joined:
    Dec 19, 2007
    Posts:
    64
    As of the 4.3 update, Mecanim finally supports Animation Events!

    Some of the Acts of Magic effects, especially Earthquake Romp with all its footfall effects, make use of Animation Events to trigger calls into the RMFX Core system at important timing points, such as contact points in a walk or run cycle. Previous to 4.3, I used an add-on from the Asset Store (Event System for Mecanim) to get the equivalent of Animation Event timing triggers out of Mecanim setups, but now it can be done with vanilla Mecanim.

    To test out this new feature and begin a deeper exploration of complex Mecanim-based character controllers, I picked up a copy of Character System by Robin Schmidt from the Asset Store. Character System provides deep Mecanim based character control that goes way beyond your basic run and walks cycles and includes climbing, swimming, melee moves, evasion rolls, and much more. It would be perfect it if it also had some spellcasting gestures, but I’m not complaining. There is so much here to work with.

    Here’s a video showing my first stab at making the AoM spell Earthquake Romp work with Character System’s Ninja character:

    [video=youtube_share;TppCAQYdmcI]http://youtu.be/TppCAQYdmcI

    Adding Animation Events for footfall and landing events to several of the system’s Animation Clips was straight forward, but it was quickly obvious that I needed to do something extra here to manage the increased complexity of this controller. In the Legacy animation system, even with animation blending, it’s usually quite clear which clips need the Animation Events. With Mecanim, where you can easily build complex movement trees with multiple overlapping animation clips, it’s not so obvious.

    The first problem was that Animation Events for the Jogging cycle would still trigger when the character appeared to be standing still in an idle. Apparently, the run cycle was still being blended in at an extremely low weight and this was still enough to trigger the events. Fortunately, I found a way to examine the current weights associated with running Animation Clips in Mecanim, and was able to filter out events occurring below a threshold before sending the events into the effect system.

    Another problem occured sometimes during transitions between states containing Animation Events resulting in overlapping events which in turn would launch multiple effects per footfall. Again, the running Animation Clip weight came in handy and I was able to code a system that prioritized incoming events and prevented redundant effect generation.

    From there it was mostly just a matter of identifying which clips needed the Animation Events. This character does a large variety of jumps, falls, and rolls, so I added a lot more Landing events than usual.

    Beyond testing the Animation Event feature, I started to experiment with how to call into a Mecanim system to trigger state changes and animation behaviors from the effect system. This can be seen at the start of the video where a pull gesture followed by a forward dive roll are triggered by the Earthquake Romp casting responder. There is a lot more to explore here, such as Mecanim parameter steering from Tech Effects.
     
  15. mcconrad

    mcconrad

    Joined:
    Jul 16, 2013
    Posts:
    155
    it is also extremely useful for adding events to the attacks so that you can turn on and off colliders, triggers, or weapon trails and such. i have not used it yet for footstep impacts, but you can fix the problem above with idle cycles triggering it just by making sure that the animation state tag is in combat not idle
     
  16. faust

    faust

    Joined:
    Dec 19, 2007
    Posts:
    64
    I figured there were other solutions for filtering running Animation Events while idling. Checking the name and/or tag of the current AnimatorStateInfo does look useful and more direct, however, I do believe that in the Character System controller both the idle clip and the jog clip are in MoveTree.
     
  17. mcconrad

    mcconrad

    Joined:
    Jul 16, 2013
    Posts:
    155
    yes there are several trees, and combat also has its own idle, so basically it would be best to check the states/tags just to make sure they are in the states you want and not in those you don't
     
  18. faust

    faust

    Joined:
    Dec 19, 2007
    Posts:
    64
    I think a working strategy here is to first check Animator.GetCurrentAnimatorStateInfo() and use that to narrow the possibilities down to a small set of clips that need to be prioritized by weight.
     
  19. Silly_Rollo

    Silly_Rollo

    Joined:
    Dec 21, 2012
    Posts:
    501
    Is everything in those videos under the hood (not the graphics) in Acts of Magic? Reading your blurb on that asset made me interested but the effects in the demo for it didn't show off a lot of layering. Those videos are quite impressive though especially if they are being driven by editor scripts and not custom spell code.

    I have a spell / effect framework that I threw together for my project and I've found it difficult to make true generics and most effects end up needing specific hacky code for each effect so I'm interested in your progress.
     
  20. faust

    faust

    Joined:
    Dec 19, 2007
    Posts:
    64
    The videos seen in this thread (at the time posted) are all made using our development branch of the RMFX Core framework which contains features and experimental code that are not part of the RMFX Core version included with Acts of Magic. A lot of Sparks of the Tempest is still experimental and the latest work with Character System is also still in development.

    Some of what’s seen in the first few videos was migrated to Acts of Magic in a recent update. Support for Selectron effects is now there and so are the Dynamic Material effects. Also, a lot of low-level changes and fixes made while getting Sparks to work have been migrated.

    It hasn’t been a primary goal of RMFX Core to be able to craft spell effects without doing any custom scripting and each of the Acts of Magic spells do indeed contain a certain amount of code that is unique to the effect. I do however try to find structures and methodologies that minimize the need for per-effect custom code, and as the framework has evolved, I’ve been able to capture more and more reusable functionality.

    Actually, it’s been a higher priority to realize effects with a high amount of parameterization that end users can tweak at the level of Inspector editing, and that allow effects to work with a lot of different characters. A certain amount of per-effect coding goes into supporting these goals.

    Generally, the low-level portions of each spell are built fairly generically. This is where existing Tech Effects (like ParticleSystems and Projectors) are defined and combined into groups. But at the top end, there is usually some per-effect scripting that orchestrates the instantiation of the groups. The framework does provide support mechanisms for doing this though.

    If you haven’t already seen these references, you may find them informative:
    Acts of Magic - User Guide
    RMFX Core - Effects Crafting Primer (Draft)

    I'm not exactly sure what you mean by "layering" here. If you can clarify, I might be able to give better answers.
     
  21. Silly_Rollo

    Silly_Rollo

    Joined:
    Dec 21, 2012
    Posts:
    501
    Parameterization I suppose was my desired end goal as well. The idea was that effects could be broken down into broad categories like physics projectile, straight lerp projectile, selectable area, self, etc without any magic numbers in the scripts and the specifics could be controlled via inspector scripts for each spell prefab for easier tweaking. I think my problem was that I didn't built my system to be as component based as it should have been.

    By layering I meant like how the tempest seems to be handling a number of tech and gameplay effects such as a trail, light source, graphic for projectile, some form of area trigger that directs the lightning and spawns its effects, and then directs the projectile to seek a target and spawn in its explosion effect. How much of that is a specific tempest spell script and how much comes from more generic components being added together?

    Glancing through the user guide it looks like many of your effects do come from combining generic components though in that doc when you say "prefab" do you mean a literal gameobject prefab or just another script? Like is "Earthquake Romp" a gameobject prefab with 4 child gameobjects?
     
  22. faust

    faust

    Joined:
    Dec 19, 2007
    Posts:
    64
    OK, I see what you mean.

    Most of what makes Sparks of the Tempest more “layered” is that it’s a much more extravagant spell than those in Acts of Magic. We were intentionally pushing the system, and Matthew Durante (the effect designer) wanted a richer spell behavior with lots of secondary effects. Most if this comes from a deeper design and the layering capability is present in the RMFX Core framework, even if it’s not reflected as strongly in the AoM spells.

    For projectiles, the framework includes a Missile Effect which is a high-level effect made specifically for projectiles. Effect-wise, the Missile Effect primarily manages the continuous “contrail” effects during the projectile flight. It also contains references to several impact effects (Primary, Secondary, and Fizzle) that are conditionally executed based on how the missile flight ends. Projectile flight behavior is managed by a companion Missile Drive component which optionally supports several “fizzle” conditions that may end the projectile flight without a collision, (based on distance, timing, or target loss). AoM includes Seeker Drive which is a subclass of Missile Drive that implements a guided missile that dynamically seeks a target object. Sparks of the Tempest uses a more elaborate customization of Seeker Drive, mainly to get the complex coil and spiral movement of the projectile.

    For the most part, Impact Effects (explosions) are interchangeable. They are typically represented as a Unity prefab that can be dragged-and-dropped into a Missile Effect in the Inspector. In fact, in a recent experiment, I wrote a generic effect wrapper that makes any explosion in the Detonator Explosion Framework work as an Impact Effect in RMFX Core.

    Most of the bigger spells are made up of Unity prefabs. For example, Earthquake Romp is represented by a prefab. Variations can be made by duplicating the prefab and changing parameters in the Inspector, such as scale and duration. (Parameters can also be modified by the specific character targeted by the spell.) The Earthquake Romp prefab references additional child effects (Unity prefabs) that implement the stomping effects. One for each foot and a bigger one for stomping. Typically we use the same effect for left and right footfalls, but they could be different, say if your character was a peg-legged pirate.
     
  23. faust

    faust

    Joined:
    Dec 19, 2007
    Posts:
    64
    Recently I've been working more with Mecanim and about a month ago, I started experimenting with the idea of adding spellcasting motions to an existing Mecanim rig by retargeting animation from a totally different rig. With the help of a new MayaLT subscription, I now have access to a variety of spellcasting animations we created a while back for the Arcane-FX product, so I decided to try combining one of these with a basic Mecanim controller.

    For the experiment, I picked out a fairly challenging motion sequence from an AFX spell called Insectoplasm. The movement for this spell is much more than a spellcasting gesture and actually levitates the character and spins it. To my surprise, it worked quite well and I really didn’t have to do a whole lot to add the new spellcasting motion as a new state in the Mecanim controller that can be transitioned to from an idle state and back.

    Here is a video of the initial retargeting test:




    Upon getting reasonably good results from the animation retargeting, I decided to move forward and start migrating the rest of the spell into Unity. Here are some more videos in a series documenting the rebuilding of the spell in Unity.


    For this video, lights, audio, and zodiac decals have been added:




    This pass adds a bunch of bugs, floating symbols, and some goo zodiacs:




    In this fourth video, the addition of goo particles and light beams mostly completes the casting portion of Insectoplasm:




    If you’d like to read more about this series, I’ve also written about it in my blog Effectronica.com:
    Insectoplasm: A spell effect under construction (part 1)
     
  24. Demonith88

    Demonith88

    Joined:
    Jun 30, 2014
    Posts:
    216
    Is there a way to have a tutorial on fx maing