[Constants]
global persist $var1 = 0
global persist $var2 = 0
global persist $var3 = 0
global persist $var4 = 0
global $active = 0

[Present]
post $active = 0

[KeySwitchVar1]
condition = $active
Key = ctrl no_shift no_alt x
type = cycle
$var1 = 0,1,2,3
; Arm/Neck : Org. -> No Arm/Shoulder(Strap Only) -> No Arm Strap -> No Necklace

[KeySwitchVar2]
condition = $active
Key = ctrl no_shift no_alt z
type = cycle
$var2 = 0,1,2,3
; Skirt : Org. -> Transparent(2-Step) -> No Skirt

[KeySwitchVar3]
condition = $active
Key = ctrl no_shift no_alt c
type = cycle
$var3 = 0,1,2,3
; Dress : Org. -> Transparent(2-Step) -> No Dress

[KeySwitchVar4]
condition = $active
Key = ctrl no_shift no_alt v
type = cycle
$var4 = 0,1,2
; Shoes : Org. -> No Stocking/Shoes(Strap Only) -> No Strap

; Skirt
[TextureOverrideSkirt01]
hash = 97537210
match_first_index = 0
if $var2 > 0 && ($active || $shader_type == 5)
    handling = skip
    if $var2 == 2
        run = CustomShaderTransparencyF2
    elif $var2 == 1
        run = CustomShaderTransparencyF1
    endif
endif

[TextureOverrideSkirt99]
hash = 97537210
if $var2 > 2 && ($active || $shader_type == 5)
    handling = skip
endif

; Shoulder/Arm
[TextureOverrideArm01]
hash = ac36855b
match_first_index = 1218
if $var1 > 0 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideArm02]
hash = ac36855b
match_first_index = 28815
if $var1 > 0 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideArm03]
hash = ac36855b
match_first_index = 10404
if $var1 > 0 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideArm04]
hash = ac36855b
match_first_index = 10212
if $var1 > 0 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideArm05]
hash = ac36855b
match_first_index = 29019
if ($active || $shader_type == 5)
	handling = skip
    if $var1 <= 1
		vb0 = ResourceStrapAVB
		ib  = ResourceStrapAIB
		drawindexed = auto
	endif
    if $var1 <= 2
		vb0 = ResourceStrapNVB
		ib  = ResourceStrapNIB
		drawindexed = auto
	endif
endif

[TextureOverrideArm06]
hash = ac36855b
match_first_index = 33042
if ($active || $shader_type == 5)
	handling = skip
	if $var1 <= 0
		vb0 = ResourceMetalTVB
		ib  = ResourceMetalTIB
		drawindexed = auto
	endif
    if $var1 <= 1
		vb0 = ResourceMetalAVB
		ib  = ResourceMetalAIB
		drawindexed = auto
	endif
    if $var1 <= 2
		vb0 = ResourceMetalNVB
		ib  = ResourceMetalNIB
		drawindexed = auto
	endif
endif

; Top
[TextureOverrideTop12]
hash = ac36855b
match_first_index = 10422
if ($active || $shader_type == 5)
	handling = skip
    if $var3 <= 2
        vb0 = ResourceTop12VB
        ib  = ResourceTop12IB
        drawindexed = auto
        
        vb0 = ResourceTop12AVB
        ib  = ResourceTop12AIB    
        if $var3 == 2
            run = CustomShaderTransparency2
        elif $var3 == 1
            run = CustomShaderTransparency1
        elif $var3 == 0
            drawindexed = auto
        endif
    endif
endif

[TextureOverrideTop1]
hash = e1ec6ad0
match_first_index = 5697
if ($active || $shader_type == 5)
    handling = skip
    if $var3 <= 2
        vb0 = ResourceTop1VB
        ib  = ResourceTop1IB
        drawindexed = auto
    endif
endif

[TextureOverrideTop2]
hash = e1ec6ad0
match_first_index = 3333
if ($active || $shader_type == 5)
    handling = skip
    if $var3 <= 2
        vb0 = ResourceTop2VB
        ib  = ResourceTop2IB
        drawindexed = auto
    endif
endif

[TextureOverrideTop3]
hash = e1ec6ad0
match_first_index = 4047
if ($active || $shader_type == 5)
    handling = skip
    if $var3 <= 2
        vb0 = ResourceTop3VB
        ib  = ResourceTop3IB
        drawindexed = auto
    endif
endif

[TextureOverrideTop4]
hash = ac36855b
match_first_index = 240
if ($active || $shader_type == 5)
    handling = skip
    if $var3 <= 2
        vb0 = ResourceTop4VB
        ib  = ResourceTop4IB
        drawindexed = auto
    endif
endif

[TextureOverrideTop5]
hash = ac36855b
match_first_index = 45426
if ($active || $shader_type == 5)
    handling = skip
    if $var3 <= 2
        vb0 = ResourceTop5VB
        ib  = ResourceTop5IB
        drawindexed = auto
    endif
endif

[TextureOverrideTop6]
hash = ac36855b
match_first_index = 45966
if ($active || $shader_type == 5)
    handling = skip
    if $var3 <= 2
        vb0 = ResourceTop6VB
        ib  = ResourceTop6IB
        drawindexed = auto
    endif
endif

[TextureOverrideTop7]
hash = ac36855b
match_first_index = 26433
if ($active || $shader_type == 5)
    handling = skip
    if $var3 <= 2
        vb0 = ResourceTop7VB
        ib  = ResourceTop7IB
        drawindexed = auto
    endif
endif

[TextureOverrideTop8]
hash = ac36855b
match_first_index = 27993
if ($active || $shader_type == 5)
    handling = skip
    if $var3 <= 2
        vb0 = ResourceTop8VB
        ib  = ResourceTop8IB
        drawindexed = auto
    endif
endif

[TextureOverrideTop9]
hash = ac36855b
match_first_index = 49926
if ($active || $shader_type == 5)
    handling = skip
    if $var3 <= 2
        vb0 = ResourceTop9VB
        ib  = ResourceTop9IB
        drawindexed = auto
    endif
endif

[TextureOverrideTop10]
hash = ac36855b
match_first_index = 51438
if ($active || $shader_type == 5)
    handling = skip
    if $var3 <= 2
        vb0 = ResourceTop10VB
        ib  = ResourceTop10IB
        drawindexed = auto
    endif
endif

[TextureOverrideTop11]
hash = ac36855b
match_first_index = 0
if ($active || $shader_type == 5)
    handling = skip
    if $var3 <= 2
        vb0 = ResourceTop11VB
        ib  = ResourceTop11IB
        drawindexed = auto
    endif
endif

[TextureOverrideTop13]
hash = 67729eff
if $var3 > 2 && ($active || $shader_type == 5)
    handling = skip
endif

; Shoes
[TextureOverrideRStocking01]
hash = e1ec6ad0
match_first_index = 0
pre ResourceVS1 = ref vs-cb2
if $var4 > 0 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideRStocking02]
hash = e1ec6ad0
match_first_index = 7167
if $var4 > 0 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideRStocking03]
hash = e1ec6ad0
match_first_index = 5607
if $var4 > 0 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideRStocking04_Strap]
hash = e1ec6ad0
match_first_index = 6021
if $var4 > 1 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideRStocking05_Strap]
hash = e1ec6ad0
match_first_index = 8022
if $var4 > 1 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideRStocking06_Strap]
hash = e1ec6ad0
match_first_index = 10902
if $var4 > 1 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideLStocking01]
hash = ac36855b
match_first_index = 23100
pre ResourceVS2 = ref vs-cb2
if $var4 > 0 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideLStocking02]
hash = ac36855b
match_first_index = 32187
if $var4 > 0 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideLStocking03]
hash = ac36855b
match_first_index = 28929
if $var4 > 0 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideLStocking04_Strap]
hash = ac36855b
match_first_index = 31041
if $var4 > 1 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideLStocking05_Strap]
hash = ac36855b
match_first_index = 47046
if $var4 > 1 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideLStocking06_Strap]
hash = ac36855b
match_first_index = 50484
if $var4 > 1 && ($active || $shader_type == 5)
	handling = skip
endif

; Body
[TextureOverrideBody]
hash = 4db12fe9
match_first_index = 0
$active = 1
handling = skip
if $var1 > 0
    vb0 = ResourceBodyAVB
    ib  = ResourceBodyAIB
    drawindexed = auto
	vb0 = ResourceBody1VB
	ib  = ResourceBody1IB    
else
	vb0 = ResourceBody0VB
	ib  = ResourceBody0IB
endif
drawindexed = auto

if $var4 > 1
    vb0 = ResourceBodyL1VB
    ib  = ResourceBodyL1IB
else
    vb0 = ResourceBodyL0VB
    ib  = ResourceBodyL0IB
endif
drawindexed = auto
if $var4 == 0
    vb0 = ResourceBodyL0AVB
    ib  = ResourceBodyL0AIB
    drawindexed = auto
endif

[TextureOverrideBodyAdd]
hash = 4db12fe9
match_first_index = 0
ResourceBakVS = ref vs-cb2
if $var4 > 0
    vs-cb2 = ref ResourceVS1
    vb0 = ResourceBodyLRVB
    ib  = ResourceBodyLRIB
    drawindexed = auto
    vs-cb2 = ref ResourceVS2
    vb0 = ResourceBodyLLVB
    ib  = ResourceBodyLLIB
    drawindexed = auto
endif
vs-cb2 = ref ResourceBakVS

; Resources
[ResourceBody0VB]
type = Buffer
stride = 80
filename = resources\body_0.vb
[ResourceBody0IB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\body_0.ib

[ResourceBody1VB]
type = Buffer
stride = 80
filename = resources\body_1.vb
[ResourceBody1IB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\body_1.ib

[ResourceBodyAVB]
type = Buffer
stride = 80
filename = resources\body_A.vb
[ResourceBodyAIB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\body_A.ib

[ResourceBodyL0VB]
type = Buffer
stride = 80
filename = resources\body_L_0.vb
[ResourceBodyL0IB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\body_L_0.ib

[ResourceBodyL0AVB]
type = Buffer
stride = 80
filename = resources\body_L_0_A.vb
[ResourceBodyL0AIB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\body_L_0_A.ib

[ResourceBodyL1VB]
type = Buffer
stride = 80
filename = resources\body_L_1.vb
[ResourceBodyL1IB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\body_L_1.ib

[ResourceBodyLLVB]
type = Buffer
stride = 80
filename = resources\body_L_L.vb
[ResourceBodyLLIB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\body_L_L.ib

[ResourceBodyLRVB]
type = Buffer
stride = 80
filename = resources\body_L_R.vb
[ResourceBodyLRIB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\body_L_R.ib

[ResourceMetalAVB]
type = Buffer
stride = 76
filename = resources\Metal_A.vb
[ResourceMetalAIB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\Metal_A.ib

[ResourceMetalTVB]
type = Buffer
stride = 76
filename = resources\Metal_T.vb
[ResourceMetalTIB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\Metal_T.ib

[ResourceMetalNVB]
type = Buffer
stride = 76
filename = resources\Metal_N.vb
[ResourceMetalNIB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\Metal_N.ib

[ResourceStrapAVB]
type = Buffer
stride = 76
filename = resources\Strap_A.vb
[ResourceStrapAIB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\Strap_A.ib

[ResourceStrapNVB]
type = Buffer
stride = 76
filename = resources\Strap_N.vb
[ResourceStrapNIB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\Strap_N.ib

[ResourceTop1VB]
type = Buffer
stride = 76
filename = resources\Top_1.vb
[ResourceTop1IB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\Top_1.ib

[ResourceTop2VB]
type = Buffer
stride = 76
filename = resources\Top_2.vb
[ResourceTop2IB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\Top_2.ib

[ResourceTop3VB]
type = Buffer
stride = 76
filename = resources\Top_3.vb
[ResourceTop3IB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\Top_3.ib

[ResourceTop4VB]
type = Buffer
stride = 76
filename = resources\Top_4.vb
[ResourceTop4IB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\Top_4.ib

[ResourceTop5VB]
type = Buffer
stride = 76
filename = resources\Top_5.vb
[ResourceTop5IB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\Top_5.ib

[ResourceTop6VB]
type = Buffer
stride = 76
filename = resources\Top_6.vb
[ResourceTop6IB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\Top_6.ib

[ResourceTop7VB]
type = Buffer
stride = 76
filename = resources\Top_7.vb
[ResourceTop7IB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\Top_7.ib

[ResourceTop8VB]
type = Buffer
stride = 76
filename = resources\Top_8.vb
[ResourceTop8IB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\Top_8.ib

[ResourceTop9VB]
type = Buffer
stride = 76
filename = resources\Top_9.vb
[ResourceTop9IB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\Top_9.ib

[ResourceTop10VB]
type = Buffer
stride = 76
filename = resources\Top_10.vb
[ResourceTop10IB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\Top_10.ib

[ResourceTop11VB]
type = Buffer
stride = 76
filename = resources\Top_11.vb
[ResourceTop11IB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\Top_11.ib

[ResourceTop12VB]
type = Buffer
stride = 76
filename = resources\Top_12.vb
[ResourceTop12IB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\Top_12.ib

[ResourceTop12AVB]
type = Buffer
stride = 76
filename = resources\Top_12_A.vb
[ResourceTop12AIB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\Top_12_A.ib

[ResourceVS1]
[ResourceVS2]
[ResourceBakVS]

; Transparency
[CustomShaderTransparency1]
blend[0] = ADD BLEND_FACTOR INV_BLEND_FACTOR
blend_factor[0] = 0.8
blend_factor[1] = 0.8
blend_factor[2] = 0.8
blend_factor[3] = 1
drawindexed = auto

[CustomShaderTransparency2]
blend[0] = ADD BLEND_FACTOR INV_BLEND_FACTOR
blend_factor[0] = 0.6
blend_factor[1] = 0.6
blend_factor[2] = 0.6
blend_factor[3] = 1
drawindexed = auto

[CustomShaderTransparencyF1]
blend[0] = ADD BLEND_FACTOR INV_BLEND_FACTOR
blend_factor[0] = 0.8
blend_factor[1] = 0.8
blend_factor[2] = 0.8
blend_factor[3] = 1
draw = from_caller

[CustomShaderTransparencyF2]
blend[0] = ADD BLEND_FACTOR INV_BLEND_FACTOR
blend_factor[0] = 0.6
blend_factor[1] = 0.6
blend_factor[2] = 0.6
blend_factor[3] = 1
draw = from_caller