Texture and Effect Render Plug-in Sample

Related Links


The Custom Texture and Effect Sample is a simple implementation of the new Prepar3D Custom Texture and Effect plug-in capabilities.

The source code for the sample can be found at:

<Prepar3D SDK Path>\PDK General Samples\TextureandEffectRender

Custom texture placed in a panel in the Mooney Bravo Glass Cockpit

Sample Gauge

Custom effect sample over Mooney Bravo glass cockpit view

Custom Effect

About the Custom Texture and Effect Sample

Prepar3D v1 had a featured called DirectX Gauge which allowed for C++ gauges to render into a panel texture using DirectX 9. DirectX gauges have been deprecated for Prepar3D v4, but similar capabilities are supported via the new Texture and Effect plug-ins. Now, DirectX 11 rendering into a texture or onto the output of 3D view in Prepar3D is possible. This sample illustrates how these two plug-ins work and how Texture plug-ins can be used in combination with programmable gauges to achieve hardware accelerated rendering of gauge textures. The advantage of separating the Texture and Gauge system is that the plug-in can be a stand-alone add-on. This method provides a texture that artist can reference from any model or as a scriptable element in XML gauges.

Custom Texture and Effect Sample consists of the following files:

Additionally, a sample configuration file is provided for reference.

NOTE: This sample is a lightweight implementation of the capabilities available to rendering plug-ins. It is expected that most of the actual DirectX drawing/rendering/animation in the example can be done in a more efficient manner, but this example should serve to demonstrate the basics of how to use the new plug-ins. For those interested in more detailed DirectX tutorials, they are available in Microsoft's DirectX Software Development Kit (SDK).

Setting Up the Project

To build the project:

  1. Open the SDK Samples.sln found in the SDK at <Prepar3D SDK Path>\ with Visual Studio 2019.
  2. Right-click on the main Project within the Solution Explorer and select "Properties".
  3. In the Project Property Pages, select the VC++ Directories Entry.
  4. Update the Include Directories path to include the paths to:
    • Pdk.h and RS_IPluginSystem.h
    • <Prepar3D SDK Path>\inc\PDK\
  5. Click the Apply button to save the settings.
  6. Right-click on TextureandEffectRender in the Solution Explorer. Select Build to begin building the Sample.

NOTE: Paths denoted with < > signs represent paths on your machine that may vary based on your installation. Please ensure you have input these paths correctly, as failure to do so may cause the build to fail.

Installing the Gauge and Effect

This section discusses installation of Custom Texture and Effect Sample into an aircraft in Prepar3D. This section assumes that you have successfully built the project and that it has generated a valid a TextureandEffectRender.dll file.

  1. First, copy the Copy the TextureandEffectRender folder in the output directory to the "%USERPROFILE%\Prepar3D v5 Add-ons" directory.
  2. %APPDATA%\Lockheed Martin\Prepar3D v5
  3. Next, identify the aircraft that will be used to display the gauge. Glass panel aircraft tend to provide larger surfaces on which to test; however other cockpits may also be used. Open the plane's panel.cfg file (found within <Prepar3D Path>\SimObjects\Airplanes\<Aircraft Selected>)
  4. Inside the panel.cfg, identify the virtual cockpit to include the DirectX gauge on. Edit the panel.cfg by adding the Texture entry similar to the example shown above. 
  5. Add the folder path, which contains the Example.fx shader file, to the ShadersHLSL.cfg file located in %PROGRAMDATA%\Lockheed Martin\Prepar3D v5. Please see the Add-ons Overview article for more information.
  6. Once the panel.cfg file for the aircraft has been updated appropriately, run Prepar3D and verify the gauge appears within the cockpit.

Extending the Example

The example demonstrates two simple concepts

  1. Displaying a rendered texture on the Virtual Cockpit.
  2. Overlaying a texture on top of a current view.

Extending to other concepts

  1. Add mouse handler to the texture: A mouse handler can be added to a gauge and placed on top of a rendered texture to capture mouse events. More information can be found in the Programmable Gauges section.
  2. Rendered texture can also be displayed on 2D panels.
  3. XML Gauge has the capability to display Texture within an Element Object.

Troubleshooting & Limitations