; EFMI ALPHA-5 INI
;此MOD为终末地跨IB教程贴示例的MOD，内容仅作为学习交流使用。
;教程链接https://www.caimogu.cc/post/2329514.html
;欢迎专业人士指正和补充！
; Mod Info -------------------------

[ResourceModName]
type = Buffer
data = "ChenQianyu Qipao"

[ResourceModAuthor]
type = Buffer
data = "FengliS"

[ResourceModDesc]
; type = Buffer
; data = "Empty Mod Description"

[ResourceModLink]
; type = Buffer
; data = "Empty Mod Link"

[ResourceModLogo]
; filename = Textures/Logo.dds

; Mod State -------------------------

[Constants]
global $required_efmi_version = 1.10
global $object_guid = 216957
global $mesh_vertex_count = 3757
global $mod_id = -1000
global $mod_enabled = 0
global $object_detected = 0
global $lod_detected = 0
global $body_bones_recorded = 0

[Present]
if $object_detected
    if $mod_enabled
        post $object_detected = 0
    else
        if $mod_id == -1000
            run = CommandListRegisterMod
        endif
    endif
endif

[CommandListRegisterMod]
$\EFMIv1\required_version = $required_efmi_version
$\EFMIv1\object_guid = $object_guid
Resource\EFMIv1\ModName = ref ResourceModName
Resource\EFMIv1\ModAuthor = ref ResourceModAuthor
Resource\EFMIv1\ModDesc = ref ResourceModDesc
Resource\EFMIv1\ModLink = ref ResourceModLink
Resource\EFMIv1\ModLogo = ref ResourceModLogo
run = CommandList\EFMIv1\RegisterMod
$mod_id = $\EFMIv1\mod_id
if $mod_id >= 0
    $mod_enabled = 1
endif

; 跨IB起手式1 不需要更改-------------------------
[ResourceDumpedCB1_UAV]
type = RWStructuredBuffer
stride = 16
array = 4096

[ResourceDumpedCB1_SRV]
type = Buffer
stride = 16
array = 4096

[ResourceFakeCB1_UAV]
type = RWStructuredBuffer
stride = 16
array = 4096

[ResourceFakeCB1]
type = Buffer
stride = 16
format = R32G32B32A32_UINT
array = 4096

[ResourceFakeT0_UAV]
type = RWStructuredBuffer
stride = 16
array = 200000

[ResourceFakeT0_SRV]
type = StructuredBuffer
stride = 16
array = 200000

; 部位身份卡，参与跨IB的部位都需要有对应的编号
[ResourceID_Body]
type = Buffer
format = R32_FLOAT
data = 0.0

[ResourceID_body2]
type = Buffer
format = R32_FLOAT
data = 1000.0

[CustomShader_ExtractCB1]
vs = hlsl/extract_cb1_vs.hlsl
ps = hlsl/extract_cb1_ps.hlsl
ps-u7 = ResourceDumpedCB1_UAV
depth_enable = false  
blend = ADD SRC_ALPHA INV_SRC_ALPHA
cull = none  
topology = point_list
draw = 4096, 0 
ps-u7 = null
ResourceDumpedCB1_SRV = copy ResourceDumpedCB1_UAV

[CustomShader_RecordBones]
cs = hlsl/record_bones_cs.hlsl
cs-t0 = vs-t0
cs-t1 = ResourceDumpedCB1_SRV
cs-u1 = ResourceFakeT0_UAV
dispatch = 12, 1, 1
cs-u1 = null
cs-t0 = null
cs-t1 = null
ResourceFakeT0_SRV = copy ResourceFakeT0_UAV

[CustomShader_RedirectCB1]
cs = hlsl/redirect_cb1_cs.hlsl
cs-t0 = ResourceDumpedCB1_SRV
cs-u0 = ResourceFakeCB1_UAV
dispatch = 4, 1, 1
cs-u0 = null
cs-t0 = null
ResourceFakeCB1 = copy ResourceFakeCB1_UAV

[ShaderOverridevs2]  
hash = 847947b4a1ad40cf
filter_index = 200
[ShaderOverridevs10]  
hash = ac358c21b925075b
filter_index = 201
[ShaderOverridevs1]  
hash = b1ca4834786821dd
filter_index = 202
[ShaderOverridevs33]  
hash = cdf11b288d812606
filter_index = 203
[ShaderOverridevs88]  
hash = 8e1c0782db9e85d1
filter_index = 203
[ShaderOverridevs22]  
hash = 6d85d78157be3f4c
filter_index = 200
; Shading: Custom Mesh Draw CommandLists -------------------------

[CommandList_Draw_Component0]
run = CommandList\EFMIv1\OverrideTextures
ib = ref Resource_Component0_IB
vb0 = ref Resource_Component0_VB0
vb1 = ref Resource_Component0_VB1
if $lod_detected == 0
    vb2 = ref Resource_Component0_VB2
else
    vb2 = ref Resource_Component0_VB2_LOD
endif
vb3 = vb0
ps-t15 = Resource_Texture4
ps-t16 = Resource_Texture3
ps-t17 = Resource_Texture2
ps-t14 = Resource_Texture1
ps-t0 = Resource_Texture1
if vs ==200 || vs == 201
    run = CustomShader_ExtractCB1
    cs-t2 = ResourceID_Body
    run = CustomShader_RecordBones
    run = CustomShader_RedirectCB1
    vs-t0 = ResourceFakeT0_SRV
    vs-cb1 = ResourceFakeCB1
; Draw Component 0 323b8ae3.光腿旗袍
drawindexedinstanced = 63306, INSTANCE_COUNT, 0, 0, FIRST_INSTANCE
; Draw Component 0 323b8ae3.身体部分
drawindexedinstanced = 142410, INSTANCE_COUNT, 63306, 0, FIRST_INSTANCE
endif
; Draw Component 0 323b8ae3.光腿旗袍
drawindexedinstanced = 63306, INSTANCE_COUNT, 0, 0, FIRST_INSTANCE

post vs-cb1 = null
post vs-t0 = null
post cs-t2 = null

[CommandList_Draw_Component0LOD]
run = CommandList\EFMIv1\OverrideTextures
ib = ref Resource_Component0_IB
vb0 = ref Resource_Component0_VB0
vb1 = ref Resource_Component0_VB1
if $lod_detected == 0
    vb2 = ref Resource_Component0_VB2
else
    vb2 = ref Resource_Component0_VB2_LOD
endif
vb3 = vb0
ps-t15 = Resource_Texture4
ps-t16 = Resource_Texture3
ps-t17 = Resource_Texture2
ps-t14 = Resource_Texture1
ps-t0 = Resource_Texture1
if vs ==200 || vs == 201
    run = CustomShader_ExtractCB1
    cs-t2 = ResourceID_Body2
    run = CustomShader_RecordBones
    run = CustomShader_RedirectCB1
    vs-t0 = ResourceFakeT0_SRV
    vs-cb1 = ResourceFakeCB1
; Draw Component 0 323b8ae3.光腿旗袍
drawindexedinstanced = 63306, INSTANCE_COUNT, 0, 0, FIRST_INSTANCE
; Draw Component 0 323b8ae3.身体部分
drawindexedinstanced = 142410, INSTANCE_COUNT, 63306, 0, FIRST_INSTANCE
endif
; Draw Component 0 323b8ae3.光腿旗袍
drawindexedinstanced = 63306, INSTANCE_COUNT, 0, 0, FIRST_INSTANCE

post vs-cb1 = null
post vs-t0 = null
post cs-t2 = null

[CommandList_Draw_Component5]
run = CommandList\EFMIv1\OverrideTextures
ib = ref Resource_Component5_IB
vb0 = ref Resource_Component5_VB0
vb1 = ref Resource_Component5_VB1
if $lod_detected == 0
    vb2 = ref Resource_Component5_VB2
else
    vb2 = ref Resource_Component5_VB2_LOD
endif
vb3 = vb0
ps-t13 = Resource_Texture4
ps-t14 = Resource_Texture3
ps-t0 = Resource_Texture1
; Draw Component 5 b8b3e4c1.001
drawindexedinstanced = 456, INSTANCE_COUNT, 0, 0, FIRST_INSTANCE
; Draw Component 5 b8b3e4c1.002
drawindexedinstanced = 69, INSTANCE_COUNT, 456, 0, FIRST_INSTANCE
; Draw Component 5 b8b3e4c1.003
drawindexedinstanced = 69, INSTANCE_COUNT, 525, 0, FIRST_INSTANCE

vs-t0 = ResourceFakeT0_SRV
vs-cb1 = ResourceFakeCB1
if vs == 202 || vs == 203
cs-t2 = ResourceID_Body
run = CustomShader_RedirectCB1
ib = ref Resource_Component0_IB
vb0 = ref Resource_Component0_VB0
vb1 = ref Resource_Component0_VB1
if $lod_detected == 0
    vb2 = ref Resource_Component0_VB2
else
    vb2 = ref Resource_Component0_VB2_LOD
endif
vb3 = vb0
; Draw Component 0 323b8ae3.身体部分
drawindexedinstanced = 142410, INSTANCE_COUNT, 63306, 0, FIRST_INSTANCE
endif

post vs-cb1 = null
post vs-t0 = null
post cs-t2 = null


[CommandList_Draw_Component5LOD]
run = CommandList\EFMIv1\OverrideTextures
ib = ref Resource_Component5_IB
vb0 = ref Resource_Component5_VB0
vb1 = ref Resource_Component5_VB1
if $lod_detected == 0
    vb2 = ref Resource_Component5_VB2
else
    vb2 = ref Resource_Component5_VB2_LOD
endif
vb3 = vb0
ps-t13 = Resource_Texture4
ps-t14 = Resource_Texture3
ps-t0 = Resource_Texture1
; Draw Component 5 b8b3e4c1.001
drawindexedinstanced = 456, INSTANCE_COUNT, 0, 0, FIRST_INSTANCE
; Draw Component 5 b8b3e4c1.002
drawindexedinstanced = 69, INSTANCE_COUNT, 456, 0, FIRST_INSTANCE
; Draw Component 5 b8b3e4c1.003
drawindexedinstanced = 69, INSTANCE_COUNT, 525, 0, FIRST_INSTANCE

vs-t0 = ResourceFakeT0_SRV
vs-cb1 = ResourceFakeCB1
if vs == 202 || vs == 203
cs-t2 = ResourceID_Body2
run = CustomShader_RedirectCB1
ib = ref Resource_Component0_IB
vb0 = ref Resource_Component0_VB0
vb1 = ref Resource_Component0_VB1
if $lod_detected == 0
    vb2 = ref Resource_Component0_VB2
else
    vb2 = ref Resource_Component0_VB2_LOD
endif
vb3 = vb0
; Draw Component 0 323b8ae3.身体部分
drawindexedinstanced = 142410, INSTANCE_COUNT, 63306, 0, FIRST_INSTANCE
endif

post vs-cb1 = null
post vs-t0 = null
post cs-t2 = null
; Shading: Full Models Draw Call Stacks Processing -------------------------

[TextureOverride_Component0]
hash = 323b8ae3
$object_detected = 1
$lod_detected = 0
if $mod_enabled && DRAW_TYPE == 4
    handling = skip
    run = CommandList_Draw_Component0
endif

[TextureOverride_Component5]
hash = b8b3e4c1
$object_detected = 1
$lod_detected = 0
if $mod_enabled && DRAW_TYPE == 4
    handling = skip
    run = CommandList_Draw_Component5
endif


; Shading: LoD Models Draw Call Stacks Processing -------------------------

[TextureOverride_Component0_LOD0]
hash = 0210cd02
$object_detected = 1
$lod_detected = 1
if $mod_enabled && DRAW_TYPE == 4
    handling = skip
    run = CommandList_Draw_Component0LOD
endif

[TextureOverride_Component5_LOD0]
hash = c568aff9
$object_detected = 1
$lod_detected = 1
if $mod_enabled && DRAW_TYPE == 4
    handling = skip
    run = CommandList_Draw_Component5LOD
endif


; Shading: Textures -------------------------

[Resource_Texture0]
filename = Textures/Components-0-6 t=7d330dbd.dds

[TextureOverride_Texture0]
hash = 7d330dbd
match_priority = 0
if $object_detected
    this = Resource_Texture0
endif

[Resource_Texture1]
filename = Textures/Components-0-6 t=d4b51f22.dds

[TextureOverride_Texture1]
hash = d4b51f22
match_priority = 0
if $object_detected
    this = Resource_Texture1
endif

[Resource_Texture2]
filename = Textures/Components-0-6-7 t=7a3eb477.dds

[TextureOverride_Texture2]
hash = 7a3eb477
match_priority = 0
if $object_detected
    this = Resource_Texture2
endif

[Resource_Texture3]
filename = Textures/Components-0-6-7 t=a9426510.dds

[TextureOverride_Texture3]
hash = a9426510
match_priority = 0
if $object_detected
    this = Resource_Texture3
endif

[Resource_Texture4]
filename = Textures/Components-0-6-7 t=c84302ec.dds

[TextureOverride_Texture4]
hash = c84302ec
match_priority = 0
if $object_detected
    this = Resource_Texture4
endif

[Resource_Texture5]
filename = Textures/Components-1 t=151c9982.dds

[TextureOverride_Texture5]
hash = 151c9982
match_priority = 0
if $object_detected
    this = Resource_Texture5
endif

[Resource_Texture6]
filename = Textures/Components-1 t=402c7ca1.dds

[TextureOverride_Texture6]
hash = 402c7ca1
match_priority = 0
if $object_detected
    this = Resource_Texture6
endif

[Resource_Texture7]
filename = Textures/Components-1 t=89e6a0f7.dds

[TextureOverride_Texture7]
hash = 89e6a0f7
match_priority = 0
if $object_detected
    this = Resource_Texture7
endif

[Resource_Texture8]
filename = Textures/Components-1 t=8ac318b6.dds

[TextureOverride_Texture8]
hash = 8ac318b6
match_priority = 0
if $object_detected
    this = Resource_Texture8
endif

[Resource_Texture9]
filename = Textures/Components-1 t=c9909a5f.dds

[TextureOverride_Texture9]
hash = c9909a5f
match_priority = 0
if $object_detected
    this = Resource_Texture9
endif

[Resource_Texture10]
filename = Textures/Components-3 t=0cc60b53.dds

[TextureOverride_Texture10]
hash = 0cc60b53
match_priority = 0
if $object_detected
    this = Resource_Texture10
endif

[Resource_Texture11]
filename = Textures/Components-5 t=91a468ed.dds

[TextureOverride_Texture11]
hash = 91a468ed
match_priority = 0
if $object_detected
    this = Resource_Texture11
endif

[Resource_Texture12]
filename = Textures/Components-7 t=e69d7088.dds

[TextureOverride_Texture12]
hash = e69d7088
match_priority = 0
if $object_detected
    this = Resource_Texture12
endif

; Resources: Buffers -------------------------

[Resource_Component0_IB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
stride = 6
filename = Meshes/Component0_IB.buf

[Resource_Component0_VB0]
type = Buffer
stride = 16
filename = Meshes/Component0_VB0.buf

[Resource_Component0_VB1]
type = Buffer
stride = 12
filename = Meshes/Component0_VB1.buf

[Resource_Component0_VB2]
type = Buffer
stride = 12
filename = Meshes/Component0_VB2.buf

[Resource_Component0_VB2_LOD]
type = Buffer
stride = 12
filename = Meshes/Component0_VB2_LOD.buf

[Resource_Component1_IB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
stride = 6
filename = Meshes/Component1_IB.buf

[Resource_Component1_VB0]
type = Buffer
stride = 16
filename = Meshes/Component1_VB0.buf

[Resource_Component1_VB1]
type = Buffer
stride = 12
filename = Meshes/Component1_VB1.buf

[Resource_Component1_VB2]
type = Buffer
stride = 12
filename = Meshes/Component1_VB2.buf

[Resource_Component1_VB2_LOD]
type = Buffer
stride = 12
filename = Meshes/Component1_VB2_LOD.buf

[Resource_Component2_IB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
stride = 6
filename = Meshes/Component2_IB.buf

[Resource_Component2_VB0]
type = Buffer
stride = 16
filename = Meshes/Component2_VB0.buf

[Resource_Component2_VB1]
type = Buffer
stride = 8
filename = Meshes/Component2_VB1.buf

[Resource_Component2_VB2]
type = Buffer
stride = 12
filename = Meshes/Component2_VB2.buf

[Resource_Component2_VB2_LOD]
type = Buffer
stride = 12
filename = Meshes/Component2_VB2_LOD.buf

[Resource_Component3_IB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
stride = 6
filename = Meshes/Component3_IB.buf

[Resource_Component3_VB0]
type = Buffer
stride = 16
filename = Meshes/Component3_VB0.buf

[Resource_Component3_VB1]
type = Buffer
stride = 8
filename = Meshes/Component3_VB1.buf

[Resource_Component3_VB2]
type = Buffer
stride = 4
filename = Meshes/Component3_VB2.buf

[Resource_Component4_IB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
stride = 6
filename = Meshes/Component4_IB.buf

[Resource_Component4_VB0]
type = Buffer
stride = 16
filename = Meshes/Component4_VB0.buf

[Resource_Component4_VB1]
type = Buffer
stride = 8
filename = Meshes/Component4_VB1.buf

[Resource_Component4_VB2]
type = Buffer
stride = 12
filename = Meshes/Component4_VB2.buf

[Resource_Component5_IB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
stride = 6
filename = Meshes/Component5_IB.buf

[Resource_Component5_VB0]
type = Buffer
stride = 16
filename = Meshes/Component5_VB0.buf

[Resource_Component5_VB1]
type = Buffer
stride = 12
filename = Meshes/Component5_VB1.buf

[Resource_Component5_VB2]
type = Buffer
stride = 12
filename = Meshes/Component5_VB2.buf

[Resource_Component5_VB2_LOD]
type = Buffer
stride = 12
filename = Meshes/Component5_VB2_LOD.buf

[Resource_Component7_IB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
stride = 6
filename = Meshes/Component7_IB.buf

[Resource_Component7_VB0]
type = Buffer
stride = 16
filename = Meshes/Component7_VB0.buf

[Resource_Component7_VB1]
type = Buffer
stride = 12
filename = Meshes/Component7_VB1.buf

[Resource_Component7_VB2]
type = Buffer
stride = 12
filename = Meshes/Component7_VB2.buf

; Autogenerated -------------------------

; This mod.ini was automatically generated by EFMI Tools Blender addon v0.3.6 and requires EFMI v1.1.0+ to function

; EFMI Tools GitHub: https://github.com/SpectrumQT/EFMI-Tools
; EFMI Package GitHub: https://github.com/SpectrumQT/EFMI-Package
; XXMI Launcher GitHub: https://github.com/SpectrumQT/XXMI-Launcher
; EFMI Mods Website: https://gamebanana.com/games/21842
; EFMI GameBanana: https://gamebanana.com/tools/21846
; EFMI Tools GameBanana: https://gamebanana.com/tools/21847
; AGMF Modding Community Discord: https://discord.com/invite/agmf
; SHA256 CHECKSUM: 0efebb495b3d9a4fd6fbd72d4cc78bb45a4ffcc94b2e2336afab5e04ad7f12ad
