HOME | DD

StillANoob — SFM Tutorial: Proper transparency on hair

Published: 2019-05-05 20:26:10 +0000 UTC; Views: 6575; Favourites: 18; Downloads: 0
Redirect to original
Description

This was something requested, and this should also be helpful to some novice XNALara porters to understand why SFM users like me do this kind “weird shit” with models.

BE WARNED: If you do this, your hair is going to be missing Ambient Occlusion. But don’t worry, any model that uses transparency misses Ambient Occlusion anyway.

Preparations

You need to have Blender, of course. Blender is love. Blender is life. Its UI is garbage, but it’s also free

You also need to verify if your hair texture have an Alpha channel (transparency). If the texture have a transparency Alpha channel, proceed. If it does not, then you should close this tutorial and use a regular VMT, because this is useless.

We are also going to need 2 different material names: Hair_Alpha and Hair_Translucent. This means each hair model is going to have both Alpha and Translucent materials.

Ok, let’s begin. For this example, I’m going to use Menat’s hair. You can check that particular model here. So, we will begin with our model imported already.


Step 1: Hair check.

Substep 1: Mesh separation.

Before even attempting anything, you need to keep only the hair. There are models whose eyelashes and/or eyebrows are also part of the hair mesh. You do NOT need those. You only need the hair.

If you are using a Dead or Alive hair, you will notice you have two hair meshses for each hair. Normally, there are properly named, so just hide whatever mesh with a name convention you want.

I’m not going to get too deep into this. Just keep the hair.

Substep 2: Transparency Check.

Thanks to our verification, we realize Menat has 2 hair meshes, however, one of them doesn’t have a Transparency Channel that affects the hair. So we hide the one that doesn’t have a Transparency channel, and just keep the one that have it.


Step 2: Define the material.

Substep 1: Get a bit of help.

We can get a little bit of help using Blender to understand what the hell we are going to do. To get this help, put your cursor on the 3D Viewport and press the N Key on your keyboard. This will make a menu appear at the right of the 3D Viewport. Scroll down on that menu and you will find a check box called Backface Culling. XNALara users should know exactly what this is. If you don’t, well, you will see soon anyway. Do not check it yet.

Substep 2: Check face direction.

We are going to use Backface Culling to see which direction are our faces… facing. So, to do that, we are just going to check Backface Culling and notice the changes in our mesh. So click or unclick to your hearts content, but once you are done, we need to do the following.

Substep 3: Define the material accordingly.

This is where things will get a little confusing. I strongly recommend you to understand what Backface Culling does. In very rough terms, the front of the face gets draw on the Viewport, and the back of the face don’t. It’s like a drawing on a paper sheet: from one side of the paper sheet, you can see the drawing, but you can’t from the other.

With that in mind, these are the pointers for the material naming:

If your faces are getting drawn outside, then that hair mesh is going to have a TRANSLUCENT material.

If your faces are getting drawn inside, then that hair mesh is going to have a ALPHA material.

Once you have figured out which one it is, rename the material of that mesh as Hair_X, where X is either Alpha or Translucent. In my case, is Hair_Translucent.

You can turn Backface Culling off now. This is our Translucent Material. Now we need to do our Alpha Material.


Step 3: Prepare your second hair mesh.

Substep 1: Duplicate your hair mesh.

Since we need to have a second hair mesh, Duplicate your hair material, and then hide the original hair. We won’t need it for now.

Substep 2: Flip Normals.

Select the hair, and then go Into Edit Mode. Select All vertices, and then Flip Normals (you can press the Space Bar, then type Flip normals and select it from there).


Step 4: Get your second hair material.

DO NOT JUST RENAME THE MATERIAL ON THE FLIPPED MESH. If you do that, you will also rename every other material that shares that same name in the Project. So, what are we going to do is the following.

Create a new material. Name it Hair_Y (where Y is the opposite of your previous material). Remove the PREVIOUS material. This way you should end with just the material you created. In my case is Hair_alpha.

Step 5: Now join both hair meshes.

Do that. After having both materials ready, just join them. Once you join them, you should have just one hair mesh with 2 materials.

Now do this with every single hair mesh

VMT Setup

Now, the VMT setup can be whatever value you want to use, it’s your model anyway, however, there’s a basic setup that you need to follow.

Hair_Translucent Setup

VertexLitGeneric
{
     $basetexture "yourpath/Hair_Color"
     $bumpmap "yourpath/Hair_Nrm"
   
    $translucent 1
    $nocull 1

    $nodecal 1
    $ambientocclusion 0
    $no_draw 0


    $phong 1
    $phongfresnelranges "[1 1 0.5]"
    $phongtint "[0.1 0.1 0.1]"
    $phongexponent 5
    $phongboost 0.5

}


Hair_Alpha Setup

VertexLitGeneric
{
      $basetexture "yourpath/Hair_Color"
     $bumpmap "yourpath/Hair_Nrm"

    $alphatest 1
    $nocull 1 
    $nodecal 1
    $ambientocclusion 0 


    $phong 1
    $phongfresnelranges "[1 1 0.5]"
    $phongtint "[0.1 0.1 0.1]"
    $phongexponent 5
    $phongboost 0.5
}


The Bolded text are mandatory parameters. If you don’t use them, then this whole process was a waste.

You should also notice how the Phong values are the same in both hairs. The only things that you are free to change are the Phong values. I recommend you to check the wiki to understand how they work and the mess around with them to find a setup you like.

And that’s it! Why does this take so long to write, and the process is like fucking 2 minute long...

Related content
Comments: 3

MrJak120 [2020-03-08 05:20:43 +0000 UTC]

Well the hair shows blocky squares so idk if its the hair itself or i did something wrong

👍: 0 ⏩: 1

MrJak120 In reply to MrJak120 [2020-03-10 00:10:35 +0000 UTC]

Nvm fixed it

👍: 0 ⏩: 0

JavierTheOne [2019-05-05 21:04:26 +0000 UTC]

This is the famous hair tutorial?

👍: 0 ⏩: 0