Difference between revisions of "Blender2P3D/FSX"

From FSDeveloper Wiki
Jump to: navigation, search
(Scenery properties)
(Using the Tools)
Line 58: Line 58:
 
= Using the Tools =
 
= Using the Tools =
  
== Overview ==
+
== Overview ==[[Image:Blender2p3dfsx setup4.jpg|thumb|right|P3D/FSX Toolset panels]]
 
Once installed, the Blender2P3D/FSX toolset will append the list of toolkit panels in your viewport. Press "N" to open or close the list of tools. There will be a new entry named "P3D/FSX", which gives access to the tools of this addon. The different tools are organized in different panels, which are grouped by function.
 
Once installed, the Blender2P3D/FSX toolset will append the list of toolkit panels in your viewport. Press "N" to open or close the list of tools. There will be a new entry named "P3D/FSX", which gives access to the tools of this addon. The different tools are organized in different panels, which are grouped by function.
 
The addon adds object properties to the scene. These properties are for instance the references to the various SDKs you can utilize or object properties like attached animations or scenery properties.  
 
The addon adds object properties to the scene. These properties are for instance the references to the various SDKs you can utilize or object properties like attached animations or scenery properties.  
Line 65: Line 65:
  
 
== Setting up your scene ==
 
== Setting up your scene ==
[[Image:Blender2p3dfsx setup4.jpg|thumb|right|P3D/FSX Toolset panels]]
 
 
To ensure that your 3d asset export properly to Prepar3D or Flight Simulator X, you must make sure to prepare and configure the Blender scene. To get started, open the toolset panels by pressing "N" on your keyboard with the main viewport being in focus. This will open a list of panel you have currently activated in your Blender configuration. Click on the tab "P3D/FSX" to bring up the panels of the Blender2P3D/FSX toolset.
 
To ensure that your 3d asset export properly to Prepar3D or Flight Simulator X, you must make sure to prepare and configure the Blender scene. To get started, open the toolset panels by pressing "N" on your keyboard with the main viewport being in focus. This will open a list of panel you have currently activated in your Blender configuration. Click on the tab "P3D/FSX" to bring up the panels of the Blender2P3D/FSX toolset.
 
=== Configure the SDK ===
 
=== Configure the SDK ===

Revision as of 11:28, 27 March 2020



The Blender2P3D/FSX toolset is an addon for Blender. This addon is a continuation of the Blender2FSX Toolset manual and it incorporates compatibility with the latest API for Blender version 2.8x and above. The new toolset also features full support of PBR materials for Lockheed Martin's Prepar3D v4.4 and above, as well as some changes to the interface and file structure of the addon. This wiki will help you install and use the new toolset.

Installation

Requirements

  • Windows 10 or 8.x
  • Microsoft Flight Simulator X SDK including updates to SP2 or Acceleration or
  • Lockheed Martin Prepar3D SDK v2.x, v3.x, & v4.x

Setup

After downloading the addon, open Blender 2.8x and open the Preferences (Edit->Preferences). Navigate to the "Add-ons" tab and click on "Install...". In the file manager, navigate to the Blender2P3DFSX.zip file, select it and click on "Install Add-on". This will extract the content of the zip file to your Blender script folder (by default under: %APPDATA%\Blender Foundation\Blender\<version number>\scripts\addons). Next, you need to activate the addon by clicking on the check-mark next to "3DView: P3D/FSX Toolset". That should enable the addon and the various panels and properties. Close the Preferences window.

To ensure that the addon was correctly installed, press "N" on your keyboard while the mouse pointer is in one of the main viewports. This should open the main panels of the addon under the tab named "P3D/FSX".

Using the Tools

== Overview ==
P3D/FSX Toolset panels

Once installed, the Blender2P3D/FSX toolset will append the list of toolkit panels in your viewport. Press "N" to open or close the list of tools. There will be a new entry named "P3D/FSX", which gives access to the tools of this addon. The different tools are organized in different panels, which are grouped by function. The addon adds object properties to the scene. These properties are for instance the references to the various SDKs you can utilize or object properties like attached animations or scenery properties. Furthermore, the addon will append the material parameters by P3D or FSX specific parameters. Lastly, the addon extends the exporter capabilities and allows you to export your scene to an x-file format and from there calls XToMdl.exe to generate a Prapar3D/Flight Simulator X compatible 3d model.

Setting up your scene

To ensure that your 3d asset export properly to Prepar3D or Flight Simulator X, you must make sure to prepare and configure the Blender scene. To get started, open the toolset panels by pressing "N" on your keyboard with the main viewport being in focus. This will open a list of panel you have currently activated in your Blender configuration. Click on the tab "P3D/FSX" to bring up the panels of the Blender2P3D/FSX toolset.

Configure the SDK

Firstly, go to the P3D/FSX Toolset Settings and select if you're prepping your scene for FSX or P3D. If you chose P3D, you also need to ensure that you have the correct version of the SDK selected. If "Auto Detect SDK" is enabled, simply click on "Initialize <P3D/FSX> Toolset". The addon will then lookup the file paths of the SDK in the Windows registry. This method should work in 99% of the cases, however if the Addon cannot find the file paths, you can also use the Manually Find ModelDef file option to set up the path.

Configure the scene

In order for your 3d asset to export properly, you have to ensure that both a GUID and a friendly name are assigned to your scene. To do so, open the P3D/FSX File Properties panel and type the friendly name in the first edit box. You can use the button Generate GUID to automatically generate a valid GUID for your scene. Alternatively, you can generate the GUID externally and copy and paste the string into the GUID edit box.

Scenery properties

[feel free to enter the information here.]

Animations

tbc...

Attachpoints

tbc...

Material parameters

The P3D/FSX Blender toolset will extend the material properties to include flight simulator specific parameters. Make sure to carefully go through the list of properties to make sure that your material is ready for export. The most fundamental parameter is the main material mode. You can choose between "PBR Material", "Specular Material" and "Disabled". Note that any material with the mode being set to "disabled" will be skipped during the export process. Also note that the PBR material is only available for models used in Prepar3D version 4.4 or higher. Therefore, if you are preparing a model for FSX or older versions of Prepar3d, make sure to have the material mode set to Specular.

The P3D/FSX Blender toolset is making use of Blender's shader graph and as a result it is important that your materials comply with the conventions of the addon's exporter. Whenever you change between different material modes, a script will automatically replace the current shader graph with one that is compatible with the chosen material mode. This means that currently you will have to re-assign all textures every time you change the material mode!

The exporter will run an analysis on all materials to extract the texture information. This is done in two ways, by checking what texture nodes connect to the relevant input nodes and by looking for specific node names. This way, it is possible to modify the shader graph in Blender while retaining the ability to export the materials properly. The texture paths are searched for in the following manner: 1. check the relevant input socket of the BSDF Principled shader node 2. follow all the links from that node and create a list of texture image nodes 3. if there are more than one texture image nodes directly or indirectly connected to the input socket, check the name of both and see if it matches 4. if there are NO texture image nodes connected to the input socket, search through ALL the texture image nodes of the graph, check if the name matches.

On creation of the shader graph, the texture image nodes will be given their corresponding names. Those are: "diffuse" for the diffuse/albedo texture "specular" for the specular texture "metallic" for the metallic/smoothness/ao texture "emissive" for the emissive/lightmap texture "normal" for the normal/bump map texture

I suggest not to delete any of those texture nodes, in case you'll need them at a later stage. If you don't want a certain texture map to show up on your model, just disconnect the corresponding link.

By default, the emissive image texture is not connected to anything. If you want to see the effects of your lightmap on the model in Blender, simply link the texture node with the input socket labeled "Emission"/"Emissive Color". Note that the emissive map doesn't have to be linked with the base shader node in order for the lightmap texture being found by the exporter!

PBR Material mode

The shader graph for PBR material.

When you switch to the PBR Material mode, the shader graph will be populated with a "BSDF Principled" node and a number of nodes that are linked up with the principled's input sockets. You can revise the material at any point by removing nodes or links. You can also add logic blocks between existing links and observe the effects in the viewport. Keep in mind however, that those type of changes will have no effect on the model when you export it to Prepar3D.

Albedo/Diffuse Map

The Albedo/Diffuse map uses the "Base Color" input socket of the BSDF Principled node. By default, the Alpha channel of the texture node is linked with the Alpha input socket of the BSDF node. For all opaque materials this should have no effect, but for transparent materials it is important that the link remains.

It is possible to modify the shader graph to display the Ambient Occlusion channel of the metallic texture. To do that, add a "MixRGB" node to the shader graph and switch the blend mode to "multiply". Next, connect the Color channel from the albedo texture node to input Color1 of the mixRGB node, and connect the green channel ("G") from the "separate RGB" node of the metallic node to the Color2 input of the mixRGB node. Lastly, connect the output of the mixRGB node to the Base Color input of the BSDF Principled Shader node.

Make sure to disable Ambient occlusion in the scene render settings to not over-saturate the shading.

Metallic Map

The metallic texture consists of three channels. The red channel represents the "metallicness" of the material, the alpha channel the "smoothness" and the green channel can contain an ambient occlusion map. Since Blender is using "roughness" rather than "smoothness", it is necessary to invert the alpha channel of the metallic texture before plugging it into the BSDF Principled node. This is already done for you when you set up the material for PBR.

By default, the AO map is omitted, see above if you want to display it in your scene.

Specular Material mode

The shader graph for specular material.

If you select "Specular Material" as the P3D/FSX material mode, the current shader graph is removed and replaced. The main shader node will now be an "Eevee Specular" node. The shader graph will be populated in a way that most closely represents the shader mechanics of FSX/P3D and all you need to do is adding your texture files to the various texture image nodes. As with the PBR shader graph, you can modify the Specular shader graph in any way you wish - as long as the original Texture image nodes and the Eevee Specular node remain, the exporter will be able to pick up the correct texture paths.

Please note that since it is a node specifically designed for the Eevee render engine, material created in this way won't render properly if you switch the viewport render mode to "Cycles".

Normal maps for PBR and Specular material

Prepar3D and FSX use a non-standard approach to rendering normal maps. This non-standard rendering path is taken into consideration in the Blender2P3D/FSX shader graphs. That means that you can use a normal map that is specifically prepared for P3D/FSX and plug it into the shader - it will render very closely to what you'll see in the flight simulator. The only change that is not taken into consideration is the vertical flip of the texture, so work with the un-flipped version of the texture in Blender.

Environment/Reflection map

Oppose to P3D, Blender is using a global reflection map in conjunction with reflective materials. Depending on your requirements, it might be necessary for you to utilize different reflection maps for different materials. To accommodate this, you can link any reflection map to any material, using the Parameter "Reflection map" under the P3D/FSX material properties. However, any change to the file or file-path will not change anything about how reflections are presented in Blender. If you would like to get an idea of how your reflection map works with your other material settings, you can manually change Blender's global reflection map. To do so, open the "World Properties" and under "Surface->Color", select "Environment Texture" as a new source for the world reflection map and navigate to your texture. Don't forget to change the render mode to "Viewport Shading". Please note that changes to the world properties won't be taken into account when exporting your model to .X or .MDL.

Transparency

If you're working with PBR material, switching your material to transparent is simple. In the P3D/FSX material settings change the "Render mode" to "Masked". The transparency value is taken from the Alpha channel of the Albedo texture node and will be visualized in the viewport. Note that switching from "Opaque" to "Masked" will also enable Backface culling by default, this is simply done for your convenience, but you can switch it off at any time with no effect to the P3D/FSX model itself.

Transparency for Specular material is currently not automated in this way, so any changes to the "Framebuffer Blend" properties of the material will have no effect on how the model is displayed in Blender. These values are, however, taken into consideration when you export your model and should work as expected.

Exporting to .X/.MDL

Export options of the Blender2P3D/FSX toolset.

An essential element of the Blender2P3D/FSX toolset is the ability to export a Blender scene directly into the .mdl format. You can access the exporter by clicking on File->Export->DirectX for P3D/FSX (.X/.MDL). This will open the export dialog. On the right side of the window you can choose various options for the export. Don't forget to enter a valid filename on the bottom of the screen before pressing "Export P3D/FSX .X file".

Note: I recommend opening the Blender console before starting the export process. At the moment the exporter won't give you any visual feedback whether it's running or not, so checking on the console helps to make sure that everything is working smoothly. The console can be accessed through Window->Toggle System Console.

Exporter options

Export only current selection
If this option is active, only the elements of your scene that are currently selected will be exported. This can be useful if you want to quickly check certain parts of the scene, without exporting everything at once.
Apply all modifiers
If this option is selected, every object in the scene will have their modifiers applied before being encoded into the .X file. It is important to have this option enabled, otherwise your model might not be displayed correctly in the sim.
Export animations and LOD
To make sure that the animations and LODs are being exported, this option should be enabled.
Skinned mesh
If there are any skinned meshes in you scene, make sure to enable this option. Otherwise the skinned mesh animations are being omitted.
Export MDL
If this option is selected, the exporter will automatically call the XToMdl.exe converter once the .x file is written. Enable this option to export directly into the Prapar3D/FSX compatible 3d model format.
Create XML Scenery placement for this MDL
[please add content here.]
Create Sample XML Scenery Placement
[please add content here.]
Log File
If this option is checked, a log file will be generated in the same folder you export your scene to. The log file is a simple text file with the name 'BlenderP3DFSXLog.txt'. It can contain valuable information on the export progress if something goes wrong.
Use BMP
If selected, all texture filenames will be changed to <filename>.bmp.

Export process

The exporter will generate an .X file and - if selected - a .xanim file, which will hold the geometric information of your model, as well as the specs of your materials. Some of the properties of the model will be taken directly from the Blender scene, whereas some properties come from the custom properties that the Blender2P3D/FSX addon adds to objects and materials.

The following list describes the operation of the exporter step-by-step.

  1. Collecting object Information

    The exporter will first go through the hierarchy of the scene and generate a list of exportable objects. Those objects are: meshes, bones and empty object if they have anything attached to it. The exporter will also check if the SDK was initialized, a modeldef.xml was found and if the scene contains a valid GUID and friendly name. If "Export Animations" was enabled in the export dialog, a list will be generated that contains information on every part that has an animation tag assigned to it.

  2. Writing the header

    The header of the .x file contains templates for mesh and material information. Since P3D and FSX models differ slightly, the templates are being written depending on the selected SDK.

  3. Outline of the scene's hierarchy

    The exporter will write a quick outline of the scene's objects into the .X file. This outline has no function, but is informative to any one who needs to debug any errors during the export.

  4. Writing scene information

    Next, the exporter will go through the list of eligible objects and encode the geometric information. This includes the position of the vertices, a list of polygons, mesh normals for each vertex, and uv coordinates.

    1. Analyzing mesh materials

      For each material, the exporter will analise the shader graph to find the relevant image texture nodes. If a image texture node cannot be found, or if the filename is empty, the corresponding texture type will be skipped by the exporter.

    2. Writing mesh material

      Once all data is collected, the material properties are being encoded in the .x file.

  5. Writing Animations

    If "Export animations and LODs" has been selected in the exporter window, a .xanim file is being generated, which contains the animation data for all animated objects.

  6. Converting to MDL

    If "Export MDL" has been selected in the exporter window, the exporter will execute the XToMdl.exe of the selected SDK. The Blender system console will show the progress during this step of the export, however note that the output is currently not logged in the log file that is generated by the exporter. If there is an issue with the .X file, or if the XToMdl.exe couldn't be found, an error will be shown in the Blender window.

  7. Export BGL

    [please add content here.]

If the export was successful, you'll find the .X and the .MDL file in the selected folder, ready to be imported into P3D/FSX.

Please note that the exporter currently does not optimize your model! If you want to improve on the performance of your 3d asset, it is recommended to join all parts that share a material but don't have an animation or attachpoint assigned to it. Also note that the export process takes a long time to complete, please have the system console open to check up on the progress of the export.

Credits and license

The addon in its current version is the hard work of many members of the fsdeveloper.com forum. The original FSX2Blender addon was developed by: Felix Owono-Ateba, Ron Haertel, Kris Pyatt (2017) and Manochvarma Raman (2018) This current incarnation of the addon uses most of the original algorithms, but with an updated UI and compatibility for Blender 2.8x. Parts of the original exporter script have been re-written to accommodate Blender's new material workflow and to add PBR support to the addon (P3D v4.4+ only). This work was done 2019/2020 by Otmar Nitsche.

Special thanks go to Arno Gerretsen and Bill Womack for their input during the development and testing of the addon.

The software is licensed under GNU General Public License (GNU-GPL-3). Feel free to use it as you see fit, both for freeware and commercial projects. If you have suggestions for changes, use the support thread in the forum. If you would like to get involved in the development of the addon, contact any of the authors mentioned above to coordinate the effort.