You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 18 Next »

Some workflows and information on texture creation for Overhaul.

Texture Naming and Sizing Notes

See parent page Overhaul Models and Textures for naming and sizing conventions. All files in an MTR file must be suffixed though with the appropriate ID (eg; _n for normal maps) even if the filename is truncated so script commands can work on each part of the MTR.

4x Upscaling Existing Texture DDS

This is a multi-step process, but reasonably simple, to obtain a upscaled PNG file.

  1. Crunch the DDS file back to PNG (this "flips" it)
  2. Run Cupscale with the models below in a chain (first one, then the other) for the texture (or set of textures):
    1. 1x_artifacts_bc1_free_alsa.pth
    2. 4x_BSRGAN.pth
  3. Save resulting PNG as the base diffuse (xxx_d.png) file.

Then you use this as the basis for the others, and if you need to scale back to 2048x2048 or smaller use Crunch to do it at the DDS stage.

4x Upscaling Existing Texture TGA or other

Same as above but you can avoid the Crunch step; just run Cupscale on the TGA file with 4xBSRGAN.pth model being run. It'll self-convert to PNG automatically.

Upscaling Textures with Transparency

This can be a big pain in the arse. Things like leaves or whatnot. Even icons. Some notes to follow and check out 4x Texture Upscaling pages for some attempts at formalising it.

Basically you need to use Pytorch mode and set the Alpha Mode in the options first. To save reading below use:

  • 2 - Channel Alpha
  • 8 bit transparency mode

For the purposes of at least basic icons there are some better options then the default "Differential Alpha" option:

Alpha ModeTested Use CaseNotesAlpha Layer Pictures
0 - DisabledAnything with no alpha channel usageMany NWN textures contain no alpha. Most tileset textures for instance, many GUI icons and textures, many feat and spell icons.
1-  Differential Alpha

This seems to be pretty bad, at least for icons (in this case id_good.tga), see picture for what the "Alpha" layer turns into! It should be all black but instead has some alpha all over the place.

Basically if we were using alpha more passively - like having wisps of smoke or the like, then it might be usable.

Most domains, feats, spells icons will not use this and instead use mode 2.

Will need to test it on some others.

ife_disarm.tga as the second example shows it is awful, since it's got lots of random transparency all over the icon.

2 - Separated AlphaIcons (feats, domains, actions)

This seems to work perfectly well for icons and the like where there is basically an icon in the middle, and alpha (tending to black) around it.

Example of the same icon which as a much better "small amount" of alpha fade at the edges and otherwise the middle is all opaque.

ife_disarm.tga looks ok - a little bit of transparency at the edges (here with 8 bit alpha on) - but it's got some weird harder edges compared to the other 2 options.

3 - Channel

This appears to be very similar to type 11, for icons at least. See id_good.tga to the right, again it moves some alpha into the icon which isn't present in the original.

The outer edges however are more nicely/gradually faded. Not that they have to be - the original icon is basically "opaque or not" alpha, with the outer edge not even being entirely black (although it kinda "fades to black").

The second example shows a slightly better case when used on ife_disarm.tga - seems better rounded parts and gives a better outline.

There is also an Alpha Depth option, using 2 - Separated Alpha, we have:

TypeNotesPicture
Full (8 Bit)

This is best for anything with fading alpha. IE not icons with a border, but for things like grass or whatever

Note the fade in the example icon - it's not bad if you want a little fading however!

Binary (1 Bit)

This may be quite good for alpha-with-a-border, ie things like icons

See example picture it gives a nice crisp edge.

Ternary (2 Bit)This isn't really suitable for anything in NWN. It's basically a worse 8 bit version, where pixels do have bits of transparency at the edge, but don't look as good/as smooth.

Converting to DDS

The intermediary file, usually PNG, could be TGA or another uncompressed format, can be converted using NWN Crunch: https://neverwintervault.org/project/nwnee/other/tool/nwn-crunch-enhanced-edition

There are some reasonable default cmd scripts but some edits are needed for doing:

  • Non-alpha using 4096x4096 textures with DTX1 - this compresses a lot better when you don't need that alpha layer
  • Converting dimensions downwards, such as making portraits smaller using one base large image
    • Note that we are generating mipmaps for portraits since we are also enabling mipmaps for them

See the SVN for these scripts. The autoflip = 1 should likely be on if you've converted the files originally from DDS.

Final DDS should be as close to the original sizes as possible, keeping under 15MB, see Overhaul Models and Textures at the bottom for notes on this but basically with alpha it is usually 2048x2048 maximum and without alpha it is 4096x4096 - although only needed on very large creatures like Dragons or Giants.

Existing Diffuse adding PBRs

The mainstay of content for the Overhaul to begin with will be using upscaled 4x textures with PBR additions.

Starting Tutorial: Using ShaderMap 4 (SM4) to Make Simple PBR Textures

If a creature is quite "dry" and "normal" we can just do a normal map. This adds some shadowing on the model where bumps are in the texture.

Using ShaderMap 4 we just simply add the image we want to create normals from, which will generate a basic normal map - to have it to NWN standards change the green channel to be Y+

(shamelessly from the tutorial above) Select the normal map then click the axis icon in the bottom left panel.

Next, click the box at the top of the green axis.

Click the checkbox to accept the changes.

This might be all you need to do - save the normal file as a PNG by right clicking on it.

You can also edit the intensity (usually the main thing to do) and the other options. Listing these on the creature model pages may be recommended to recreate it later (eg; if you change the texture size, or swap the texture).

For the specular you can use this to generate a good enough general spec map to later edit in GIMP or similar to change to NWN specifics. See Merrickdad's tutorial for most of this.

Specular and Roughness

These maps provide a shine to the object.

However it's not as simple as "just export stuff from ShaderMap 4" or any other tool, since:

  • You might want the entire model to be "shiny" (or wet) and the specular map isn't quite correct for that
    • This might just mean the spec/roughness maps are purely one colour, which simplifies things
  • You might want different levels of shiny - ie wet, metallic, reflective and so on
  • Environment maps may be needed to add some additional gusto
  • The changes to the original diffuse by having a roughness and specular map may mess up the colouring quite a bit

Specular maps:

  • This should be "how much it is shiny" - or "Specularity signifies just how much of the incoming light is reflected"
  • The values are 0-255 based on the RGB values - so a as the value goes toward 1 (white), this will also result in the material behaving as metallic. IE: White == maximum reflective, Black == not reflective.

Roughness maps:

  • Compliment specular maps, in so far as you can be shiny but not metallic which is where roughness comes in
  • should by themselves be enough for "shiny/wet" but doesn't seem to be the case on non-flat planes, or difficult diffuses so...have to use a specular too
  • It's again a Black-White 0-255 image. You'll want to have greys generally, White == maximum roughness and Black == no roughness.

Some experimentation is required here and for different types.

Using shader variables

This might be easier than having a ton of DDS files which essentially are one uniform colour. Saves a lot of disk space and file mess too.

Example MTR c_ettercap.mtr - the top two lines force normal maps and specular/diffuse compared to leaving them blank, taken from the PBR demo module (bit more on default shaders used here: https://github.com/mtijanic/nwnee-shader-tutorials/blob/master/tut/material-fragment-shaders.md ). The values though will just be uniform for the model, as if we produced an entire specular/roughness map which was all uniform white or black or grey.

customshadervs vslit_nm
customshaderfs fslit_nm
renderhint NormalTangents
// Textures 
texture0 c_ettercap_d
texture1 c_ettercap_n
parameter float Specularity 0.02
parameter float Roughness 0.1

Example code to change the values for testing - debug console - select the ettercap and apply.

    float fSpecularity = 0.02;
    float fRoughness = 0.05;
    SetMaterialShaderUniformVec4(OBJECT_SELF, "c_ettercap", "Specularity", fSpecularity);
    SetMaterialShaderUniformVec4(OBJECT_SELF, "c_ettercap", "Roughness", fRoughness);

Example values see here: Enhanced Lighting Engine and PBR

  • Specular: General rule of thumb of having about 0.02 for liquids, 0.04 for solids, except metals, which instead should have values close to 1.0.
  • Roughness: Highly polished surfaces will have about 0.05-0.1 and very rough surfaces like natural rocks, bricks and similar will be about 0.6-0.7.
  • Water:
    • Spec 0.02
    • Roughness: 0.1
  • Metal:
    • Spec: 1.0
    • Roughness: 0.0
  • Bricks:
    • Spec: 0.04
    • Roughness: 0.6

However having something that is "wet but solid" instead of water needs some testing. It sometimes also benefits from the diffuse file (main colours) being altered to remove shadows or lighten them up.

Some examples:

SpecularRoughnessPictureDescription
0.30.05

Generally a bit "wet" but not quite good enough
1.00.00001

A metallic mess (note setting Roughness to 0.0 seems to recalculate it as if it wasn't set)




There's a Metallicness value set in the shader too. We'll look at that another time...the shader defines it in inc_material.shd and seems to be auto generated anyway:

uniform lowp float Specularity;
uniform lowp float Roughness;
uniform lowp float Metallicness;

Default definition: fMetallicness = clamp(fMetallicnessModifier * fSpecularity - fMetallicnessMod, 0.0, 1.0);

Code to test:

    float fSpecularity = 0.02;
    float fRoughness = 0.05;
    float fMetallicness = 0.05;
    SetMaterialShaderUniformVec4(OBJECT_SELF, "c_ettercap", "Specularity", fSpecularity);
    SetMaterialShaderUniformVec4(OBJECT_SELF, "c_ettercap", "Roughness", fRoughness); 
    SetMaterialShaderUniformVec4(OBJECT_SELF, "c_ettercap", "Metallicness", fMetallicness);  


Environment Maps

These provide some colourisation information to the model where things are reflected. The textures alpha channel is used to modify the texture based on the environment map.

The default games version without PBR's is a bit lackluster.

The "default" option uses the texture file "chrome1"

This applies - as it looks like - a bit of a silvery-shine.

Needs further testing on how we replace this default or, well, how it works overall. Some aspects of implementation:

  • TXI (urg) can define it with EnvMapTexture
  • MTR can supposedly use Texture15 for it, this needs further testing
  • You can specify a texture filename in the appearance.2da entry (not a terrible idea, but only works for creatures not placeables or tiles)

Using Alpha as Specular

As noted above alpha layers are used for the environment mapping "shiny/reflective" surfaces. It'd be nice to get these converted over to PBR's though (which gives us some nicer control).

In GIMP you can go Alpha → Greyscale like this: https://graphicdesign.stackexchange.com/questions/155206/alpha-to-colour-value-in-gimp

  • Bucket Fill with Normal mode and  black colour all channels except alpha so RGB layers are black (do this by unselecting the alpha under Channels)
  • (optional but not really needed) Insert an all back layer below the now alpha only layer
  • Use "Behind" bucket fill with white colour on the alpha layer
  • Should fill it in with black being "no alpha" and white being "full alpha" more or less
  • You can now delete the alpha layer; select the layer, right click and then select Remove Alpha Channel:

Now it's ok but might not be to what specular maps should be (where white == shiny). This is because the NWN envmaps overwhelm the colour and so fully alpha would mean, basically, full environment map replacement, which is really bad.

We want to extend the colours so black stays black, and greys become more white. Most of the time the non-alpha black bits are all the non-metal parts (eg wood, skin etc.) so it's pretty safe assumption the even dark grey bits are meant to be shiny.

I've found that Colors → Exposure works well. Put black level to 0.1 (maximum) to keep the blacks and the Exposure upwards, say to 2.0 or so. Going a little higher can really push the whites. Over 3.0 and it tends to white out everything on the example below. 2.0 seems to be fine in game for our purposes.

Then convert with Crunch and bingo (here with a normal map from Shadermap 4):

Note the diffuse has been passed in as DXT1 to remove any alpha (and lower the DDS size, they tend to get quite big at 2048 size).

  • No labels