# Visual Effects Visual effects are an important feature of Microsoft Flight Simulator 2024 as they can be used to make the world and the SimObjects that inhabit it feel more alive. These effects should always be created using [The Visual Effects Editor](../../devmode/editors/vfx-editor/the-visual-effects-editor/) in the actual simulation, as the editor permits you to have real-time visual feedback on the effects being created. However, it may be necessary to edit an effect after it has been created, or you may wish to simply understand the internal structure of how an effect is created and added to a package, and so these pages can be used to get that information.   All visual effects are packaged as part of a **VisualEffectsLib**, which will contain one `*.vfxlib` file and then one or more `*.xml` files. The `*.vfxlib` file is what tells the simulation what effects are contained in the package and is itself basically a form of [XML file](../../devmode/editors/project-editor/file-formats/xml-files/) that can be edited in any text editor, if required. The format for this file is as follows: ``` xml ``` When you are creating your effects, the general folder structure for saving the `*.xml` and `*.vfxlib` files would be: <FSProject\_Folder>\(PackageSources\)VisualEffectLibs\\<CompanyName>\\ {{< callout context="note" title="NOTE" icon="outline/bulb" >}} Visual effects XML files will be compiled into [SPB files](../../devmode/editors/project-editor/file-formats/spb-files/) when the package is built. {{< /callout >}} The different XML files listed in the `*.vfxlib` file are the files for individual effects. The structure of these individual effect files is explained on the following page: - [Visual Effects XML Properties](visual-effects-xml-properties/)   You can also find fully formatted examples from the following page: - [Visual Effects XML Examples](visual-effects-xml-examples/)   To implement the visual effects in your add-ons requires the use of **model behaviours** and the associated **templates**. You can find full details of this process on the following page: - [Adding Aircraft VFX](../models/modelbehaviors/usingbehaviours/vfx/adding-aircraft-vfx/)   ### Using Visual Effects Once you have created your visual effects, you'll need to be able to add them to your SimObjects. This is done by including references to the effect in the [Model XML Properties](../models/model-xml-properties/) file for the SimObject. Visual Effects are contained within **Component Templates**. The base template for Visual Effects is defined in the `FX.xml` document, so to start with you need to make sure that you add the following line into a `` element: ``` xml ``` Once you've done that, you can start to use the **Component Templates**. For this, first add a Component with a unique string ID attribute like this: ``` xml ``` Inside that component you will need to declare what template you are using, and what parameters of that template you want to change in a `` section: ``` xml ``` The available default parameter elements are : - ``: The {{< glossterm >}}guid{{< /glossterm >}} of the VFX to spawn. This can be found as the "`InstanceID`" attribute value of the `` element in the [Visual Effect XML](visual-effects-xml-properties/) asset source file in the following format: {XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX} - ``: [RPN code expression](../../programming-apis/reverse-polish-notation/) evaluated by the simulator. When it becomes `true` the Visual Effect is spawned. When it becomes `false` the Visual Effect is stopped. - ``: The index of the **ContactPoint** you want to attach the effect to. You can use it as a fallback if the node you provided is not found. The default value is -1 which means you don't want to use any contact point (in which case you will you need to provide a valid **node**, as explained further down this page). - ``: X offset in the coordinate space defined for the Visual Effect, applied to the Visual Effect after spawn (meters, default value is 0). - ``: Y offset in the coordinate space defined for the Visual Effect, applied to the Visual Effect after spawn (meters, default value is 0) - ``: Z offset in the coordinate space defined for the Visual Effect, applied to the Visual Effect after spawn (meters, default value is 0) - ``: Pitch rotation angle in local space (degrees, default value is 0) - ``: Bank rotation angle in local space (degrees, default value is 0) - ``: Heading rotation angle in local space (degrees, default value is 0) If you don't need something else than the default value then you don't need to add the parameter to the override section. Below is a short example of how this all comes together: ``` xml {7E68323C-E75D-4F5B-988E-65DD4956F6BA} 1 0 > 2 1.0 90.0 ``` With that done, you can define each instance of your effect to spawn as a child Component with a unique ID and a Node like this: ``` xml {7E68323C-E75D-4F5B-988E-65DD4956F6BA} 1 0 > 2 1.0 90.0 ``` Note that the **Node** attribute is mandatory. Its value must match the name of a node in your model mesh. If you don't want to attach to a node the attribute must still be present - you can put a placeholder value such as "`__NO_NODE__`" to make sure you don't accidentally match a node in your model - and you must provide a contact point to spawn on with the `` template parameter.   If you want to override some template parameters for a specific instance of your effect you can also do that inside a `` element, EG: ``` xml {7E68323C-E75D-4F5B-988E-65DD4956F6BA} 1 0 > 1.0 5.0 -5.0 2 8.0 90.0 ``` There are also more advanced template parameters that you can use to get further control over the behavior of your Visual Effect: - ``: Enumerates the different surface types over which your Visual Effect may spawn. This implicitly disables all other surface types. See the [Surface Types](visual-effects/#surface_types) section for a full list of names associated with each surface type. - ``: Enumerates the surface types over which your Visual Effect may *not* spawn. - ``: Enumerates over which surface types your Visual Effect will be replaced by another. The other effect is referenced with a GUID defined in the corresponding `` template parameter. - ``: This defines which Visual Effect will replace the one defined by the `` parameter for the corresponding `` parameter. - ``: This element is used to define a custom parameter and some accompanying [RPN](../../programming-apis/reverse-polish-notation/) code that can then be used in the [GraphParameter](../../devmode/editors/vfx-editor/nodes/graphparameter/) VFX node. For full details of how this element can be used please see here: [Example Using Graph Parameters](visual-effects-xml-examples/#graph_params) The value `N` for the elements listed above must start at 0 and be incremented sequentially to however many you need. Below is a further example showing how to use these elements: ``` xml {7E68323C-E75D-4F5B-988E-65DD4956F6BA} 1 0 > CONCRETE ASPHALT BITUMINUS MACADAM TARMAC 5.0 InitialSize, (A:GROUND VELOCITY, knots) 50 / CONCRETE {A8CEDC03-94A2-4B18-89C7-2DCD96CC83DE} ASPHALT {A8CEDC03-94A2-4B18-89C7-2DCD96CC83DE} InitialSize, (A:GROUND VELOCITY, knots) 10 / ``` Please see the [Model Behavior Example](visual-effects-xml-examples/#h) on the main examples page for a complete version of a Visual Effect added to the `` element. There is also a page dedicated to showing how to use specific model `` templates for VFX: - [Visual Effects Templates](../models/modelbehaviors/usingbehaviours/vfx/visual-effects-templates/)     #### Surface Types Below is a list of the viable names that can be used for surface types when using the ``, ``, or `` elements in the VFX templates: 1. `CONCRETE` 2. `GRASS` 3. `WATER_FSX` 4. `GRASS_BUMPY` 5. `ASPHALT` 6. `SHORT_GRASS` 7. `LONG_GRASS` 8. `HARD_TURF` 9. `SNOW` 10. `ICE` 11. `URBAN` 12. `FOREST` 13. `DIRT` 14. `CORAL` 15. `GRAVEL` 16. `OIL_TREATED` 17. `STEEL_MATS` 18. `BITUMINUS` 19. `BRICK` 20. `MACADAM` 21. `PLANKS` 22. `SAND` 23. `SHALE` 24. `TARMAC` 25. `WRIGHT_FLYER_TRACK` 26. `OCEAN` 27. `WATER` 28. `POND` 29. `LAKE` 30. `RIVER` 31. `WASTE_WATER` 32. `PAINT`