The TrueSkyPluginRender Library

The library TrueSkyPlugRender provides a dynamically-bound dll interface to integrate trueSKY into an external renderer.

Usage is as follows:

  • Initialize by dynamically loading the appropriate TrueSkyPluginRender dll for the platform.

  • Bind the exported interface functions.

  • Initialize trueSKY.

Then, for each rendered view, for each frame that is rendered, insert trueSKY in the pipeline, after the depth buffer has been generated, but before any translucent rendering.

For example, in a Win32 environment, you might load the dll with:

HMODULE dllHandle = LoadLibrary(L"TrueSkyPluginRender_MT.dll");

Then, the interface functions are initialized, e.g.

//! Graphics API list
enum GraphicsDeviceType
        GraphicsDeviceUnknown   = -1,
        GraphicsDeviceD3D11             =  2

//! Event types
enum GraphicsEventType
        GraphicsEventInitialize = 0,
        GraphicsEventShutdown   = 1,
        GraphicsEventBeforeReset= 2,
        GraphicsEventAfterReset = 3
typedef int (*FStaticInitInterface)(  );
typedef void (*FStaticSetGraphicsDevice)
        (void* device, GraphicsDeviceType deviceType,GraphicsEventType eventType);
typedef int(*FStaticRenderFrame2)(RenderFrameStruct* frameStruct);

FStaticInitInterface                            StaticInitInterface=nullptr;
FStaticSetGraphicsDevice                        StaticSetGraphicsDevice=nullptr;
FStaticRenderFrame2                                     StaticRenderFrame2=nullptr;

StaticInitInterface     =(FStaticInitInterface)GetProcAddress(dllHandle, "StaticInitInterface" );
StaticSetGraphicsDevice =(FStaticSetGraphicsDevice)GetProcAddress(dllHandle, "StaticSetGraphicsDevice" );

It’s advisable to check that the function pointers obtained are non-zero. If all the required pointers are present, the dll can be used. We start by calling

void* currentDevice = (current D3D11 device pointer);
StaticSetGraphicsDevice(currentDevice, CurrentApiType, GraphicsEventInitialize);

Now trueSKY is ready to render.

FrameStruct frameStruct;
(initialize frameStruct...)

A reference to the relevant functions can be found here.


Building TrueSkyPluginRenderer has a post-build script called CopyToTargetDir. Based on the built platform and config, this tries to deploy both the built dll and shaders to where they need to go. This is specified by the file truesky_setup.json, which goes in the current user’s home folder. For example:

        ,"simul_branches":[{"simul":"C:/Simul/4.1b/Simul","platforms":[{"platform":"Spectrum","dll_destination":"E:\\Code\\Exo One\\Exo_MasterPlayer_DebugsOn_XSXa\\Loose\\Data\\Plugins","shader_destination":"E:/Code/Exo One/Exo_MasterPlayer_DebugsOn_XSXa/Loose/D3D12"}]}]

The members “unreal_branches”, and “unity_branches” are specifically to deploy to an Unreal or Unity engine setup. The member “simul_branches” is more generic, and will deploy to the specified dll and shader destination for each platform.