SlotFix - Satan1c/ZZMI_tools GitHub Wiki

This is an ORFix.ini analog for ZZZ. It was made so that when modding ZZZ you no longer need to depend on hashed textures and to not break outlines/reflections/transparency with slots usage.

Important

This library included in ZZMI Package, avoid duplicates of it in Mods folder.

Support list

Texture placement; regular and in censorship.

  • Characters
    • Diffuse, NormalMap, LightMap, MaterialMap
    • GlowMap, WengineFx
  • Weapons
    • Diffuse, NormalMap, LightMap, MaterialMap
    • GlowMap, WengineFx; untested
  • World objects; partialy tested, majority of objects will work
    • Diffuse, NormalMap, LightMap
  • NPC
    • Diffuse, NormalMap, LightMap, MaterialMap; partialy tested

Terminology

  • Slots refer to things like ps-t4
  • Hashed textures refers to the practice of modding textures by having a [TextureOverride] section to match the texture's hash and including a line like this = ResourceCharacterPartDiffuse to set that hash to a new resource

Dependency

Depends on ZZMI Package's Resources.ini with registered resources, or their aliases

Resources list
  • Diffuse
    • Resource\ZZMI\Diffuse
    • Resource\ZZMI\D
  • NormalMap
    • Resource\ZZMI\NormalMap
    • Resource\ZZMI\N
  • LightMap
    • Resource\ZZMI\LightMap
    • Resource\ZZMI\L
  • MaterialMap
    • Resource\ZZMI\MaterialMap
    • Resource\ZZMI\M
  • GlowMap
    • Resource\ZZMI\GlowMap
    • Resource\ZZMI\G
  • WengineFx
    • Resource\ZZMI\WengineFx
    • Resource\ZZMI\W

Some characters have Glow effects without requirement to have signature w-engine, those effects will use GlowMap, and those only available with signature w-engine use WengineFx.

Matches.ini for detection of shaders, and SlotFix.ini to perform the operation of setting textures to the correct slots.

Use run = CommandList\ZZMI\SetTextures or run = CommandList\ZZMI\SetTex after setting your resources to execute.

Usage in mod .ini

Caution

Pass your resources with ref flag as presented below, to avoid performance impact.

Inside of a mod's .ini file, there are Texture Override sections for the IB hashes needed to override certain parts of a model. There will be a main section that typically is named with IB in it which should look like the following:

[TextureOverridePartIB]
hash = . . .
handling = skip

Next you will find another Texture Override section that should have the same hash = . . . value as the main IB from above. These typically correspond to parts of that IB which are handled differently from the rest of the parts in it. In this section, you will use the SlotFix Resource 'variables' to set the textures for this part as demonstrated below:

[TextureOverridePartA]
hash = . . .
match_first_index = 0

; optional if only modding with SlotFix
; needed only if you still need to mod some textures by hash
run = CommandListSkinTexture

ib = ResourcePartAIB

; place any Textures to replace
Resource\ZZMI\Diffuse = ref ResourcePartADiffuse
Resource\ZZMI\NormalMap = ref ResourcePartANormalMap
Resource\ZZMI\LightMap = ref ResourcePartALightMap
Resource\ZZMI\MaterialMap = ref ResourcePartAMaterialMap

; execute
run = CommandList\ZZMI\SetTextures

; drawindexed stuff comes after this
 . . .

; Repeat the same as above for other parts
[TextureOverridePartB]
hash = . . .
match_first_index = 322

 . . .

You can also make use of this for multiple texture changes in a single override.

Resource\ZZMI\Diffuse = ref ResourcePartADiffuse
Resource\ZZMI\NormalMap = ref ResourcePartANormalMap
Resource\ZZMI\LightMap = ref ResourcePartALightMap
Resource\ZZMI\MaterialMap = ref ResourcePartAMaterialMap

run = CommandList\ZZMI\SetTextures

drawindexed = 123, 0, 0

Resource\ZZMI\Diffuse = ref ResourcePartADiffuse
Resource\ZZMI\NormalMap = ref ResourcePartANormalMap

run = CommandList\ZZMI\SetTextures

drawindexed = 246, 123, 0

Tip

To prevent shaders re-match after restart, you can enable the shader cache in d3dx.ini, or with your own d3dx override file, by setting cache_shaders = 1 in the correct section

Tip

If the mod doesn't have a NormalMap, or doesn't have an adapted NormalMap, you can use the one included with the ZZMI Package, Resource\ZZMI\FlatNormalMap.

If the mod doesn't have an adapted GlowMap for glow or sig effect, to hide it you can use empty one included with the ZZMI Package Resource\ZZMI\EmptyGlowMap.

More concrete example of SlotFix usage

Usually textures are replaced by hashes which prevents any weird behaviour, but sometimes you can find mods with ps-t3-t6 slots being used instead.

Slots provide easy texture replacement and remove the first-load issue where modded textures don't immediately appear, but they often break a lot more things and may add constant stutters.

SlotFix allows mod authors to make use of slot replacement, but without the issues encountered with using slots, as if you were using hashes instead.

Before, with only slots

[TextureOverride Soldier0 HairA]
hash = 217ec790
match_first_index = 0
ib = ResourceSoldier0HairAIB

ps-t3 = Resource.HairA.Diffuse
ps-t4 = Resource.HairA.NormalMap
ps-t5 = Resource.HairA.LightMap
ps-t6 = Resource.HairA.MaterialMap
ps-t9 = Resource.HairA.GlowMap
; ps-t9 = null

; Soldier0HairA
	; BackBottom
	drawindexed = . . .

Before, with hashes (and some slots)

[TextureOverride Soldier0 HairA]
hash = 217ec790
match_first_index = 0
ib = ResourceSoldier0HairAIB

ps-t4 = Resource.HairA.NormalMap
ps-t9 = Resource.HairA.GlowMap
; ps-t9 = null

; Soldier0HairA
	; BackBottom
	drawindexed = . . .

[TextureOverride Soldier0 HairA Diffuse]
hash = . . .
this = Resource.HairA.Diffuse

[TextureOverride Soldier0 HairA LightMap]
hash = . . .
this = Resource.HairA.LightMap

[TextureOverride Soldier0 HairA MaterialMap]
hash = . . .
this = Resource.HairA.MaterialMap

After (using SlotFix)

[TextureOverride Soldier0 HairA]
hash = 217ec790
match_first_index = 0
ib = ResourceSoldier0HairAIB

Resource\ZZMI\Diffuse = ref Resource.HairA.Diffuse
Resource\ZZMI\NormalMap = ref Resource.HairA.NormalMap
Resource\ZZMI\LightMap = ref Resource.HairA.LightMap
Resource\ZZMI\MaterialMap = ref Resource.HairA.MaterialMap
Resource\ZZMI\WengineFx = ref Resource.HairA.GlowMap
run = CommandList\ZZMI\SetTextures

; Soldier0HairA
	; BackBottom
	drawindexed = . . .

Outlines

OG | Slots | SlotFix 1

ps-t3-6 slots are used by the 'Diffuse' shader, and as you can see the textures look the same; but, the 'Outline' shader uses a different order for the slots, so the Diffuse texture in ps-t3 slot will break things.

Textures in censorship

OG | Slots | SlotFix 2

ps-t3-6 slots, again used by the 'Diffuse' shader; textures are again the same, but the 'Diffuse' shader in censorship also uses a different slot order, so the LightMap texture in ps-t5 slot and MaterialMap in ps-t6 break things.

Battle glow

Slots | nulled t9 | During swap 3

By default the 'Glow' shader expects the glow texture to be in the t9 slot, so in order to hide the wrongly aligned texture you can null it with ps-t9 = null to remove it completely, or place the correctly aligned GlowMap, but only until you do a swap since the 'Glow' shader uses different slot order in swap.

⚠️ **GitHub.com Fallback** ⚠️