niftools / nifxml

A repository for the nif.xml file, which contains the nif file format description.
http://www.niftools.org
GNU General Public License v3.0
37 stars 43 forks source link

BSEffectShaderProperty - Texture Names #44

Open hexabits opened 9 years ago

hexabits commented 9 years ago

(Edit: Forgot this part was included in #41) It seems that nearly all values for this are 65283 (0xFF03). I'd like to find examples that are not though.

I'm not sure if the FF part is really part of the texture clamp mode, since the 03 part matches up with TexClampMode type in nif.xml. WRAP_S_WRAP_T (3) is the most common value.

However the storage type of TexClampMode is uint so it is meant to take up that many bytes and therefore it can't be used with BSESP.

There is a small chance the extra data has to do with the second texture. I have just figured out that the "Greyscale Texture" is actually set to mirrored repeat. It has to be with the way the texture is used as a LUT, or when the sampler gets values near 0.0 or 1.0 there are artifacts.


Speaking of, I feel the names for the textures are wrong. "Greyscale Texture" is actually what the "Source Texture" should be called. The color in the "Source Texture" doesn't actually matter as only the green channel is taken into account. I've tested and confirmed this. So, generally, the "Source Texture" is meant to be greyscale.

The "Greyscale Texture" is best called a Palette Texture, or Lookup Texture. The reason is because it is used as a LUT (look up table) given the "Source" texture as input. This is only if using SLSF1_Greyscale_To_PaletteColor/SLSF1_Greyscale_To_PaletteAlpha. Note the name... Greyscale to Palette.

hexabits commented 9 years ago

@ttl269 Sorry, I didn't notice #41 included the first part of this ticket. The second part still applies.

hexabits commented 9 years ago

Also, you can see what the Effect Shader does mathematically speaking here: https://github.com/jonwd7/nifskope/blob/ac00f5c4c7c16a2ebb262325fc8504eb47a192cd/res/shaders/sk_effectshader.frag

I agree with your name changes, especially considering how they line up with the shader math.

Note that when "Greyscale to Color" is used, only the Red value of the Base Color Multiple is used.