-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmodOptions.lua
More file actions
385 lines (362 loc) · 14.4 KB
/
Copy pathmodOptions.lua
File metadata and controls
385 lines (362 loc) · 14.4 KB
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
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
local nativeSettingsConfig = {
tabName = '/AdvancedPathTracing',
tabLabel = 'Advanced Path Tracing',
categories = {
{
name = 'global_settings',
label = 'Path Tracing Settings'
},
{
name = 'photo_mode',
label = 'Screenshots Override'
},
{
name = 'helpers',
label = 'Helpers'
}
},
options = {
{
index = 'ptPreset',
path = '/AdvancedPathTracing/global_settings',
label = 'Global Preset',
description = "Global preset Path Tracing quality.\n\nVanilla is the game's default mode\n\nVery Low is the lowest quality worth enabling PT, but lower is possible.\n\nLow increases very low quality to not be as noisy\n\nMedium uses ReSTIR DI/GI, similar quality to Vanilla, but up to 8% performance increase\n\nHigh further increase quality over medium\n\nUltra enables global light and changes to ReSTIR DI + ReGIR GI which can look better but with high cost\n\nPsycho flatlines your GPU. Changes back to ReSTIR DI to have way less noise and to be more like offline rendering. Results vary",
range = {
[1] = "Vanilla",
[2] = "Very Low",
[3] = "Low",
[4] = "Medium",
[5] = "High",
[6] = "Ultra",
[7] = "Psycho",
[8] = "Custom"
},
stateCallback = function(state)
setPTPreset(state)
end,
typeFunction = 'addSelectorString',
},
{
index = 'ptMode',
path = '/AdvancedPathTracing/global_settings',
label = 'Mode',
description = "Changes Path Tracing mode\n\nReSTIR DI - The older PT from update 2.0, used with DI and naive GI. Enables control of rays per pixel and bounces per ray (also for Photo Mode screenshots).\n\nReSTIR DI/GI - Reservoir Spatio Temporal Importance Resampling for Global Illumination, is a screen space light sampling used for illuminating secondary surfaces. This is the vanilla mode.\n\nReSTIR DI + ReGIR GI - Uses Reservoir-based Grid Importance Sampling, for a world space light sampling on top of ReSTIR, but only for GI\n\n ReGIR DI/GI - Uses ReGIR for both DI and GI",
range = {
[1] = "ReSTIR DI",
[2] = "ReSTIR DI/GI",
[3] = "ReSTIR DI + ReGIR GI",
[4] = "ReGIR DI/GI"
},
stateCallback = function(state)
setPTMode(state)
end,
typeFunction = 'addSelectorString',
},
{
index = 'ptQuality',
path = '/AdvancedPathTracing/global_settings',
label = 'Quality',
description = "Adjust internal path tracing quality settings.\n\nVanilla: Default quality\n\nPerformance: Faster but noisier\n\nBalanced: Improves over Vanilla by loosing up to 3%\n\nQuality: Heavier but less noise and higher quality.\n\nPsycho: Flatline your GPU",
range = {
[1] = "Vanilla",
[2] = "Performance",
[3] = "Balanced",
[4] = "Quality",
[5] = "Psycho"
},
stateCallback = function(state)
setPTQuality(state)
end,
typeFunction = 'addSelectorString',
},
{
index = 'rtxdiHistory',
path = '/AdvancedPathTracing/global_settings',
label = 'Light Frame Accumulation',
description = "Defines ReSTIR DI light reservoir frame accumulation\n\nVanilla: Default value\n\nDisabled: No accumulation. Increase the performance by up to 8% with minimal visual loss, but some surfaces may exhibit flickering noise\n\nOptimized: Not as high as vanilla, but more responsive with some accumulation to fix occasional noise flickering",
range = {
[1] = "Vanilla",
[2] = "Disabled",
[3] = "Optimized"
},
stateCallback = function(state)
setRTXDIHistory(state)
end,
typeFunction = 'addSelectorString',
},
{
index = 'rayNumber',
path = '/AdvancedPathTracing/global_settings',
label = 'Rays Per Pixel',
description = "Number of rays per pixel. Only works when using ReSTIR DI mode.",
range = {
min = 1,
max = 8,
step = 1
},
stateCallback = function(state)
setRayNumber(state, false)
end,
typeFunction = 'addRangeInt',
},
{
index = 'rayBounce',
path = '/AdvancedPathTracing/global_settings',
label = 'Bounces Per Ray',
description = "Number of bounces per ray. Only works when using ReSTIR DI mode.",
range = {
min = 0,
max = 8,
step = 1
},
stateCallback = function(state)
setRayBounce(state, false)
end,
typeFunction = 'addRangeInt',
},
{
index = 'sharc',
path = '/AdvancedPathTracing/global_settings',
label = 'NVIDIA SHARC',
description = "Enables NVIDIA's Spatial Hash Radiance Cache (SHARC) for light bounces. Helps stabilize light bounces in dark areas and during fast camera movement. Scales with PT quality with performance ranging from 1.5% (Vanilla) to 10% (Psycho). Disabled when using ReGIR. Performance and image quality varies",
range = nil,
stateCallback = function(state)
setSharc(state)
end,
typeFunction = 'addSwitch',
},
{
index = 'ptTweaks',
path = '/AdvancedPathTracing/global_settings',
label = 'Tweaks',
description = "Adds missing PT Reflections through Screen Space Reflections\n\nReduce noise on some scenarios. Some scenes may appear a little darker\n\nUse PDF (Probability Density Function) for minor performance boost\n\nMinor reflections improvement on transparent surfaces\n\nImproved RT distance\n\nMinor GI/DI optimizations",
range = nil,
stateCallback = function(state)
setPTTweaks(state)
end,
typeFunction = 'addSwitch',
},
{
index = 'globalLight',
path = '/AdvancedPathTracing/global_settings',
label = 'Enhanced Global Light',
description = "Enables enhanced PT global light for sun/moon, with better radiance\n\nIt mostly affects the sunlight and shadows for the foliage animation (wind). However, the shadows may appear duplicated/misaligned.",
range = nil,
stateCallback = function(state)
setGlobalLight(state)
end,
typeFunction = 'addSwitch',
},
{
index = 'dlssdParticles',
path = '/AdvancedPathTracing/global_settings',
label = 'Ray Reconstruction Particles',
description = "Use Ray Reconstruction on particles, when it's not raining and outdoors",
range = nil,
stateCallback = function(state)
setDLSSDParticlesControl(state)
end,
typeFunction = 'addSwitch',
},
{
index = 'selfReflection',
path = '/AdvancedPathTracing/global_settings',
label = 'Self Reflection',
description = "Enables self-reflaction of V without showing the head (internal game limitation). Also works with normal Ray Tracing",
range = nil,
stateCallback = function(state)
setSelfReflection(state)
end,
typeFunction = 'addSwitch',
},
{
index = 'rayNumberPm',
path = '/AdvancedPathTracing/photo_mode',
label = 'Rays Per Pixel',
description = "Number of rays per pixel (ReSTIR DI) for the Photo Mode screenshots",
range = {
min = 1,
max = 8,
step = 1
},
stateCallback = function(state)
setRayNumber(state, true)
end,
typeFunction = 'addRangeInt',
},
{
index = 'rayBouncePm',
path = '/AdvancedPathTracing/photo_mode',
label = 'Bounces Per Ray',
description = "Number of bounces per ray (ReSTIR DI) for the Photo Mode screenshots",
range = {
min = 0,
max = 8,
step = 1
},
stateCallback = function(state)
setRayBounce(state, true)
end,
typeFunction = 'addRangeInt',
},
{
index = 'nrdControl',
path = '/AdvancedPathTracing/helpers',
label = 'NRD Disable Helper',
description = "Disables NRD denoisier from time to time to mitigate Ray Reconstruction (RR) loss of performance over time. Only works with RR on",
range = nil,
stateCallback = function(state)
setNRDControl(state)
end,
typeFunction = 'addSwitch',
},
{
index = 'refreshGame',
path = '/AdvancedPathTracing/helpers',
label = 'Auto Refresh Game',
description = "Enables auto refresh game, by rapidly pause/unpause the game, on closing the menu or loading saves to mitigate loss of performance. Refresh only happens after exiting menus, loading saves or teleports",
range = nil,
stateCallback = function(state)
setRefreshControl(state)
end,
typeFunction = 'addSwitch',
},
{
index = 'refreshInterval',
path = '/AdvancedPathTracing/helpers',
label = 'Refresh Game Interval (min)',
description = "The amount of time in minutes to wait for the next refresh. Zero will refresh every time",
range = {
min = 0,
max = 60,
step = 1
},
stateCallback = function(state)
setRefreshTime(state)
end,
typeFunction = 'addRangeInt',
},
{
index = 'refreshGameNow',
path = '/AdvancedPathTracing/helpers',
label = '',
description = 'Ignore the interval and refresh the game after exiting the menu. Also refreshes DLSS Ray Reconstruction',
range = nil,
buttonText = 'Refresh',
textSize = 45,
stateCallback = function(state)
setRefreshNow()
end,
typeFunction = 'addButton',
}
}
}
local ModOptionsShared = {}
local ModOptions = {
loaded = false,
nativeSettings = nil,
nativeOptions = {}
}
--[[
ModOptions.__index = ModOptions
function ModOptions.new()
local self = setmetatable({}, ModOptions)
self.loaded = false
self.options = {}
return self
end
--]]
function ModOptionsShared.isLoaded()
return ModOptions.loaded
end
function ModOptionsShared.refresh()
if ModOptions.loaded then
ModOptions.nativeSettings.refresh()
end
end
function ModOptionsShared.getNativeSettings(index)
if ModOptions.loaded and ModOptions.nativeOptions[index] then
return ModOptions.nativeOptions[index].settings
end
end
function ModOptionsShared.callAction(index, value)
if ModOptions.loaded and ModOptions.nativeOptions[index] then
ModOptions.nativeOptions[index].settings.stateCallback(value)
end
end
function ModOptionsShared.setOption(index, value)
if ModOptions.loaded and ModOptions.nativeOptions[index] then
ModOptions.nativeSettings.setOption(ModOptions.nativeOptions[index].option, value)
end
end
---Loads NativeSettings menus
---@param settings table --The settings values
---@param defaults table --The default settings values
---@return boolean -- Wheter or not NativeSettings were load
function ModOptionsShared.loadNativeSettings(settings, defaults)
local nativeSettings = GetMod("nativeSettings")
--Return if NativeSettings not found
if not nativeSettings then
ModOptions.loaded = false
return false
end
if not nativeSettings.pathExists(nativeSettingsConfig.tabName) then
nativeSettings.addTab(nativeSettingsConfig.tabName, nativeSettingsConfig.tabLabel)
for _, c in pairs(nativeSettingsConfig.categories) do
nativeSettings.addSubcategory(nativeSettingsConfig.tabName .. '/' .. c.name, c.label)
end
end
local nativeOption = nil
--Only loop with indexed values with ipairs
for _, v in ipairs(nativeSettingsConfig.options) do
if v.range then
if v.range['min'] ~= nil then
nativeOption = nativeSettings[v.typeFunction](
v.path,
v.label,
v.description,
v.range.min, v.range.max, v.range.step,
settings[v.index],
defaults[v.index],
v.stateCallback
)
else
nativeOption = nativeSettings[v.typeFunction](
v.path,
v.label,
v.description,
v.range,
settings[v.index],
defaults[v.index],
v.stateCallback
)
end
elseif v.typeFunction == 'addButton' then
nativeOption = nativeSettings[v.typeFunction](
v.path,
v.label,
v.description,
v.buttonText,
v.textSize,
v.stateCallback
)
else
nativeOption = nativeSettings[v.typeFunction](
v.path,
v.label,
v.description,
settings[v.index],
defaults[v.index],
v.stateCallback
)
end
ModOptions.nativeOptions[v.index] = {
settings = v,
option = nativeOption
}
end
ModOptions.nativeSettings = nativeSettings
ModOptions.loaded = true
return true
end
return ModOptionsShared