Blend mode overrides (vertex alpha-like effect)


TUTORIAL: BLEND MODE OVERRIDES
ge7nStK.gif

(I'll try to update this tutorial often with new information)

In this tutorial I'll show you how the blend mode overrides work in WotLK (or "vertex alpha" as some people mistakenly call it).
This system was implemented in the Burning Crusade, but Blizzard has been using it heavily since Wrath of the Lich King.

2MG3Yic.jpg

Basically, the game loads two textures for a single texture unit, allowing you to use one of them as an opacity mask to avoid hard cuts. You can make many awesome effects:
U0qdSXF.gif
(It's just a few planes with texture animation and a texture mask on top)

It's an advanced model edit. We don't have the right tools and the documentation is almost non-existent. However the result is really satisfying and it's actually possible to do it by hand.
Before starting, keep in mind that this system is not well documented. Most programs like Blender or PyModelEditor can break your model if you load them after applying this effect, so, leave the blend mode override for the last.

TOOLS
-PyModelEditor.
-010editor + wow templates.
-IMPORTANT: "Second UV channel creator" script.
-My test model.

THE TUTORIAL
1) Open your model with PyModelEditor:
-Open your model in PyModelEditor and create a texture animation. You can follow my TUTORIAL.
-Then, add the texture with the mask. In this case, we will use this one: World\TexAnimPlaneTest\BlendEffect.blp (included with my test model). It is VERY IMPORTANT that the texture with the mask is bellow the main texture.
You can now save your model and close PyModelEditor.

2) Open your model with 010editor:
-The main problem when trying to apply this effect is that your model must have a second UV channel. I made a script that clones the first UV channel into the second slot. Open your model in 010editor and run my "Second UV channel creator" script. If your model has blend mode overrides activated but doesn't have a second UV channel it will look invisible in-game.
Note: make sure you are working on "OVR" mode before running the script. You can change it by using the Insert Key or by clicking INS/OVR in the status bar.
-Change the renderflag that your model will use to additive alpha (4) or blend (2). Otherwise, the new blending mode won't work (will look black).

3) Now is when this starts to get complicated:
-Go to the header and change the GLOBALFLAGS to 8. When you do this, the blend mode override activates.
-Run the m2 template again and you should get an error message. Load the model anyway. Go to the bottom and a new block called "struct new_mapping" should appear:
CBadwj7.jpg

Go to the bottom of your file and write a line of "0". Copy the position of the line. In my case it's "1312".
In "nAltMapping" write "2". In "ofsAltMapping" write the position of the line you just wrote:
AoPFsVR.jpg

Run the m2 template once again and it should load correctly. Two new lines will appear under ofsAltMapping. Write "1" in the first one and "4" in the second:
ZQ9MfQ0.jpg

4) Go to TexAnimLookup. There should be two TexAnimLookup: -1 and 0.
The first one controls if the first texture moves. Replace -1 with 0 to make it animated.
The second line controls if the mask texture moves. Replace 0 with -1:
tCOPX8F.jpg

5) Open your model SKIN with 010editor:
-Go to texunits and change the D4 of the mesh with blend mode override to 2. This will force the game to load 2 textures for that tex unit. It will load the one referenced in the skin and the one bellow in the M2 list (texlookuptable).
-In "texanimid" there should be a 0.

yzUrlqH.jpg

You can now test the model in-game. It should look like this:

T76H4FK.gif

As you can see, it uses the opacity of the second texture and it doesn't affect its texture animation. Without the blend mode override system it's impossible to make something like this.
Feel free to play with the texture and create new effects.
Remember that the mask texture must have an alpha channel or your model will look black.

If you want to download the mask texture I used for THIS image, you can download it HERE.

TL;DR VIDEO

EXPLANATION
If the GlobalFlag of your model is 8, the game triggers blend mode override for your model.
You activate the blend mode override in the .skin file, by changing the D4 of your desired texunit to "2".

When the GlobalFlag is 8, the way your M2 works changes completly. The order of your textures becomes relevant.
The order of your textures will start to be read in pairs. Here is an example:

eYOKmIZ.jpg
 

Also, the order of "TexAnimLookup" should mirror the order of "TexLookupTable". The ID 0 of "TexAnimLookup" controls the texture animation of the texture with ID 0 in "TexLookupTable". I know it's kind of complicated, but play with it for a while and you will find out how it works.

The values you write in nAltMapping (1; 4) are the renderflags of the blending mode. It means that the base texture will be applied as additive alpha (4) over the opacity map (1). If you think it looks too bright, change it to 1,1.

MODELS WITHOUT HEADER SPACE
Some models don't have space in their headers for the blend mode overrides extra block, therefore it overrides the model name data.
What you can do in this case is opening the model in PyModelEditor and then saving it. Every time PyModelEditor saves a model it remakes the header from scratch and adds some free space for the extra header.
However, the model name block is not necessary. You can just override it with the "new_mapping" block if needed and it won't cause damage to the model itself.

UV CHANNELS
If you want to create a custom second UV channel, download THIS SCRIPT I made.
As you can see, it copies the UV channel 1 of a second model to the UV channel 2 of your first model:
93Wq55E.jpg

The idea is simple: make your model. Then clone it, modify its UV map in Blender and copy it to the second UV channel of the original model.
This second uv channel method is used in many models, such as the fire coming out of Agrammar's eyes. You can map geometry into existing or smaller textures without having to create a new one.

Here is an in-game example of a model with two different uv channels:
DDgV8uC.jpg
After the script, the second uv channel is smaller and centered around the heart shape, but the first one along with its texture remains intact. The result is a bigger mask, leaving the original texture and UV untouched.

IN CATA, MOP, WOD AND LEGION

If you want to use this system in Cataclysm or Mists of Pandaria, the process is quite the same. Some steps are different.
(Thanks to Soldan for giving me some information)
-Instead of changing the GLOBALFLAGS to "8", you should put "128" ( or "0" if your model doesn't cast shadows). The "struct new_mapping" block won't appear, and it's not necessary, so you can skip the Step 3 completely.
VYDviww.jpg

-Additionally open the .skin file, go to the texunit with blend mode overrides and add "16401" to the "order" field (aka "shader"). That number replaces the "struct new_mapping" block.
nPQ6RNL.jpg

If your model looks too dark, put "16404" instead, and it will look brighter.



Recommended Comments

This is what i get XD, i did all the steps but i think i failed in this one:

"Then, add the texture with the mask. In this case, we will use this one: World\TexAnimPlaneTest\BlendEffect.blp (included with my test model). It is VERY IMPORTANT that the texture with the mask is bellow the main texture. "

Should I take the step that the image shows, but instead of world\TexAnimPlaneTest\TexAnimPlaneTest.blp should be World\TexAnimPlaneTest\BlendEffect.blp ?.

Nice tutorial :D!

7cv1Rke.jpg

WoWScrnShot_110517_234153.jpg

Share this comment


Link to comment
Share on other sites

thanks for the tut friend

never thought someone will do a tut for blending animated textures

Share this comment


Link to comment
Share on other sites
On 6/11/2017 at 1:51 AM, Zehlendorf said:

Should I take the step that the image shows, but instead of world\TexAnimPlaneTest\TexAnimPlaneTest.blp should be World\TexAnimPlaneTest\BlendEffect.blp ?.

 

I added a VIDEO to the tutorial. Check it out!

Share this comment


Link to comment
Share on other sites
18 minutes ago, Zehlendorf said:

I do all the steps :c.

That happens when your model doesn't have a second UV channel. Check if you are running my script correctly.

Share this comment


Link to comment
Share on other sites

yeah that's is my problem, when i try to run the script it says "*ERROR Line 6: Function 'ReadString' can only be executed when the script is being run on a file."

Share this comment


Link to comment
Share on other sites
22 minutes ago, Zehlendorf said:

yeah that's is my problem, when i try to run the script it says "*ERROR Line 6: Function 'ReadString' can only be executed when the script is being run on a file."

That's because you are running the script on the script file itself and not on the model.
-Open your model. Open the script.
-Click on the model tab (as i did in the video).
-Run the script.

The log should say "Success! Second UV channel created!".

Share this comment


Link to comment
Share on other sites

Ok i got that log " Success! Second UV channel created!" but when change the values in struct new_mapping and try to run the m2, got this error "*ERROR Line 427: Template passed end of file at variable 'nValues'. "

Share this comment


Link to comment
Share on other sites

I think the script it's not working like the one in the video or well this happen to me, because the last lines are not the same.

 

error.jpg

and I add the 00 line like the tutorial, change the values in struct new_mapping,  execute the template and got this:

error2.thumb.jpg.d5afc4a5f0a4df3e9d3f8ae

 

Share this comment


Link to comment
Share on other sites
48 minutes ago, Zehlendorf said:

and I add the 00 line like the tutorial, change the values in struct new_mapping,  execute the template and got this:

 

It says there is an error in line 427 (something related with timestamps, not with the script of the blend mode override). I don't know what did you do, but your model has 4 more lines than mine, and there seems to be something broken in an animation (since the model doesn't have animations I guess it's related to the texture animation).

Share this comment


Link to comment
Share on other sites

before running the script I have up to the line that is seen in the image, is that correct?

i really wanna get this working, just for learn lel xD

 

error3.jpg

Share this comment


Link to comment
Share on other sites
12 minutes ago, Zehlendorf said:

before running the script I have up to the line that is seen in the image, is that correct?

 

You can run the script wherever you want. The position you are on doesn't matter.
Do this:
Run the M2 template. If everything loads fine, run the script and reload the M2 template. If the script gives you an error, send me the model. If it loads fine, start doing the blend mode overrides stuff.

Share this comment


Link to comment
Share on other sites

I apparently failed to actually send my comment before (or am too stupid to find it now): 

This description of that block is way better than what's on wiki. Care to better describe it there? It would be appreciated.

Share this comment


Link to comment
Share on other sites

it works! the problem was :

I had my  010 editor in INS, just click on it and it changed to "OVR" and all worked fine. Thanks alot to Inico.

mGq8tK6.jpg

WoWScrnShot_110717_183608.thumb.jpg.6059

Share this comment


Link to comment
Share on other sites
On 7/11/2017 at 8:40 PM, wungasaurus said:

This description of that block is way better than what's on wiki. Care to better describe it there? It would be appreciated.

To be honest, I don't know how the wiki works, and the information is quite messy. I don't know where to start and don't want to break anything. Feel free to add it if you want, I don't need credit ^_^.

On 11/11/2017 at 8:00 PM, Смердокрыл said:

Any plans on a similar tut for Cata+ expansions?

Just added it to the tutorial.

Share this comment


Link to comment
Share on other sites
23 hours ago, Aurarius said:

I tried everything on a weapon but it comes out unchanged or invisible.

It's difficult to help if you don't give information at all.
As stated on some comments above yours, if a model is invisible, it doesn't have a second uv channel. If it has a second uv channel and it still looks invisible, you are corrupting the file somehow (and there are a thousand ways to break a model).

Share this comment


Link to comment
Share on other sites

For example a bird, the body is a normal texture, the wings are the texture animation.

Share this comment


Link to comment
Share on other sites

Rly nice tutorial with the materials and your script/testobject. I bring it to work, i dont understand yet all but i will if i need.^^

It helped me by a nonanimated problem. And now im sure i can do this with most models if they have this. Before this i made extra meshes and gave them renderflags.Now with masks, it will be much finer/easier and cooler^^. So just a big thx :)Thx.jpg.dce90556e12aba0dcfc9434ec02a49f4

Share this comment


Link to comment
Share on other sites
3 hours ago, jy02339377 said:

我用官方武器的模型作为模版,自定义创作了一把武器,并把武器进行了放大,但是完成后发现:模型自带的魔法粒子效果位置发生了偏移。请问这个问题怎么解决,谢谢!

 

翻译:I used the model of the official weapon as a template, created a weapon by myself, and enlarged the weapon. However, after the completion, I found that the position of the magic particle effect of the model was shifted. How to solve this problem, thank you!

 

Share this comment


Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now