namespace = TexFx

[ShaderRegexOutlineTransparency]
shader_model = ps_4_0 ps_5_0
filter_index = 037730.0
temps = ini tex69 tex70 dim
if ps-t69 === 0 && $texfx_on
	run = CommandListSetResourceReferences
	run = CommandListSetIntensity
	run = CommandListSwapVersion
endif
ps-t69 = null
if ps-t70 === 0
	post ps-t70 = null
endif

; Regex Match ---------------------------------------
;Match Outline
[ShaderRegexOutlineTransparency.Pattern]
(?P<MatchDiffuse>
dcl_output o0\.xyzw\n
dcl_output o1\.xyzw\n
dcl_output o2\.xyzw\n
dcl_output o3\.x\n
dcl_output o4\.x\n
dcl_output o5\.x\n
^[\s\S]+)
(?s)(?P<TillModesty>^discard_nz r0\.[xy]\nne r0\..*\nif_nz r0\.[xy]\n\s*lt.*?)
(?P<Modesty>discard\w+ \w+\.[xyzw]+\n)
(?s)(?P<TillSetColor>.*else\n\s*mov (?P<color>r\d\.[xyzw]+), v\d\.[xyzw]+\nendif\n)
(?P<TillRet>.*)
ret

[ShaderRegexOutlineTransparency.InsertDeclarations]
dcl_resource_texture1d (float,float,float,float) t120
dcl_resource_texture2d (float,float,float,float) t69
dcl_resource_texture2d (float,float,float,float) t70
dcl_sampler s14, mode_default
dcl_sampler s15, mode_default

[ShaderRegexOutlineTransparency.Pattern.Replace]
${MatchDiffuse}
ld_indexable(texture1d)(float,float,float,float) ${ini}.xyzw, l(69,0), t120.xyzw\n
${TillModesty}
\t	if_z ${ini}.z\n
\t\t	${Modesty}
\t	endif\n
;
${TillSetColor}
; Custom Outline Colors, Sponsered by Annplan.
if_z ${ini}.y\n
\t	resinfo_indexable(texture2d)(float,float,float,float) ${dim}.xyyy, l(0), t70.xyyy\n
\t	if_nz ${dim}.xy\n
\t\t	sample_indexable(texture2d)(float,float,float,float) ${tex70}.xyz, v2.xy, t70.xyzw, s14\n
\t\t	mov ${color}, ${tex70}.xyz\n
\t	endif\n
endif\n
${TillRet}
if_z ${ini}.y\n
; TexFx Discard Outlines
\t	resinfo_indexable(texture2d)(float,float,float,float) ${dim}.xyzw, l(0), t69.xyzw\n
\t	if_nz ${dim}.xy\n
\t\t	sample_indexable(texture2d)(float,float,float,float) ${tex69}.xyzw, v2.xy, t69.xyzw, s15\n
; Green Channel
;
; Blue Channel
;
;Red Channel
\t\t	discard_nz ${tex69}.x\n
\t	endif\n
endif\n
ret