# Tutorial:
https://www.youtube.com/watch?v=hvNcRaPmWoE&t=12s&ab_channel=JHill
# XGEN
Make mesh - circle or whatever
Duplicate it and call it scalp. Basically this is just to old the hair textures, you can make the scalp not renderable so in the side click the arnold drop down and untick all the visibility ticks. (the hair will be rendered just the scalp wont.
You cant have udims for groom so all textures need to be 0-1 (the basic square on the texture map)
Now we need to attach a groom to this.
Go to generate and create a description
you can have multiple collections in a description
you can also have multiple collections
so name the first one character_desc and then under collection - hair, then click shaping guides and ok
then go to the xgen tab at the top and clck the +hair symbol and click the area youwant the guide. you can scale this normally to make it longer or shorter. to move/shape them press the icon that looks like an x but has arrows
(press b middle mouse and drag and you can make the brush bigger)
this line is made up of points, you can add resolution to this. on the side it says guide tools/ rebuild click and up the number to get a smoother result.
you want to add all the hairs before you rebuild them so that they are the same.
you can click a hair folical and press control and move it.
then to get actual hair, increse the density, for a full hed of hair put it up to 200
then change the width to make it thinner and then alter the width ramp the far left corner is the root of the hair and the right is the tip.
then click with the anti ailiasing button to see teh hair better
once you arrange the hair, you can add clumping and noise from the modifiers (on the side and click the +) then click clumping (youll get an error initially) then to the side of it click set up maps. contatntly go back and forth with the generate clumps (mess with the desity and click generate) to try and get the best outcome.
then add another modifyer - noise
make the frequency 2 and magnitude 1
sometiems when you mess with this the hair vanishes, you just need to go back to the follicles and go to modify cv count to it becuase it meant that there is not enough hair.
next we are creating maps.
go to desnity and underneath it there is Mask arrow down, click and press add mask and type in denisty mask and click blacj and type 40 ( higher for eyelashes)
then double click the paintbrush on the left in the tool bar and you can start painting the white mask. the hair will show in the white areas once you click the save near the mask.
if you paint with blurr it will have a smoother tranasition
# Udemy course:
 anti aliasing
 ambient occlusion
split into sections:
fibre generation - xgen
bakes - Arnold
Card creation - maya
shader setup - marmoset and UE5
create a plane
name it xgen plane
go into xgen tab
click the Xpannel on the left, this will onpen up a tab on the right showing descriptions.
Click new description (you can also do this by going to generate/ new description at the top)
 this adds hair (guides)
 this replicates the hair when you press it
the four orange hairs are the ones I placed and then when i clicked the eyes they replicated (the brown ones)

right click guide control points you can move and shape them

when you click the eye again after shaping it, then the hair will try interpolate between the moved guide and the remaining guide.
difficulty selecting plane go into object mode and, turn off geometry (the diamond)

when adding density to the hair the programme might slow down so go to prewier/output (near primatives) and change the percentafe
you can also change the length in the primnatives section, it will still try to adhere to the shape of the guides and add length accordingly
and then we can change the width
width ramp is tapering

bumped up the modifyer CV up to 10 to make it smoother
messed with the width ramp to get a taper (the R stands for Root and the T for tip) and then moved the taper slider up to 0.5 to get it thin at the end
also turned on ambient occlusion and anti aliasing
Then add the sky dome in arnold and add the hdri to it
CRTL-A attribute editor and change the scale to 0 to eliminate the HDRI picture
click the resolution gate button to frame it when rendering 
# removing noise from hair
go to render settings 
and then scroll down to image size and change the presets and chancge it to 2k square


then you need to denoise it so go to display settings in the arnold renderer (the cog on the side)in the post section click the drop down and select denoiser optix

then go into the render editor again and the sub heading arnold renderer and in sampling change the camera number to 5 and the rest to 3

then go back to the render settings in system change the render device from cpu to gpu. be sure to add a material to the hair before doing so (assign aistandard hair)

for now its black but there are presets to pick from
if i click ctrl A and under presets on the side click blond and press replace

(you can remove the denoiser for the blond and you might get a better effect)
if i hit the light and can see what it looks like in the view port its a quick preview thing

# modifiers
go back to the xgen editor and click modifiers
and click the + and click noise
and mess with the settings

hairt with the optix shader inb the renderer
-------------
making hair charms
make a plane
adjust the size and the bend it from the deform section at the top non linear/bend. middle mouse and drag to create curvature. rotate the curve and bend it forward to generate the curve. (you might need to unlick the curve first)
create the bend you want
rotate it,
delete history and freeze transformations
move it up, create a cube and make it 14 cm (input 14 on the Y)
make a mask on the side and make it a black mask. once you click on the paintbrush change the colour ro white
add modifyers like noise and cut
cut makes the hair at different lengths adgust the amout from like 0-5 cm
add like 0.2 coil
creating these maps:


alpha
when rendering the hair add a sky done and then turn the camera visibility in the atttribute editor all the way downso we can see the strands better
once done assign the hair ai standard hair shader and then chang the preset colour. then on the attribute editor change the melanin (which is the pigment)

when saving your lapha from the renderer make sure you save as .tga
to extract an ambient occlusion map, select the back plane and the three xgen hair things and assign a new material - ambient occlusion, you can save this as a jpg

next is the depth map-
we need to create a C depth pass
open up renderer tool and click AOV's and the press the Z option and move it to the right (double click it) and then render again
then in the renderer where is says beauty, click it and press the Z option, then the scene again. this may look like nothing happened coz it turned white but if you go to the pixle menue on the righ and hover over the render port then you will see the values on the right changing.this is becuase at the momnet it is super exposed. so go to the tab next to it saying display and we need to tweak the settings.
- lower the exposure all the way down.
- change the view transform to RAW so we can see the colour
- then mess with the gamma so you can get an image like so:

- to save this you first need to go to save image option and select apply gamma exposure the just save the image normally like before as a jpg
we need to fix this map in photoshop and make the stranfs of hair closer to us white and the ones further away black (at the moment its the other way around) so when in photohsop press ctrl I.
then press ctrl L and play with the levels to get them looking a bit better so you can see the whites/ mid greys and blacks. then just save as jpg. should look liuke below

make sure you set the gamma back to 1 and the otherone back to 0 and change the setting back to acer from raw.
Normal map:
assign new material to backgrounf plane and your hair - aiutility node
in attribute editor change the shademode to flat
change colour mode to - normal
then just render it
change the view transform in display on the side to RAW

direction map:
using the same utility node as the normal map but we are changing the colour mode to v surface derivative
exposure in the renderer need to be RAW also
object ID:
Hide the background plane
keep the utility node again and change the colour mode to Uniform ID.

the result is colourful but we need this to be black and white so we need to import this into photoshop and press CTRL SHIFT U and the image will become desaturated.
Root map:
change the background plane to lambert
change the hair to ai Flat
basically we need to give it a gradient from top to bottom and to do this we need a ramp.
on the side click the checkered box where it says colour and press ramp
just save then
# Creating hair cards
create a plane make it upright facing front and remove all subdivisions.
assign a basic lambert material to it
then click the chequered box on the right where it says colour and select file and then go to images and select the colour alpha .tga then if you press 6 on your keyboard your hair will show.
then in top pannel that says polymodelling press the cut tool
and split the hair up into their designated 3 sections and then cut horizontally close to the roots and the tips to remove the extra space. also add a line in the centre of the hair cards (i didnt add it on this pic but do it) then insert lines as subdivisions too and then go to edit mesh and detatch. (if its gglowing yellow and orange soft selection is on so double click the selection tool and unclick soft selection)

nect we need to limit the amount of blank space in the hair texture and we need to moive it without moving the hair so double click the move tool to open the settings and click preserve UVs. so then move the vertices as close as possible to the hair. then once done move the middle hair line a little bit forward so that its not flat.

then select all edit mesh and separate so that theyre their own piece. make the pivot point in the centre middle of each one
on now import the hdri with the sky dome and change the ACES 1.0 to untone (at the top of the view port of the right) take off the background by changing the x,y,z value to 0and turn on ambient occlusion, anti aliasing and the lightbulb.
make a triangle with the hair thick hair cards to make the base

basically we need to make this fit the charm but we dont want to shrink it so use soft selection (press B) and then select the vertices and scale in
then arrange it and duplicate it and re arrange again.
then go to the renderer (the viewport one) and click the box near viewport. where it says transparency algorithm - object sorting change it to depth peeling. it makes it look much nicer. basically with object sorting maya tries to determine which object goes in the front and which goes in the back. whereas depth peeling makes it viewed as one whole object
should end up like this once you add it all ogethert:

didnt want to download marmoset
----
for your character you need to plan out what you have.
so you need to plan the hairstyles out beforehand
if you have a goateee then slpit it into the sections you need eyebrows etc
back into maya
use a dummy
create/ measure tool/ distance. this helps you gague how big sometyhing is in maya
start setting up the sheets, create a cylinder an then delete half of it, and then duplicate them,
add the hair
add noiuse
add clumping- then click set up maps to actually add the clumping, click guide so that each quide works as the origin for clumping and save
you can export a description and then import it for the next hair card so the settings are the same and saves time, allthough we need to experiment with this as it wasnt coming the same. the gat the smae hair texture assign existing material and itll be like hair 1 or something

when creating the otyher wones dont forget to taper the hairs also add cuts

fo rthe eyebrow descriptions make sure they are facing up rather than down like before,
when creating the eyebrows (4th vid on the second section) make sure there are fewer, thickness up and make the mask linear rather than circular. make them different lengths (use cut also) and make the hair nodes slanting.


for the actual hair becuase we are creating whispy hair, when you clumy just ress generate when you set up maps so that its more random and then add some noise
when copying and pasting a description and you need to match the hair colour make sure you select the description from the tool box and then assign hairphysicalshader1.
once all the hair parts are done.
we need to clean up the hypershade becasue there are a bunch of unused nodes. so first select all the descriptions and right click them in the view port and assign existing material - hairphysicalshader1 and then go into the hypershade and click edit delete unused nodes.

# baking hair maps
assign new material arnold standard ai hair
go to presets and make it black and then reduce the melanin.
then add a skydome light
when creting a roughness map, open photoshop and import the diffuse map and the object id map, place them on top of wachother with the object id on top and apply multiply to the layer
you can create another version and make it a brown and using a soft brush paint the roots as it is usually darker at the top
creating a specular/roughness map
new page in photohsop 2048/2048 pixles make it black
add noise (filter add noise) tick monochromatic and put it up to like 40%
the add another filter/ blur/ motion blur and make it 90 degrees and push the distance up like half way

# placing the hair on the cards and on the head
import model
create a plane
make the subdivishions 1

select it and at the top click UV/ Planar (press the box near it) and map it on the z axis so the uv map will look like so:

modify it like this:

assign it a lambert material then import the diffuse map onto the plane
baseically with the way we set up the map we can now move it around in the uv editor to fit each slot of hair like so:

once you get them all sorted,
then give them divisions so select and add edgeloops around 5 and one down the middle
make sure you bend the hair cards and for the eyebrows select the centre faces and press b (soft selection) and pull out slightly to make a dome shape

now start making the triangular clumps
change teh viewport in render from object sorting to depth peeling







# Unreal
youtube video https://www.youtube.com/watch?v=Z58OQ9x0E68&ab_channel=CGMasterAcademyCGMA
in unreal you only need:
ID map
heingt map
ramp map
alpha and then a map with everything combined in one texture (1, 32 bit tj texture)
when making hair turn off all typoes of shading (lighting/ flat lighting)
layer 1: make the scalp, needs to be opaque

layer 2: Block out layer - it should not feel or look like hair yet, its a main sctructure and needs to act like a base.

Layer 3: second block layer - try not to stack hair cards on top of eachother. must utilise negative space in hair chunksto see layers underneath

layer 4:@ flyu aaways - finer details
buns are simle hairstyles to make becuase they can be static and dont need to move
here is the same process applied to a bun:
scalp:

blockout

secondblockout

flyaweay layer:

a vertex colour needs to be assigned to each layer to make life easier
when placign the hair cards in chunks makle sure theyre straightand not diagonal
Always use deformers when trying to bend haior and always apply a twist modifier too to start. this helps break up the hair when light hits.
place the hair card root on the scalp and then start using the hair moidifiers.
for dreadlocks apply texture to a tube and then twist it
make a heightmap combined with the alpha channel just for maya preview
braids also need to be made with a tube
use Simple Pipe script for baking spline textures
# Section 2 of udemy course
outline all the different hair cards that you want to make on photohsoo

then bring into maya by adding it to a plane ( assign it a material then in colour add a file and then import the material, if you dont see it press 6)
then click the live surface option (looks like a magnet at the top) start drawing the strands using create/ currve tool/ ep curve
folow the guides you drew for the hair and beard
then you need to make all the startingpiunts of the hair start from the same section,
so lighlight the group and press fn 7 and select the top vertices and press R and scale it straight

then select them, curves/ rebuild (open the settings of it) and change the spans to 10
centre the pivot points and then move the hair strands so its not straight
create one plane for all the parts like so:

then select the plane and create an xgen description
select your hair then go to utilities and click curves to guides
the disadvantage to this is that when you mess with the density it effects all the guides.
Xgen understands masks, so if you use less white on your mask then it will generate less hair

saves quite a bit of work

# model 4
create your hjair, select the faces that you want and then crete a description from there, (or mask it) do your thing, you can create different descriptions in the same collection.
then gram all your hair elements once done and go to generate/ interactive groom and when naming it dont use capital letters
then you need to select it and go to generate again and go to cache and click export cache, make sure its an alembic file.
when importing it into unreal make sure the groom pop up comes up
creating a hair material in unreal:
create new material
make sure you select hair under the shading model drop down
then type in strands and make sure that the box is ticked
the in the node area press 3 and click to create a parameter right click and convert to parameter
make three and name hair high med and low
starting with low
change the colour, from the default value on the left and make it red then the med a dark red and the high a pinky red for highli9ghts

we then ned to mix these colours using another node called lerp multiply float 3 an plug inm accordingly

then add another node that will combine them called hair attributes and add the seed to the A(S) this will give each strand different colour variations
then we need to add a lerpinterpolate node and we are going to join the mid colour to it and also the mixed colour

then we need to add another parameter so press 1 and click which is gonna be plugged into the alpha and set the value to 1 (on the left) and then right click the node and turn it into a parameter and name it colour noise amount
then we need to create a multiply node for the lerp node to plug into the base colour section of the main thing
and create another parameter (press 1 and click and then rightclick and change to parameter)

then import your groom and go to your character and double click it open the view port and import your groom and arange it, make sure the import is below the mesh cahracter. then under material in element drag your new hair texture
then go bnack to your material in the bar and right click it and make it an instance and pull that one into the groom insteadin the element section inder material
then double click the new instance shader from the shelf and you can edit the brightness and colours real time
still need to edit the hair so open the og shader again and add an "add" node using the tab key. then add a noise node and plug it into the position and then add a lerp interpolate and insert it into B and then add another parameter so press 1 and click and right click and add parameter plug into alpha and then another lerp interpolate and add the plug in to Alpha and then insert it into the roughness
then for the values create two more parameters called roughness and roughness 1 and then insert the roughness to lerp A and roughness 1 to lerp B and change default value of Roughness to 0.28 and roughness 1 to 0.38
then save

the hair is a bit too semi transparent so we fix it
go into the vharacter blueprint and double click to groom and go to strands on teh right and you can change the hair width and all other stuff
now we fix the dynamics
double click your groom in the shelf adn go to physics and then click the box and hair starts to move
to arrange the stiffness of it go back into the groom and go down to the physics assets in simulation and click override settings then open solver settings and tick enable simmulation
and then go to the material constraints and increase the bend stiffness
if you mirror something and it doesnt mirror correctly, then redo the clumping guodes.
be sure to select both sides when making a description
make sure there are uvs
creating a braid.
using ep curves
once hair is ready then follow the line with the ep curves and make them flow with the hair
then grab them all and press curve /rebuild
then plait it
its a bitch
and then go to utilities and curves to guides