This shader allows mixing PLT and TGA/DDS textures on dynamic PC parts. It also allows PLT to have transparency. (now updated for 8193.37-15)

(Shader currently located at https://neverwintervault.org/project/nwn1/other/visual-effect/merricksdads-plt-mixer-shader-ee-only)

How it works

The shader loads in two more textures.

The first texture goes in material texture6 and includes a mixing mask. Only the red channel is used, so you can make a black and white image to serve as the mask. I've given this mask a suffix of _m in the filename.

The second texture goes in material texture7 and includes an override texture and alpha channel. I've given the override texture an _o suffix.



Mask: texture6Override: texture7 (RGB channels)Override: texture7 (alpha channel)

The shader code takes the alpha from texture7 and applies it to the original PLT for lighting purposes.

It then uses the mask luminance as a mixing factor. The new texture applied to the armor part will be 100% PLT where the mask is black, and 100% texture7 when the mask is white. Any gray shade will be partial mixing using:  Total = (texture6.red * texture7) + ((1.0 - texture6.red) * PLT).

The shader then grabs the alpha from texture7 again and makes sure that the final alpha matches the alpha in texture7 (multiplied now by the mask texture value), discarding values below 20% as in the OC content. (this can be modified in the shader code).

Example MTR File

customshadervs vslit_nm
customshaderfs fslit_mixplt
renderhint NormalAndSpecMapped
texture6 pmh0_chest010_m
texture7 pmh0_chest010_o

The Test Module

The included module and hak only contains the shown texture override and mask. These are for human male chest armor 10. The module contains a corrected version of the chest model with the correct texture applied in the correct orientation.

Simply pick up the armor on the floor with a human male and put it on to see the effect.

You can even see it render correctly in the toolset.

Making your own

To make your own, simply clone the MTR file in the HAKand change the file names for texture 6 and 7 to match your own mask and override textures. Save your MTR file to match the texture associated with an armor part.

The mask and override texture need not match the name of the PLT texture, but the MTR file must match the PLT texture. Check the BITMAP line in the model to see which PLT will actually be called by the part model. It is not always the same as the model name.

Paint the mask texture white wherever you want to apply the texture override. Paint it black where you only want PLT texture and its associated color. Any gray value will mix the two.

Make sure to include an alpha channel in your override texture if you want one. Alpha channel will be applied no matter what the mask texture says for that region.

Include the files fslit_mixplt and inc_pltmixer in your HAK, or put them in override or development while building.

Make sure your custom MTR file is named the same as the PLT requested by the MDL file, and that the MTR file includes the "customshader.." lines at the top.


Enjoy