Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 101 additions & 14 deletions ext/Client/EmitterMeshPatchDatatable.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ return {
-- XP2_Skybar
['fx/dlc/xp2/ambient/levelspecific/mp_skybar/emitters/em_dlc_amb_mpskybar_bgsmog_smoke'] = true
},
-- Tried Messing with their enlightenType
-- rigidMeshs = {
-- -- MP_011
-- ['levels/mp_011/objects/mp011_backdrop_01_mesh'] = true,
-- ['levels/mp_011/objects/mp011_backdropesplanade_01_mesh'] = true,
-- ['levels/mp_011/objects/mp011_backdropesplanade_02_mesh'] = true,
-- ['levels/mp_011/water/meshes/mp_011_watersurface01_mesh'] = true,
-- },
meshes = {
-- MP_Subway
['levels/mp_subway/objects/backdrops/mp15_smokepillar_01_mesh'] = true,
Expand All @@ -45,10 +53,10 @@ return {
['levels/mp_007/props/mp007_waterwash_02_mesh'] = true,

-- MP_011
['levels/mp_011/objects/mp011_backdrop_01_mesh'] = true,
['levels/mp_011/objects/mp011_backdropesplanade_01_mesh'] = true,
['levels/mp_011/objects/mp011_backdropesplanade_02_mesh'] = true,
['levels/mp_011/water/meshes/mp_011_watersurface01_mesh'] = true,
-- ['levels/mp_011/objects/mp011_backdrop_01_mesh'] = true,
-- ['levels/mp_011/objects/mp011_backdropesplanade_01_mesh'] = true,
-- ['levels/mp_011/objects/mp011_backdropesplanade_02_mesh'] = true,
-- ['levels/mp_011/water/meshes/mp_011_watersurface01_mesh'] = true,

-- MP_012
['levels/mp_012/terrain/mp012_matte_4parts_1_mesh'] = true,
Expand All @@ -63,27 +71,28 @@ return {
['levels/mp_013/props/mp013_cloudlayer_mesh'] = true,

-- MP_017
['levels/mp_017/terrain/mp_017_waves_01_mesh'] = true,
-- ['levels/mp_017/terrain/mp_017_waves_01_mesh'] = true,

-- MP_018
['levels/mp_018/terrain/mp018_mattepainting_chunk01_mesh'] = true,
['levels/mp_018/terrain/mp018_mattepainting_chunk02_mesh'] = true,
['levels/mp_018/terrain/mp018_mattepainting_chunk03_mesh'] = true,
['levels/mp_018/terrain/mp018_wave_01_mesh'] = true,
-- ['levels/mp_018/terrain/mp018_wave_01_mesh'] = true,

-- XP1_001
['levels/xp1_001/objects/mattepainting_01_mesh'] = true,
['levels/xp1_001/objects/mattepainting_02_mesh'] = true,
['levels/xp1_001/objects/mattepainting_03_mesh'] = true,
['levels/xp1_001/objects/mattepainting_04_mesh'] = true,


-- XP1_002
['levels/xp1_002/objects/xp1_002__wave_01_mesh'] = true,
-- ['levels/xp1_002/objects/xp1_002__wave_01_mesh'] = true,

-- XP1_004
['xp_raw/surrounding/smokepillars/smokepillar_01_mesh'] = true,
['levels/xp1_004/props/wake_wave_02/wake_wave_02_mesh'] = true,
['levels/xp1_004/props/wave_01/wave_01_mesh'] = true,
-- ['levels/xp1_004/props/wake_wave_02/wake_wave_02_mesh'] = true,
-- ['levels/xp1_004/props/wave_01/wave_01_mesh'] = true,

-- XP2_Palace
['xp2/objects/godrays_01/godrays_01_mesh'] = true,
Expand All @@ -100,22 +109,37 @@ return {
['levels/xp3_desert/props/xp3_bandar_backdropmatte_01_mesh'] = true,

-- XP4_Quake
['levels/sp_valley/terrain/cloud_moving_mesh'] = true
['levels/sp_valley/terrain/cloud_moving_mesh'] = true,
-- ['levels/xp4_earthquake/objects/waterpuddle_01_copy_mesh'] = true,
-- ['levels/xp4_earthquake/objects/watersplash_02_mesh'] = true,
-- ['levels/xp4_earthquake/objects/lakeedge/pondedge_01_mesh'] = true,
-- ['levels/xp4_earthquake/objects/lakeedge/pondedge_02_mesh'] = true,
-- ['levels/xp4_earthquake/objects/backdrop/backdropcity_01_mesh'] = true,
-- ['levels/xp4_earthquake/terrain/earthquakems_01_mesh'] = true,
-- ['levels/xp4_earthquake/objects/earthquakepiece_big_Mesh'] = true,
},
variations = {
-- MP_012
['levels/mp_012/objects/smokestacks/smokestack_01_02'] = true,

-- MP_018
['levels/xp1_001/objects/wave_01_xp001'] = true,
-- XP1_001 -- this was removing the waves for karkand
-- ['levels/xp1_001/objects/wave_01_xp001'] = true,

-- XP2_Skybar
['levels/xp2_skybar/objects/smokepillar_bg/smokepillar_01_xp2'] = true,

-- XP3_Valley
['levels/xp3_valley/objects/mountainsidecloud_01_valley'] = true,
['levels/xp3_valley/objects/mountainsidecloud_02_valley'] = true,
['levels/xp3_valley/objects/mountainsidecloud_04_vvalley'] = true
['levels/xp3_valley/objects/mountainsidecloud_04_vvalley'] = true,

-- XP4_Quake
-- ['levels/xp4_earthquake/objectvariations/watershadow_mp013_02_variation'] = true,
-- ['levels/xp4_earthquake/objects/backdrop/skybarbackdropcombined_big_earthquake'] = true,
-- ['levels/xp4_earthquake/objects/waterpuddle_01_copy_nodrop2'] = true,
-- ['levels/xp4_earthquake/objects/waterpuddle_01_nodrip'] = true,
-- ['levels/xp4_earthquake/objects/backdrop/skyscraper3_variation'] = true

},
effects = {
-- MP_007
Expand Down Expand Up @@ -145,12 +169,75 @@ return {
-- XP5_002
['fx/ambient/levelspecific/sp_03/fx_amb_sp03_littlewindow_godrays'] = true
},

envmaps = {
['levels/mp_subway/lighting/ve_mp_subway_city_01'] = true,
['levels/mp_011/lighting/ve_mp_011_day01'] = true,
['levels/xp5_001/lighting/ve_xp5_001_01'] = true,
['levels/xp5_002/lighting/ve_xp5_002_01'] = true,
['levels/xp5_003/lighting/ve_xp5_003_01'] = true,
['levels/xp5_004/lighting/ve_xp5_004_02'] = true
}
},

-- The Shaders related to this meshes are lazy loaded. Once loaded invalidating them doesn't seem to be working.
waterAssets = {
-- XP1_001
['levels/xp1_001/xpack1_001_terrain.water.mesh'] = true,

-- XP1_002
['levels/xp1_002/terrain_2/gulfterrain_03.water.mesh'] = true
},

waters = {
-- ['Levels/XP1_001/XP1_001'] = true,
-- ['Levels/XP1_002/XP1_002'] = true,
-- ['Levels/XP1_003/XP1_003'] = true,
},

textures = {
['levels/xp4_earthquake/objects/lakeedge/lakeenv'] = true,
},


-- Messing with the shaders doesn't seem to be doing anything visually...
-- waterShaders = {
-- -- XP1_001 Karkand
-- ['levels/xp1_001/shaders/water'] = true,

-- -- XP1_002 Gulf of Oman
-- ['levels/xp1_002/shaders/water'] = true,

-- -- XP1_003 Sharqi
-- ['levels/xp1_003/shaders/water'] = true

-- }
}

-- Partition CAEA8375-0AFC-4367-D5AD-032158C1B13F
-- LakeData A7C3B316-7939-2A5C-332D-E66FE2EFC1CE
-- $::VisualVectorShapeData
-- $::VectorShapeData
-- $::BaseShapeData
-- $::GameObjectData
-- $::GameDataContainer
-- $::DataContainer
-- IsEventConnectionTarget 3
-- IsPropertyConnectionTarget 3
-- IndexInBlueprint 65535
-- Points::array
-- member(0)::Vec3
-- x -28.61029624938965
-- y 146.45040893554688
-- z -837.198974609375
-- member(1)::Vec3
-- x -146.542236328125
-- y 146.45040893554688
-- z -233.81307983398438
-- Normals *nullArray*
-- Tension 0.0
-- IsClosed True
-- AllowRoll False
-- ErrorTolerance 0.75
-- Shader3d Levels/XP1_001/Shaders/Water/26B58BD9-8058-6A60-2013-D0E27942CFF3
-- DrawOrderIndex 100
-- TessellationTriangleSize 4.0
143 changes: 131 additions & 12 deletions ext/Client/Patches.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,65 @@ Patches = class('Patches')
local m_PatchDatatable = require('EmitterMeshPatchDatatable')

---@type VEMLogger
local m_VEMLogger = VEMLogger("Patches", false)
local m_VEMLogger = VEMLogger("Patches", true)

local XP1_001 = {
MainPartitionGuid = Guid("FAF35F00-5263-40A3-AB4D-67384BC2AD6D")
}
local XP1_002 = {
MainPartitionGuid = Guid("D658DDB6-0B1E-4555-ABB8-5BC931C48F16")
}


function Patches:__init()
m_VEMLogger:Write("Initializing Patches")

-- Patch Menu Background
ResourceManager:RegisterInstanceLoadHandler(Guid("3A3E5533-4B2A-11E0-A20D-FE03F1AD0E2F"),
Guid("F26B7ECE-A71D-93AC-6C49-B6223BF424D6"), self, self._OnMenuBGLoaded)
if VEM_CONFIG.PATCH_DN_COMPONENTS then
-- ResourceManager:RegisterPartitionLoadHandlerOnce(Guid('675975D5-F74E-11E1-BE7E-D621ACDFC7F6'),
-- self, function(partition)
-- partition.primaryInstance:MakeWritable()
-- partition.primaryInstance:ReplaceReferences(nil)
-- end
-- )

-- This didn't work :(

-- ResourceManager:RegisterInstanceLoadHandlerOnce(Guid('675975D5-F74E-11E1-BE7E-D621ACDFC7F6'),
-- Guid("4F45BDE8-25AA-1869-0078-DE697547B492"),
-- self, self._OnXP4LakeEnvLoaded)
ResourceManager:RegisterInstanceLoadHandler(Guid("3A3E5533-4B2A-11E0-A20D-FE03F1AD0E2F"),
Guid("F26B7ECE-A71D-93AC-6C49-B6223BF424D6"), self, self._OnMenuBGLoaded)
-- ResourceManager:RegisterInstanceLoadHandler(XP1_001.MainPartitionGuid,
-- Guid("BBA12DEB-BC7A-E7F7-5E0D-43DFAF4AFFF4"), self, self._OnKarkandOmandWaterLoaded)
-- ResourceManager:RegisterInstanceLoadHandler(XP1_002.MainPartitionGuid,
-- Guid("CAEA8375-0AFC-4367-D5AD-032158C1B13F"), self, self._OnKarkandOmandWaterLoaded)
end
-- This will REMOVE the water entierly (recommend to just remove the waves too,
-- but I don't really like how it looks, specially for Gulf...
-- I mean there is a fucking boat in it)
-- Events:Subscribe('Level:LoadResources', function(level)
-- local visual = ResourceManager:GetSettings("VisualTerrainSettings")
-- if visual ~= nil then
-- visual = VisualTerrainSettings(visual)
-- if m_PatchDatatable.waters[level] then
-- visual.drawWaterEnable = false
-- end
-- end
-- end)
end

-- ---@param p_Instance DataContainer
-- function Patches:_OnXP4LakeEnvLoaded(p_Instance)
-- print("############ Removing XP4 LakeEnv #####################")
-- -- local texture = TextureAsset(p_Instance)
-- Asset(p_Instance).name = ""
-- -- texture:MakeWritable()
-- -- texture.name = ""
-- -- p_Instance:ReplaceReferences(texture)
-- print("############ Removed XP4 LakeEnv #####################")
-- end

---@param p_Instance DataContainer
local function _PatchMeshAsset(p_Instance)
if m_PatchDatatable.meshes[p_Instance.partition.name] then
Expand All @@ -24,8 +73,60 @@ local function _PatchMeshAsset(p_Instance)
for _, l_Material in pairs(s_Mesh.materials) do
l_Material:MakeWritable()
l_Material.shader.shader = nil
-- print('The instance: ' .. p_Instance.partition.name)
-- print('################# Patched Mesh :) #################')
end
end
-- Messing with its enlightenType doesn't work either.
-- if m_PatchDatatable.rigidMeshs[p_Instance.partition.name] then
-- print("#####1################### Checking those backdrops #############################")
-- local s_Mesh = MeshAsset(p_Instance)
-- s_Mesh:MakeWritable()
-- s_Mesh.enlightenType = 0 -- 0 = Dynamic
-- end
end

---@param p_Instance DataContainer
local function _PatchWaterAsset(p_Instance)
if m_PatchDatatable.waterAssets[p_Instance.partition.name] then
for _, instance in pairs(p_Instance.partition.instances) do
if instance:Is('LakeData') then
-- if instance.isLazyLoaded then
-- instance:RegisterLoadHandlerOnce(function(loadedInstance)
-- print('Instance has loaded!')
-- local lakeData = LakeData(loadedInstance)
-- lakeData:MakeWritable()
-- if lakeData.shader3d.isLazyLoaded then
-- lakeData.shader3d:RegisterLoadHandlerOnce(function(loadedInstance)
-- print('Instance has loaded!')
-- local shader = ShaderGraph(loadedInstance)
-- shader:MakeWritable()
-- shader.gammaCorrectionEnable = false
-- end)
-- else
-- lakeData.shader3d.gammaCorrectionEnable = false
-- end
-- end
-- )
-- else
-- We know now that LakeData aren't lazy loaded ...
local lakeData = LakeData(instance)
lakeData:MakeWritable()
if lakeData.shader3d.isLazyLoaded then
lakeData.shader3d:RegisterLoadHandlerOnce(function(loadedInstance)
print('Instance has loaded!')
local shader = ShaderGraph(loadedInstance)
shader:MakeWritable()
shader = nil
end)
else
lakeData.shader3d.gammaCorrectionEnable = false
end
end
end
-- end
m_VEMLogger:Write("Water Assets patched")
end
end

---@param p_Instance DataContainer
Expand All @@ -34,6 +135,8 @@ local function _PatchMeshMaterialVariation(p_Instance)
local s_Variation = MeshMaterialVariation(p_Instance)
s_Variation:MakeWritable()
s_Variation.shader.shader = nil
-- print('The instance: ' .. p_Instance.partition.name)
-- print('################# Patched ObjectVariation :) #################')
end
end

Expand Down Expand Up @@ -137,18 +240,23 @@ end

---@param p_Partition DatabasePartition
function Patches:PatchComponents(p_Partition)
-- print('The partition: ' .. tostring(p_Partition))
-- print('The partition primaryInstance typeinfo elementType: ' ..
-- tostring(p_Partition.primaryInstance.typeInfo.elementType))
-- print('The partition primaryInstance typeinfo name : ' .. tostring(p_Partition.primaryInstance.typeInfo.name))

if not VEM_CONFIG.PATCH_DN_COMPONENTS then
return
end

if p_Partition.primaryInstance:Is("MeshAsset") then
-- print('The Partition Name: ' .. p_Partition.name)
-- print('Its primary Instance name' .. p_Partition.primaryInstance.partition.name)
_PatchMeshAsset(p_Partition.primaryInstance)
-- elseif p_Partition.primaryInstance:Is("WaterAsset") then
-- _PatchWaterAsset(p_Partition.primaryInstance)
elseif p_Partition.primaryInstance:Is("TextureAsset") then
if m_PatchDatatable.textures[p_Partition.primaryInstance.name] then
-- print("################ TEXTURE MATCH ###############")
local texture = TextureAsset(p_Partition.primaryInstance)
texture:MakeWritable()
texture = nil
-- print("################ ITS NIL NOW ###############")
end
elseif p_Partition.primaryInstance:Is("ObjectVariation") then
-- print('The Partition Name: ' .. p_Partition.name)
-- print('Its primary Instance name' .. p_Partition.primaryInstance.partition.name)
for _, l_Instance in ipairs(p_Partition.instances) do
if l_Instance:Is('MeshMaterialVariation') then -- ObjectVariation is the primary instance
_PatchMeshMaterialVariation(l_Instance)
Expand All @@ -170,6 +278,8 @@ function Patches:PatchComponents(p_Partition)
end
elseif p_Partition.primaryInstance:Is("EmitterTemplateData") then
_PatchEmitterTemplateData(p_Partition.primaryInstance)
-- elseif p_Partition.primaryInstance:Is("ShaderGraph") then
-- waterShaders
end
end

Expand All @@ -184,4 +294,13 @@ function Patches:_OnMenuBGLoaded(p_Instance)
m_VEMLogger:Write("Menu background patched (priority increased)")
end

-- function Patches:_OnKarkandOmandWaterLoaded(waterAssets)
-- for _, lakesAndWater in pairs(waterAssets.partition.instances) do
-- lakesAndWater:MakeWritable()
-- lakesAndWater.shader.shader = nil
-- end

-- m_VEMLogger:Write("Karkand/Oman water patched")
-- end

return Patches()
Loading