-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathPatches.cs
281 lines (249 loc) · 12.7 KB
/
Patches.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
using Harmony12;
using NovaEnv;
using Pathea;
using Pathea.WeatherNs;
using System;
using System.Collections.Generic;
using System.ComponentModel.Design.Serialization;
using System.Linq;
using System.Reflection;
using System.Security.Policy;
using System.Text;
using UnityEngine;
using UnityEngine.PostProcessing;
namespace PostProcessing
{
static partial class Main
{
private static bool defaultPostProcessingSet = false;
private static VignetteModel.Settings defaultVignetteSettings;
private static BloomModel.Settings defaultBloomSettings;
private static EyeAdaptationModel.Settings defaultEyeAdaptSettings;
private static MotionBlurModel.Settings defaultMotionBlurSettings;
private static DepthOfFieldModel.Settings defaultDepthOfFieldSettings;
private static ColorGradingModel.Settings defaultColorGradingSettings;
private static AmbientOcclusionModel.Settings defaultAOSettings;
private static bool defaultAASet = false;
private static AntialiasingModel.Settings defaultAATaaSettings;
private static AntialiasingModel.Settings defaultAAFxaaSettings;
[HarmonyPatch(typeof(PostProcessingBehaviour), "OnEnable")]
static class PostProcessingBehaviour_OnEnable_Patch
{
static void Prefix(PostProcessingBehaviour __instance)
{
if(__instance.profile != null && !defaultPostProcessingSet)
{
defaultVignetteSettings = __instance.profile.vignette.settings;
defaultBloomSettings = __instance.profile.bloom.settings;
defaultEyeAdaptSettings = __instance.profile.eyeAdaptation.settings;
defaultMotionBlurSettings = __instance.profile.motionBlur.settings;
defaultDepthOfFieldSettings = __instance.profile.depthOfField.settings;
defaultColorGradingSettings = __instance.profile.colorGrading.settings;
defaultAOSettings = __instance.profile.ambientOcclusion.settings;
defaultPostProcessingSet = true;
}
}
}
[HarmonyPatch(typeof(PostProcessingBehaviour), "OnPreCull")]
static class PostProcessingBehaviour_OnPreCull_Patch
{
static void Postfix(ref VignetteComponent ___m_Vignette, ref BloomComponent ___m_Bloom, ref EyeAdaptationComponent ___m_EyeAdaptation, ref DepthOfFieldComponent ___m_DepthOfField, ref MotionBlurComponent ___m_MotionBlur, ref ColorGradingComponent ___m_ColorGrading, ref TaaComponent ___m_Taa, ref FxaaComponent ___m_Fxaa, ref AmbientOcclusionComponent ___m_AmbientOcclusion)
{
if (enabled && settings.customVignette)
{
VignetteModel.Settings vSettings = new VignetteModel.Settings
{
mode = VignetteModel.Mode.Classic,
intensity = settings.vignetteIntensity,
color = new Color(settings.vignetteColorRed, settings.vignetteColorGreen, settings.vignetteColorBlue, settings.vignetteColorAlpha),
center = new Vector2(settings.vignetteX,settings.vignetteY),
smoothness = settings.vignetteSmoothness,
roundness = settings.vignetteRoundness,
rounded = settings.vignetteRounded
};
___m_Vignette.model.settings = vSettings;
}
else
{
___m_Vignette.model.settings = defaultVignetteSettings;
}
if (enabled && settings.customBloom)
{
BloomModel.BloomSettings bbSettings = new BloomModel.BloomSettings
{
intensity = settings.bloomIntensity,
threshold = settings.bloomThreshold,
softKnee = settings.bloomSoftKnee,
radius = settings.bloomRadius,
antiFlicker = settings.bloomAntiFlicker
};
BloomModel.LensDirtSettings blSettings = new BloomModel.LensDirtSettings
{
texture = ___m_Bloom.model.settings.lensDirt.texture,
intensity = settings.bloomLensDirtIntensity
};
BloomModel.Settings bSettings = new BloomModel.Settings
{
bloom = bbSettings,
lensDirt = blSettings
};
___m_Bloom.model.settings = bSettings;
}
else
{
___m_Bloom.model.settings = defaultBloomSettings;
}
if (enabled && settings.customEyeAdapt)
{
EyeAdaptationModel.Settings eSettings = new EyeAdaptationModel.Settings
{
lowPercent = settings.eyeAdaptLowPercent,
highPercent = settings.eyeAdaptHighPercent,
minLuminance = settings.eyeAdaptMinLuminance,
maxLuminance = settings.eyeAdaptMaxLuminance,
keyValue = settings.eyeAdaptKeyValue,
dynamicKeyValue = settings.eyeAdaptDynamicKeyValue,
adaptationType = settings.eyeAdaptAdaptationFixed?EyeAdaptationModel.EyeAdaptationType.Fixed: EyeAdaptationModel.EyeAdaptationType.Progressive,
speedUp = settings.eyeAdaptSpeedUp,
speedDown = settings.eyeAdaptSpeedDown,
logMin = settings.eyeAdaptLogMin,
logMax = settings.eyeAdaptLogMax,
};
___m_EyeAdaptation.model.settings = eSettings;
}
else
{
___m_EyeAdaptation.model.settings = defaultEyeAdaptSettings;
}
if (enabled && settings.customMotionBlur)
{
MotionBlurModel.Settings mSettings = new MotionBlurModel.Settings
{
shutterAngle = settings.motionBlurShutterAngle,
sampleCount = settings.motionBlurSampleCount,
frameBlending = settings.motionBlurFrameBlending
};
___m_MotionBlur.model.settings = mSettings;
}
else
{
___m_MotionBlur.model.settings = defaultMotionBlurSettings;
}
if (enabled && settings.customDepthOfField)
{
DepthOfFieldModel.Settings dSettings = new DepthOfFieldModel.Settings
{
focusDistance = settings.depthOfFieldFocusDistance,
aperture = settings.depthOfFieldAperture,
focalLength = settings.depthOfFieldFocalLength,
useCameraFov = settings.depthOfFieldUseCameraFov,
kernelSize = (DepthOfFieldModel.KernelSize)settings.depthOfFieldKernelSize,
};
___m_DepthOfField.model.settings = dSettings;
___m_DepthOfField.model.enabled = true;
}
else
{
___m_DepthOfField.model.settings = defaultDepthOfFieldSettings;
___m_DepthOfField.model.enabled = false;
}
if (enabled && settings.customColorGrading)
{
ColorGradingModel.TonemappingSettings ctSettings = new ColorGradingModel.TonemappingSettings
{
tonemapper = (ColorGradingModel.Tonemapper)settings.colorGradingTonemapper,
neutralBlackIn = settings.colorGradingNeutralBlackIn,
neutralWhiteIn = settings.colorGradingNeutralWhiteIn,
neutralBlackOut = settings.colorGradingNeutralBlackOut,
neutralWhiteOut = settings.colorGradingNeutralWhiteOut,
neutralWhiteLevel = settings.colorGradingNeutralWhiteLevel,
neutralWhiteClip = settings.colorGradingNeutralWhiteClip
};
ColorGradingModel.BasicSettings cbSettings = new ColorGradingModel.BasicSettings
{
postExposure = settings.colorGradingPostExposure,
temperature = settings.colorGradingTemperature,
tint = settings.colorGradingTint,
hueShift = settings.colorGradingHueShift,
saturation = settings.colorGradingSaturation,
contrast = settings.colorGradingContrast
};
ColorGradingModel.Settings cSettings = new ColorGradingModel.Settings
{
tonemapping = ctSettings,
basic = cbSettings,
channelMixer = ___m_ColorGrading.model.settings.channelMixer,
colorWheels = ___m_ColorGrading.model.settings.colorWheels,
curves = ___m_ColorGrading.model.settings.curves
};
___m_ColorGrading.model.settings = cSettings;
}
else
{
___m_ColorGrading.model.settings = defaultColorGradingSettings;
}
if (enabled && settings.customAO)
{
AmbientOcclusionModel.Settings aSettings = new AmbientOcclusionModel.Settings
{
intensity = settings.AOIntensity,
radius = settings.AORadius,
sampleCount = (AmbientOcclusionModel.SampleCount)sampleCounts.Values.ToArray()[settings.AOSampleCount],
downsampling = settings.AODownsampling,
forceForwardCompatibility = settings.AOForceForwardCompatibility,
ambientOnly = settings.AOAmbientOnly,
highPrecision = settings.AOHighPrecision
};
___m_AmbientOcclusion.model.settings = aSettings;
}
else
{
___m_AmbientOcclusion.model.settings = defaultAOSettings;
}
/*
if(!defaultAASet)
{
defaultAATaaSettings = ___m_Taa.model.settings;
defaultAAFxaaSettings = ___m_Fxaa.model.settings;
defaultAASet = true;
}
if (enabled && settings.customAA)
{
AntialiasingModel.FxaaSettings afSettings = new AntialiasingModel.FxaaSettings
{
preset = (AntialiasingModel.FxaaPreset) settings.AAFxaaPreset
};
AntialiasingModel.TaaSettings atSettings = new AntialiasingModel.TaaSettings
{
jitterSpread = settings.AAJitterSpread,
sharpen = settings.AASharpen,
stationaryBlending = settings.AAStationaryBlending,
motionBlending = settings.AAMotionBlending
};
AntialiasingModel.Settings aSettings = new AntialiasingModel.Settings
{
//method = settings.AAMethodTaa?AntialiasingModel.Method.Taa: AntialiasingModel.Method.Fxaa,
method = ___m_Taa.model.settings.method,
fxaaSettings = afSettings,
taaSettings = atSettings
};
AntialiasingModel.Settings aSettings2 = new AntialiasingModel.Settings
{
//method = settings.AAMethodTaa?AntialiasingModel.Method.Taa: AntialiasingModel.Method.Fxaa,
method = ___m_Fxaa.model.settings.method,
fxaaSettings = afSettings,
taaSettings = atSettings
};
___m_Taa.model.settings = aSettings;
___m_Fxaa.model.settings = aSettings2;
}
else
{
___m_Taa.model.settings = defaultAATaaSettings;
___m_Fxaa.model.settings = defaultAAFxaaSettings;
}
*/
}
}
}
}