Pixel shader logic for mixing colors

From wowdev
Jump to navigation Jump to search

WoW combines colors of textures in shader. The actual formula used depends on shader used.

Symbols

vec4 tex1 - color from first texture
vec4 tex2 - color from second texture
vec4 submeshColor - value for current animation and animation time from M2Color (M2Color.color lands into submeshColor.rgb, M2Color.color goes into M2Color.a). If M2Color is not present in M2 file, this values is (1.0, 1.0, 1.0, 1.0)
float transparency - value for current animation and animation time from M2TextureWeight. If M2TextureWeight doesnt exists in M2 file, this value is 1.0
vec4 meshResColor - the combined color of several variables:

  • for M2 spawned from MDDF chunk of Adt:
  • for M2 spawned from MDDF chunk of WMO:
    • if M2 is contained:
    • otherwise:

vec4 finalColor - the result of combining

M2 shaders

Combiners_Opaque

finalColor.rgb = tex1.rgb * meshResColor.rgb;
finalColor.a = meshResColor.a;

Combiners_Decal

finalColor.rgb = (meshResColor.rgb - tex1.rgb) * meshResColor.a + tex1.rgb;
finalColor.a = meshResColor.a;

Combiners_Add

finalColor.rgba = tex1.rgba + meshResColor.rgba;

Combiners_Mod2x

finalColor.rgb = tex1.rgb * meshResColor.rgb * 2.0;
finalColor.a = tex1.a * meshResColor.a * 2.0;

Combiners_Fade

finalColor.rgb = (tex1.rgb - meshResColor.rgb) * meshResColor.a + meshResColor.rgb;
finalColor.a = meshResColor.a;

Combiners_Mod

finalColor.rgba = tex1.rgba * meshResColor.rgba;

Combiners_Opaque_Opaque

finalColor.rgb = tex1.rgb * tex2.rgb * meshResColor.rgb;
finalColor.a = meshResColor.a;

Combiners_Opaque_Add

finalColor.rgb = tex2.rgb + tex1.rgb * meshResColor.rgb;
finalColor.a = meshResColor.a + tex1.a;

Combiners_Opaque_Mod2x

finalColor.rgb = tex1.rgb * meshResColor.rgb * tex2.rgb * 2.0;
finalColor.a = tex2.a * meshResColor.a * 2.0;

Combiners_Opaque_Mod2xNA

finalColor.rgb = tex1.rgb * meshResColor.rgb * tex2.rgb * 2.0;
finalColor.a = meshResColor.a;

Combiners_Opaque_AddNA

finalColor.rgb = tex2.rgb + tex1.rgb * meshResColor.rgb;
finalColor.a = meshResColor.a;

Combiners_Opaque_Mod

finalColor.rgb = tex1rgb * tex2.rgb * meshResColor.rgb;
finalColor.a = tex2.a * meshResColor.a;

Combiners_Mod_Opaque

finalColor.rgb = tex1.rgb * tex2.rgb * meshResColor.rgb;
finalColor.a = tex1.a;

Combiners_Mod_Add

finalColor.rgba = tex2.rgba + tex1.rgba * meshResColor.rgba;

Combiners_Mod_Mod2x

finalColor.rgba = tex1.rgba * tex2.rgba * meshResColor.rgba * 2.0;

Combiners_Mod_Mod2xNA

finalColor.rgb = tex1.rgb * tex2.rgb * meshResColor.rgb * 2.0;
finalColor.a = tex1.a * meshResColor.a;

Combiners_Mod_AddNA

finalColor.rgb = tex2.rgb + tex1.rgb * meshResColor.rgb;
finalColor.a = tex1.a * meshResColor.a;

Combiners_Mod_Mod

finalColor.rgba = tex1.rgba * tex2.rgba * meshResColor.rgba;

Combiners_Add_Mod

finalColor.rgb = (tex1.rgb + meshResColor.rgb) * tex2.a;
finalColor.a = (tex1.a + meshResColor.a) * tex2.a;

Combiners_Mod2x_Mod2x

finalColor.rgba = tex1.rgba * tex2.rgba * meshResColor.rgba * 4.0

WMO shaders