VR Toolbox: 360 Desktop

VR Toolbox: 360 Desktop

Not enough ratings
Writing Rendering Plugins
By MyDream
Everything to get you started writing your own plugins
   
Award
Favorite
Favorited
Unfavorite
Intro
VR Toolbox supports rendering plugins in the form of DLL files. The plugin SDK comes with VR Toolbox: navigate to the VR Toolbox directory and look for pluginSDK.

Some possible example plugins:
  • Render your hands in VR using a hands tracker.
  • Render dynamic backgrounds that react to live events (music, time of day, etc.)
  • Grids, lasers, custom objects

The included sample plugin is designed to get you started and renders a neon grid on the floor.
Details
Activating a Plugin

To activate a plugin, just drag and drop the DLL file onto VR Toolbox. Alternatively, use the standard "Open" button in the GUI.

Note that if your plugin requires additional files other than the DLL, you should design it considering:
  • the Init() function is called with the current directory set to the DLL directory.
  • every other plugin function is called with the current directory set to the VR Toolbox base directory.

Writing a Plugin

Plugins are 64-bit DLLs and you can use Visual Studio C++ 2015 to develop them. The sample plugin should be enough to give you guidance. Note that it requires the DirectX 11 SDK (June 2010, latest version) to compile.
State
The render callback is called after the scene is rendered, but before the controllers are rendered.

The scene color and depth render targets are bound. After your plugin returns, they must continue to be bound.

Some constant buffers are also bound for you to use if you wish. You should preserve the ones bound before slot 4:

#define MAX_LIGHTS 12 #define LIGHT_TYPE_SCREEN 0 #define LIGHT_TYPE_POINT 1 cbuffer cbPerFrame : register(b1) { matrix SkyboxRot; matrix SlowRot; matrix ActiveControllerTransform; float4 AmbientColor; float4 FogColor; uint flags; float time; float dT; float SlowRotAngle; int frame; int shaderDebug; float zFar; float zNear; float zK1; float zK2; }; cbuffer cbCamera : register(b4) { matrix Projection; matrix View; float4 EyePos; int eye; }; struct Light { float4 Position; float4 UV; float4 color; float intensity; float mipLevel; int lightType; int occIdx; }; struct Occluder { float3 Position; float RadiusInv; }; cbuffer cbl : register(b2) { Light Lights[MAX_LIGHTS]; Occluder Occ[MAX_LIGHTS]; int nLights; int nOcc; float SpotlightRadius; float SpotlightRadiusInv2; };
Debugging Your Plugin
You can debug and step through your plugin with Visual Studio. Follow these steps:

  1. Start VR Toolbox.
  2. Attach the Visual Studio debugger to VRToolbox.exe (Debug -> Attach To Process).
  3. Place breakpoints in your code, for example in the init function.
  4. Load the plugin .dll from VR Toolbox.

When attaching the debugger, make sure to select "Native Code" in the "Attach to" area in step 2.
1 Comments
Laserbeak43 15 Jul, 2019 @ 5:12am 
Thanks! Need to try this.