/
Custom.MyRenderScript.cs
105 lines (96 loc) · 4.38 KB
/
Custom.MyRenderScript.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// This file is a part of MPDN Extensions.
// https://github.com/zachsaw/MPDN_Extensions
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3.0 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library.
using System;
using Mpdn.Extensions.Framework.RenderChain;
using Mpdn.Extensions.RenderScripts.Mpdn.ImageProcessor;
using Mpdn.Extensions.RenderScripts.Mpdn.Resizer;
using Mpdn.Extensions.RenderScripts.Shiandow.Chroma;
using Mpdn.Extensions.RenderScripts.Shiandow.Nedi;
namespace Mpdn.RenderScript
{
namespace MyOwnUniqueNameSpace // e.g. Replace with your user name
{
public class MyRenderChain : RenderChain
{
// Uncomment if you have MPC-HC's shader pack installed
// private string[] Deinterlace = { @"MPC-HC\Deinterlace (blend).hlsl" };
private string[] PostProcess = { @"SweetFX\LumaSharpen.hlsl" };
private string[] PreProcess = { @"SweetFX\Bloom.hlsl", @"SweetFX\LiftGammaGain.hlsl" };
private string[] ToGamma = { @"ConvertToGammaLight.hlsl" };
private string[] ToLinear = { @"ConvertToLinearLight.hlsl" };
protected override ITextureFilter CreateFilter(ITextureFilter input)
{
// Scale chroma first (this bypasses MPDN's chroma scaler)
input += new BicubicChroma { Preset = Presets.MitchellNetravali };
// Uncomment if you want to deinterlace with MPC-HC's deinterlace (blend) shader
/***
if (Renderer.InterlaceFlags.HasFlag(InterlaceFlags.IsInterlaced))
{
// Deinterlace using blend
input += new ImageProcessor { ShaderFileNames = Deinterlace };
}
***/
// Pre resize shaders, followed by NEDI image doubler
input += new ImageProcessor { ShaderFileNames = PreProcess };
// 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 ((Renderer.TargetSize > input.Size()).All) // See TextureSize for other comparer methods
{
input += new Nedi { AlwaysDoubleImage = true };
}
if ((Renderer.TargetSize < input.Size()).All)
{
// Use linear light for downscaling
input += new ImageProcessor { ShaderFileNames = ToLinear }
+ new Resizer { ResizerOption = ResizerOption.TargetSize100Percent }
+ new ImageProcessor { ShaderFileNames = ToGamma };
}
else
{
// Otherwise, scale with gamma light
input += new Resizer { ResizerOption = ResizerOption.TargetSize100Percent };
}
if (Renderer.VideoSize.Width < 1920)
{
// Sharpen only if video isn't full HD
input += new ImageProcessor { ShaderFileNames = PostProcess };
}
return input;
}
}
public class MyRenderScript : RenderChainUi<MyRenderChain>
{
public override string Category
{
get { return "Hidden"; } // Change to something else to make it visible in MPDN
}
public override ExtensionUiDescriptor Descriptor
{
get
{
return new ExtensionUiDescriptor
{
Name = "Custom Render Script Chain",
Description = "A customized render script chain (Advanced)",
Guid = new Guid("B0AD7BE7-A86D-4BE4-A750-4362FEF28A55"),
Copyright = "" // Optional field
};
}
}
}
}
}