added some more fixes

This commit is contained in:
Emmet
2025-03-15 20:17:25 -05:00
parent c5fe44a1d0
commit 51760b1b94
4 changed files with 279 additions and 7 deletions

View File

@ -1,18 +1,25 @@
#!/bin/sh
HOSTNAME=$(hostname)
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
STEAMAPPS_DIR="/home/deck/.steam/steam/steamapps";
if [ "$HOSTNAME" == "snowfire" ]; then
STEAMAPPS_DIR="/opt/Steam/steamapps";
fi
cp -f new/dinput8.dll $STEAMAPPS_DIR/common/MonsterHunterWilds/
cp -f new/dstorage.dll $STEAMAPPS_DIR/common/MonsterHunterWilds/
cp -f new/dstoragecore.dll $STEAMAPPS_DIR/common/MonsterHunterWilds/
cp -f new/re2_fw_config.txt $STEAMAPPS_DIR/common/MonsterHunterWilds/
cp -f original/dstorage.dll $STEAMAPPS_DIR/compatdata/2246340/pfx/drive_c/windows/system32
cp -f original/dstoragecore.dll $STEAMAPPS_DIR/compatdata/2246340/pfx/drive_c/windows/system32
mkdir -p $STEAMAPPS_DIR/common/MonsterHunterWilds
cp -f $SCRIPT_DIR/new/dinput8.dll $STEAMAPPS_DIR/common/MonsterHunterWilds
cp -f $SCRIPT_DIR/new/dstorage.dll $STEAMAPPS_DIR/common/MonsterHunterWilds
cp -f $SCRIPT_DIR/new/dstoragecore.dll $STEAMAPPS_DIR/common/MonsterHunterWilds
cp -f $SCRIPT_DIR/new/re2_fw_config.txt $STEAMAPPS_DIR/common/MonsterHunterWilds
mkdir -p $STEAMAPPS_DIR/compatdata/2246340/pfx/drive_c/windows/system32
cp -f $SCRIPT_DIR/original/dstorage.dll $STEAMAPPS_DIR/compatdata/2246340/pfx/drive_c/windows/system32
cp -f $SCRIPT_DIR/original/dstoragecore.dll $STEAMAPPS_DIR/compatdata/2246340/pfx/drive_c/windows/system32
mkdir -p $STEAMAPPS_DIR/common/MonsterHunterWilds/reframework/autorun
cp -f $SCRIPT_DIR/reframework/autorun/mhwilds_disable_postprocessing.lua $STEAMAPPS_DIR/common/MonsterHunterWilds/reframework/autorun
mkdir -p $STEAMAPPS_DIR/common/MonsterHunterWilds/reframework/autorun/utility
cp -f $SCRIPT_DIR/reframework/autorun/utility/Statics.lua $STEAMAPPS_DIR/common/MonsterHunterWilds/reframework/autorun/utility
echo "Use the following for the launch options:"
echo "_GL_SHADER_DISK_CACHE_SKIP_CLEANUP=1 MESA_GLSL_CACHE_MAX_SIZE=4GB PROTON_ENABLE_NVAPI=1 WINEDLLOVERRIDES=\"dstorage,dstoragecore=n,b\" gamemoderun \%command"
echo "_GL_SHADER_DISK_CACHE_SKIP_CLEANUP=1 MESA_GLSL_CACHE_MAX_SIZE=4GB PROTON_ENABLE_NVAPI=1 WINEDLLOVERRIDES=\"dstorage,dstoragecore=n,b\" gamemoderun %command"

View File

@ -0,0 +1,7 @@
[Desktop Entry]
Name=Monster Hunter Wilds Optimization (Steam Deck)
Comment=Install optimization files for MH Wilds on Steam Deck
Exec=/home/deck/Projects/mhwilds-optimization/install.sh
Icon=
Terminal=false
Type=Application

View File

@ -0,0 +1,198 @@
--v1.1.3
local statics = require("utility/Statics")
local TAAStrength = statics.generate("via.render.ToneMapping.TemporalAA", true)
local localExposureType = statics.generate("via.render.ToneMapping.LocalExposureType", true)
local lensDistortionSetting = statics.generate("via.render.RenderConfig.LensDistortionSetting", true)
--Default settings
local settings =
{
TAA = false,
jitter = false,
LDRPostProcessEnable = true,
colorCorrect = true,
lensDistortionEnable = false,
localExposure = false,
localExposureBlurredLuminance = true,
customContrastEnable = false,
filmGrain = true,
lensFlare = true,
godRay = true,
fog = true,
volumetricFog = true,
customContrast = 1.0
}
local apply = false
local save = false
local changed = false
local initialized = false
--Singleton and manager types
local cameraManager, cameraManagerType, graphicsManager, graphicsManagerType
--gameobject, component, and type definitions
local camera, cameraGameObject, LDRPostProcess, colorCorrectComponent, tonemapping, tonemappingType, graphicsSetting
--Saves settings to json
local function SaveSettings()
json.dump_file("mhwi_remove_postprocessing.json", settings)
end
--Loads settings from json and puts into settings table
local function LoadSettings()
local loadedTable = json.load_file("mhwi_remove_postprocessing.json")
if loadedTable ~= nil then
for key, val in pairs(loadedTable) do
settings[key] = loadedTable[key]
end
end
end
--Get component from gameobject
local function get_component(game_object, type_name)
local t = sdk.typeof(type_name)
if t == nil then
return nil
end
return game_object:call("getComponent(System.Type)", t)
end
--Apply settings
local function ApplySettings()
if initialized == false then log.info("[DISABLE POST PROCESSING] Not initialized, not applying settings") return end
log.info("[DISABLE POST PROCESSING] Applying settings")
--Set tonemapping and LDRPostProcessing
tonemapping:call("setTemporalAA", settings.TAA and TAAStrength.Strong or TAAStrength.Disable)
tonemapping:call("set_EchoEnabled", settings.jitter)
tonemapping:call("set_EnableLocalExposure", settings.localExposure)
tonemapping:call("setLocalExposureType", settings.localExposureBlurredLuminance and localExposureType.BlurredLuminance or localExposureType.Legacy)
--Set contast values depending on customContrastEnable
if settings.customContrastEnable == true then
tonemapping:call("set_Contrast", settings.customContrast)
elseif settings.colorCorrect == false then
tonemapping:call("set_Contrast", 1.0)
else
tonemapping:call("set_Contrast", 0.3)
end
--Set graphics setting
graphicsSetting:call("set_Fog_Enable", settings.fog)
graphicsSetting:call("set_VolumetricFogControl_Enable", settings.volumetricFog)
graphicsSetting:call("set_FilmGrain_Enable", settings.filmGrain)
graphicsSetting:call("set_LensFlare_Enable", settings.lensFlare)
graphicsSetting:call("set_GodRay_Enable", settings.godRay)
graphicsSetting:call("set_LensDistortionSetting", settings.lensDistortionEnable and lensDistortionSetting.ON or lensDistortionSetting.OFF)
if apply == true then graphicsManager:call("setGraphicsSetting", graphicsSetting) end
end
--Initialize by getting singletons, types, objects, then create hooks
local function Initialize()
log.info("[DISABLE POST PROCESSING] Trying to initialize...")
--Get singletons managers
cameraManager = sdk.get_managed_singleton("app.CameraManager")
if cameraManager == nil then return end
graphicsManager = sdk.get_managed_singleton("app.GraphicsManager")
if graphicsManager == nil then return end
log.info("[DISABLE POST PROCESSING] Singleton managers get successful")
--Get types
cameraManagerType = sdk.find_type_definition("app.CameraManager")
graphicsManagerType = sdk.find_type_definition("app.GraphicsManager")
log.info("[DISABLE POST PROCESSING] Singleton managers type definition get successful")
--Get gameobjects, components, and type definitions
camera = cameraManager:call("get_PrimaryCamera")
cameraGameObject = camera:call("get_GameObject")
LDRPostProcess = get_component(cameraGameObject, "via.render.LDRPostProcess")
colorCorrectComponent = LDRPostProcess:call("get_ColorCorrect")
tonemapping = get_component(cameraGameObject, "via.render.ToneMapping")
tonemappingType = sdk.find_type_definition("via.render.ToneMapping")
graphicsSetting = graphicsManager:call("get_NowGraphicsSetting")
log.info("[DISABLE POST PROCESSING] Component get successful")
--Create hooks and register callback
sdk.hook(cameraManagerType:get_method("onSceneLoadFadeIn"), function() end, function() ApplySettings() end)
sdk.hook(tonemappingType:get_method("clearHistogram"), function() end, function() tonemapping:call("set_EnableLocalExposure", settings.localExposure) end)
re.on_application_entry("LockScene", function() colorCorrectComponent:call("set_Enabled", settings.colorCorrect) end)
log.info("[DISABLE POST PROCESSING] Hook and callback creation successful")
--Apply settings after initialization
initialized = true
ApplySettings()
log.info("[DISABLE POST PROCESSING] Initialization successful")
end
--Load settings at the start and keep trying to initialize until all singleton managers get
LoadSettings()
re.on_frame(function() if initialized == false then Initialize() end end)
--Script generated UI
re.on_draw_ui(function()
if imgui.tree_node("Post Processing Settings") then
changed = false
--Settings menu
changed, settings.TAA = imgui.checkbox("TAA enabled", settings.TAA)
if changed == true then ApplySettings() end
changed, settings.jitter = imgui.checkbox("TAA jitter enabled", settings.jitter)
if changed == true then ApplySettings() end
imgui.new_line()
changed, settings.colorCorrect = imgui.checkbox("Color correction", settings.colorCorrect)
if changed == true then ApplySettings() end
changed, settings.localExposure = imgui.checkbox("Local exposure enabled", settings.localExposure)
if changed == true then ApplySettings() end
imgui.text(" ") imgui.same_line()
changed, settings.localExposureBlurredLuminance = imgui.checkbox("Use blurred luminance (sharpens)", settings.localExposureBlurredLuminance)
if changed == true then ApplySettings() end
changed, settings.customContrastEnable = imgui.checkbox("Custom contrast enabled", settings.customContrastEnable)
if changed == true then ApplySettings() end
changed, settings.customContrast = imgui.drag_float("Contrast", settings.customContrast, 0.01, 0.01, 5.0)
if changed == true then ApplySettings() end
imgui.new_line()
imgui.text("Graphics Settings")
changed, settings.lensDistortionEnable = imgui.checkbox("Lens distortion enabled", settings.lensDistortionEnable)
if changed == true then ApplySettings() end
changed, settings.fog = imgui.checkbox("Fog enabled", settings.fog)
if changed == true then ApplySettings() end
changed, settings.volumetricFog = imgui.checkbox("Volumetric fog enabled", settings.volumetricFog)
if changed == true then ApplySettings() end
changed, settings.filmGrain = imgui.checkbox("Film grain enabled", settings.filmGrain)
if changed == true then ApplySettings() end
changed, settings.lensFlare = imgui.checkbox("Lens flare enabled", settings.lensFlare)
if changed == true then ApplySettings() end
changed, settings.godRay = imgui.checkbox("Godray enabled", settings.godRay)
if changed == true then ApplySettings() end
imgui.spacing()
--Apply graphics settings when clicking on apply box
changed, apply = imgui.checkbox("Apply graphics settings", apply)
if apply == true then
ApplySettings()
apply = false
end
imgui.text("WARNING: applying graphics settings will set")
imgui.text("ambient lighting to high due to a bug in the game")
imgui.text("until returning to title or restarting the game")
imgui.new_line()
--Save settings when clicking on save box
changed, save = imgui.checkbox("Save settings", save)
if save == true then
SaveSettings()
save = false
end
imgui.new_line()
imgui.tree_pop()
end
end)

View File

@ -0,0 +1,60 @@
local Statics = {}
function Statics.generate(typename, double_ended)
local double_ended = double_ended or false
local t = sdk.find_type_definition(typename)
if not t then return {} end
local fields = t:get_fields()
local enum = {}
for i, field in ipairs(fields) do
if field:is_static() then
local name = field:get_name()
local raw_value = field:get_data(nil)
log.info(name .. " = " .. tostring(raw_value))
enum[name] = raw_value
if double_ended then
enum[raw_value] = name
end
end
end
return enum
end
function Statics.generate_global(typename)
-- split the . in the string so we get separate tables for each
-- lua has no built in split function
local parts = {}
for part in typename:gmatch("[^%.]+") do
table.insert(parts, part)
end
local global = _G
for i, part in ipairs(parts) do
if not global[part] then
global[part] = {}
end
global = global[part]
end
if global ~= _G then
local static_class = Statics.generate(typename)
for k, v in pairs(static_class) do
global[k] = v
global[v] = k
end
end
return global
end
return Statics