Talk:BLS

From wowdev
Jump to navigation Jump to search

Permutations depend on shader and build. Ids are mostly derived from flags but sometimes also bitfields or other things. For ADTs contributors will be blending mode depending on WDT flags as well as mcly count, amongst others. For other shaders it is completely different. There is no formula across shaders, probably even less across builds.

The idea is that there should be at least 4 groups of shaders, where the permutation flags and numbers should be shared across the group. These groups are: md2 vertex shaders, wmo vertex shaders, m2 pixel shaders, wmo pixel shaders. This theory is indirectly confirmed as the total count of permutations inside each those groups is the same.

Permutations reverse engineered for vertex md2 Diffuse_T1

Based on Legion 21062 build

There are 96 permutations in this build for Diffuse_T1.

I consider first permutation to be 0 and the last one to be 95.

Additives 16 and 8 are mutually exclusive, only one of these values should be counted in final permutation number


Full formula to get right permutation number:

 48*disableFog + 24*enableShadowBand + 16*enableBoneAndFullMatr + 8*enableBone + flags

Fun fact, it seems, that even though 48 and 24 can be added together, they are mutually exclusive too. Thus these pairs of permutations are equal (48, 72), (49, 73)... up to (71, 95)

Additive

48 - disable fog

  • Disables out_fog from shader

24 - enable Shadowband

  • Enables vec4 vc_shadowBandMtx0[3]; in shader uniform buffer
  • Enables out float out_fog; as shader output
  • Position in such shaders is called shadowPos. Probably these are used for rendering shadows

16 - enable bone and full bone matrix construct

  • Enables vec4 in_boneWeights; input attribute
  • Enables uvec4 in_boneIndices; input attribute
  • If flag 1 is enabled - also enables in_boneOffset; input attribute, which is used as index into vc_worldView to get view matrix. Also (1 + in_boneOffset) is added to in_boneIndices before getting vc_worldView[in_boneIndices]
  • 4 in_boneWeights are multiplied by 4 vc_worldView[in_boneIndices] and added together to form world matrix for bone

8 - enable bone

  • Enables vec4 in_boneWeights; input attribute
  • Enables uvec4 in_boneIndices; input attribute
  • If flag 1 is enabled - also enables in_boneOffset; input attribute, which is used as index into vc_worldView to get view matrix. Also (1 + in_boneOffset) is added to in_boneIndices before getting vc_worldView[in_boneIndices]
  • Does same as additive 16, but discards values of in_boneWeights and uses only first vc_worldView[in_boneIndices.x] as world matrix for bone

Flags

1 - disable View matrix

  • Disables mat3x4 vc_viewMatrix in shader input

2 - enable clip plane

  • Enables vec4 vc_clipPlane in uniform buffer
  • Enables float out_clipDist as shader output

4 - Disable clamp between vc_matDiffuse and vc_matEmissive

  • Disables vec4 vc_matEmissive; in uniform buffer
  • Use vc_matDiffuse as color instead clamp((vc_matDiffuse + vc_matEmissive), 0, 1);

--Deamon (talk) 03:26, 4 April 2016 (CEST)