Skip to content

Scripted Render Chain

Zach Saw edited this page May 29, 2015 · 1 revision

One of the interesting feature of MPDN added in the version v2.25.17 is the possibility to create your own Render Script directly in the player using JavaScript.

All functions that the 'rs' script can access are available in the Clip and Host classes (see Mpdn.ScriptedRenderChain.ScriptHelpers.cs). 'Clip' is available via the 'input' object while 'Host' is 'host'. There's also a "Debug.Output" function that allows you to dump debug messages to the DbgView app.

References

input.FileName          // returns the full path and file name of the video file
input.FrameRateHz       // returns the fps of your video
input.SourceSize.Width  // returns video source width
host.ExePath            // returns the folder name of which MPDN's executable file resides 

Render Methods

Lut3DColorCorrection    
ImageProcessor    
Preset
Resizer    
BicubicChroma    
Deband    
Nedi    
NNedi3    
OclNNedi3    // OpenCL version of NNEDI3
SuperChromaRes    
SuperRes  

Example

This is a rewrite of the CustomRenderer using the Render Scripting

// Example render script

// Scale chroma first (this bypasses MPDN's chroma scaler)
BicubicChroma( Preset = Presets.MitchellNetravali )

// Apply some filtering pixel shaders
ImageProcessor( ShaderFileNames = ["SweetFX\\Bloom.hlsl", "SweetFX\\LiftGammaGain.hlsl"] )

// Use NEDI once only.
// Note: To use NEDI as many times as required to get the image past target size,
//       change the following *if* to *while*
if (input.NeedsUpscaling)
{
    Nedi( AlwaysDoubleImage = true )
}

if (input.NeedsDownscaling)
{
    // Use linear light for downscaling
    ImageProcessor( ShaderFileNames = ["ConvertToLinearLight.hlsl"] )
    Resizer( ResizerOption = ResizerOption.TargetSize100Percent )
    ImageProcessor( ShaderFileNames = ["ConvertToGammaLight.hlsl"] )
}

if (input.SourceSize.Width < 1920)
{
    // Sharpen only if video isn't full HD
    // Or if you have FineSharp installed, replace the following line with it
    ImageProcessor( ShaderFileNames = ["SweetFX\\LumaSharpen.hlsl"] )
}  
Clone this wiki locally