Skip to content

The Conditional Render Script

Shiandow edited this page Oct 8, 2015 · 32 revisions

What is the Conditional render script?

The Contidional render script allows you to let MPDN automatically choose a render script when certain conditions are met. Based on this, you can do things like create profiles based on frame rate / resolution etc. or even downscale in linear light with any scaler of your choice without having to use the Scripted Render Chain.

What is a conditional statement?

You use a conditional statement when you want to perform different actions for different decisions.

For example,
if NeedsUpscaling use Script Chain.

You can configure Script Chain by presseing the configure button.

It is just as simple to write one that takes effect when downscaling is required.

If NeedsDownscaling use Script Chain.

Within this downscale chain, you can add your ImageProcessor (ConvertToLinearLight.hlsl), Resizer (to 100% target) and ImageProcessor (ConvertToGammaLight.hlsl) scripts to do linear light scaling.

You can also use and or in the conditional statement. For example,

if Math.floor(FrameRateHz) == 23 and SourceSize.Width >= 1280 use NEDI

activates NEDI preset if the source clip has a frame rate of 23.0 - 23.99999Hz (which coincidentally matches 23.976Hz) and a width of 1280 pixels or more (i.e. HD materials).

This takes care of HD materials but what if we want to make MPDN automatically use NNEDI3 for lower resolutions?

That's easy. Just add another conditional to your [render chain](Script Chain) that goes

if Math.floor(FrameRateHz) == 23 and SourceSize.Width < 1280 use OpenCL NNEDI3.

Your render chain would look something like this:
Conditionally choose between NEDI / NNEDI3

You can even use conditionals for just the scaling part of the render chain. For example, you could have a chain that goes SuperChromaRes -> Deband -> Conditionals -> ImageProcessor.
Mixing conditionals with standard scripts

These are the supported keywords and their types,

    FileName         : string   // Video file name with full path
    Interlaced       : bool     // Is the video interlaced?
    NeedsUpscaling   : bool     // Does it need upscaling?
    NeedsDownscaling : bool     // Does it need downscaling?
    TargetSize       : Size     // Target window size (resolution)
    SourceSize       : Size     // Video resolution
    LumaSize         : Size     // Luma resolution
    ChromaSize       : Size     // Chroma resolution
    AspectRatio      : Point    // Aspect ratio of the video
    FrameRateHz      : double   // Frame rate in Hz
    SourceBitDepth   : int      // Bit depth of your video
    ScalingFactorX   : double   // Horizontal scaling factor
    ScalingFactorY   : double   // Vertical scaling factor
    ScalingFactor    : double   // Geometric mean of horizontal and vertical scaling factors
    
    where,
        Size { Width, Height }
        Point { X, Y }
Clone this wiki locally