[Constants]
global persist $var1 = 0
global persist $var2 = 0
global persist $var3 = 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,4
; Bra/Top : Org. -> Bra Only -> Top Only -> Top Only (Transparent) -> None

[KeySwitchVar2]
condition = $active
Key = ctrl no_shift no_alt z
type = cycle
$var2 = 0,1
; Necklace : On/Off

[KeySwitchVar3]
condition = $active
Key = ctrl no_shift no_alt c
type = cycle
$var3 = 0,1,2,3
; Leggings/Panty : Org. -> Leggings Only -> Panty Only -> None

; No Outer
[TextureOverrideOuter01]
hash = 127eddcc
match_first_index = 5898
if ($var1 == 1 || $var1 == 4) && $active
	handling = skip	
elif ($var1 == 0 || $var1 == 2) && $active
	handling = skip
	vb0 = ResourceTopVB
	ib  = ResourceTopIB
	drawindexed = auto
elif $var1 == 3 && $active
	handling = skip
	vb0 = ResourceTopVB
	ib  = ResourceTopIB
	run = CustomShaderTransparency
endif

[TextureOverrideOuter02]
hash = 5525667c
match_first_index = 8982
if ($var1 == 1 || $var1 == 4) && $active
	handling = skip	
elif $var1 == 3 && $active
	run = CustomShaderTransparencyF
endif

[TextureOverrideOuter03]
hash = 5525667c
match_first_index = 43575
if ($var1 == 1 || $var1 == 4) && $active
	handling = skip	
elif $var1 == 3 && $active
	run = CustomShaderTransparencyF
endif

[TextureOverrideOuter04]
hash = 5525667c
match_first_index = 12987
if ($var1 == 1 || $var1 == 4) && $active
	handling = skip	
elif $var1 == 3 && $active
	run = CustomShaderTransparencyF
endif

; Bra
[TextureOverrideBra01]
hash = 5525667c
match_first_index = 14457
if $var1 > 1 && $active
	handling = skip
endif

[TextureOverrideBra02]
hash = 5525667c
match_first_index = 3462
if $var1 > 1 && $active
	handling = skip
endif

[TextureOverrideBra03]
hash = 5525667c
match_first_index = 43863
if $var1 > 1 && $active
	handling = skip
endif

; Leggings
[TextureOverrideLeggings01]
hash = 5525667c
match_first_index = 4050
if $var3 > 1 && $active
	handling = skip
endif

[TextureOverrideLeggings02]
hash = 127eddcc
match_first_index = 0
if $var3 > 1 && $active
	handling = skip
elif $var3 > 0 && $active
	handling = skip
	ResourceBakT0 = ref ps-t0
	ResourceBakT1 = ref ps-t1
	ps-t0 = ResourceTexturePants
	ps-t1 = ResourceTexturePantsW
	vb0 = ResourcePantsVB
	ib  = ResourcePantsIB
	drawindexed = auto
	vb0 = ResourcePantsThinVB
	ib  = ResourcePantsThinIB
	run = CustomShaderTransparencyPants
	ps-t1 = ResourceBakT1
	ps-t0 = ResourceBakT0
endif

; Panty
[TextureOverridePanty01]
hash = 5525667c
match_first_index = 150
if $active
	if ($var3 == 1 || $var3 == 3)
		handling = skip
	elif $var3 == 2
		handling = skip
		vb0 = ResourcePantyVB
		ib  = ResourcePantyIB
		drawindexed = auto
	endif
endif

[TextureOverridePanty02]
hash = 5525667c
match_first_index = 0
if $active
	if ($var3 == 1 || $var3 == 3)
		handling = skip
	elif $var3 == 2
		handling = skip
		vb0 = ResourcePantyAccVB
		ib  = ResourcePantyAccIB
		drawindexed = auto
	endif
endif

[TextureOverridePanty03]
hash = 5525667c
match_first_index = 3438
if $active
	if ($var3 == 1 || $var3 == 3)
		handling = skip
	endif
endif

; Necklace
[TextureOverrideNecklace01]
hash = 5525667c
match_first_index = 29307
if $var2 > 0 && $active
	handling = skip
endif

; Body
[TextureOverrideBody]
hash = 2658b82e
$active = 1
match_first_index = 0
handling = skip
if $var1 > 1
	vb0 = ResourceBodyU1VB
	ib  = ResourceBodyU1IB
else
	vb0 = ResourceBodyU0VB
	ib  = ResourceBodyU0IB
endif
drawindexed = auto
if $var3 > 1
	vb0 = ResourceBodyL2VB
	ib  = ResourceBodyL2IB
elif $var3 > 0
	vb0 = ResourceBodyL1VB
	ib  = ResourceBodyL1IB
else
	vb0 = ResourceBodyL0VB
	ib  = ResourceBodyL0IB
endif
drawindexed = auto

; Resources
[ResourceBodyU0VB]
type = Buffer
stride = 80
filename = resources\body_U_0.vb

[ResourceBodyU0IB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\body_U_0.ib

[ResourceBodyU1VB]
type = Buffer
stride = 80
filename = resources\body_U_1.vb

[ResourceBodyU1IB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\body_U_1.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

[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

[ResourceBodyL2VB]
type = Buffer
stride = 80
filename = resources\body_L_2.vb

[ResourceBodyL2IB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\body_L_2.ib

[ResourcePantyVB]
type = Buffer
stride = 76
filename = resources\panty.vb

[ResourcePantyIB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\panty.ib

[ResourcePantyAccVB]
type = Buffer
stride = 76
filename = resources\panty_acc.vb

[ResourcePantyAccIB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\panty_acc.ib

[ResourcePantsVB]
type = Buffer
stride = 76
filename = resources\pants.vb

[ResourcePantsIB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\pants.ib

[ResourcePantsThinVB]
type = Buffer
stride = 76
filename = resources\pants_thin.vb

[ResourcePantsThinIB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\pants_thin.ib

[ResourceTopVB]
type = Buffer
stride = 76
filename = resources\Top.vb

[ResourceTopIB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\Top.ib

[ResourceBakT0]
[ResourceBakT1]
[ResourceTexturePants]
filename = resources\texture\pants.dds
[ResourceTexturePantsW]
filename = resources\texture\pants_W.dds

; Transparency
[CustomShaderTransparencyF]
blend[0] = ADD BLEND_FACTOR INV_BLEND_FACTOR
blend_factor[0] = 0.4
blend_factor[1] = 0.4
blend_factor[2] = 0.4
blend_factor[3] = 1
draw = from_caller
handling = skip

[CustomShaderTransparency]
blend[0] = ADD BLEND_FACTOR INV_BLEND_FACTOR
blend_factor[0] = 0.4
blend_factor[1] = 0.4
blend_factor[2] = 0.4
blend_factor[3] = 1
drawindexed = auto

[CustomShaderTransparencyPants]
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
