Pixel shader logic for mixing colors: Difference between revisions
No edit summary |
No edit summary |
||
Line 8: | Line 8: | ||
<code>vec4 submeshColor</code> - value for current animation and animation time from [[M2#Colors|M2Color]] (<code>M2Color.color</code> lands into <code>submeshColor.rgb</code>, <code>M2Color.alpha</code> goes <code>into submeshColor.a</code>). If [[M2#Colors|M2Color]] is not present in M2 file, this values is (1.0, 1.0, 1.0, 1.0)<br> | <code>vec4 submeshColor</code> - value for current animation and animation time from [[M2#Colors|M2Color]] (<code>M2Color.color</code> lands into <code>submeshColor.rgb</code>, <code>M2Color.alpha</code> goes <code>into submeshColor.a</code>). If [[M2#Colors|M2Color]] is not present in M2 file, this values is (1.0, 1.0, 1.0, 1.0)<br> | ||
<code>float transparency</code> - value for current animation and animation time from [[M2#Transparency|M2TextureWeight]]. If [[M2#Transparency|M2TextureWeight]] doesnt exists in M2 file, this value is 1.0<br> | <code>float transparency</code> - value for current animation and animation time from [[M2#Transparency|M2TextureWeight]]. If [[M2#Transparency|M2TextureWeight]] doesnt exists in M2 file, this value is 1.0<br> | ||
<code>mix(a,b,c)</code> - function that calculates result value as <code>a*(1.0-c) + b*c</code>. Same formula in different notation with less multiplications: <code>(b - a) * c + a</code><br> | |||
<code>vec4 meshResColor</code> - the combined color of several variables: | <code>vec4 meshResColor</code> - the combined color of several variables: | ||
* for M2 spawned from MDDF chunk of Adt: | * for M2 spawned from MDDF chunk of Adt: |
Revision as of 18:43, 30 August 2016
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.alpha
goes into submeshColor.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
mix(a,b,c)
- function that calculates result value as a*(1.0-c) + b*c
. Same formula in different notation with less multiplications: (b - a) * c + a
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;<br>
finalColor.a = meshResColor.a;
Combiners_Opaque_Mod
finalColor.rgb = tex1rgb * tex2.rgb * meshResColor.rgb;<br>
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
Combiners_Opaque_Mod2xNA_Alpha
finalColor.rgb = meshResColor.rgb * ( (tex1.rgb - tex1.rgb * tex2.rgb) * tex1.a + tex1.rgb * tex2.rgb);
finalColor.a = meshResColor.a;
Combiners_Opaque_AddAlpha
finalColor.rgb = meshResColor.rgb * tex1.rgb + tex2.rgb * tex2.a;
finalColor.a = meshResColor.a;
Combiners_Opaque_AddAlpha_Alpha
finalColor.rgb = meshResColor.rgb * tex1.rgb + (tex2.rgb * tex2.a * (1.0 - tex1.a));
finalColor.a = meshResColor.a;
Combiners_Opaque_Mod2xNA_Alpha_Add
Combiners_Mod_AddAlpha
finalColor.rgb = meshResColor.rgb * tex1.rgb + tex2.rgb * tex2.a
finalColor.a = meshResColor.a * tex1.a;
Combiners_Mod_AddAlpha_Alpha
float addMapBrightness = (((0.300000012 * tex2.r) + (0.589999974 * tex2.g)) + (0.109999999 * tex2.b));
finalColor.rgb = meshResColor.rgb * tex1.rgb + (tex2.rgb * tex2.a * (1.0 - tex1.a) + ((tex2.xyz * tex2.a) * (1.0 - tex1.a));
finalColor.a = meshResColor.a * (tex1.a + (tex2.a * addMapBrightness));