Jump to content

Hi There

Welcome to Klub Exile. If you happened to make your way to the site either from Lovers Lab or a Search on Google, we are glad you found us.  To unlock the entire site you will need to have a account registered.  Don't worry it is free but in the mean time you can read up on why we made the site and other little tidbits.  Feel free to join or Discord Server also if you have any more questions.  Thanks for stopping by and See You on the other side.

admin admin



Recommended Posts

 hair video:

PhysX - is a system that allow insert into your project physic effects. It consist from several subsystems for different cases. PhysX SDK allow to developers compile physx components compatible with their projects and get access to all physx functionality. As you know (and again thanks to shoxx) I got physx3.3.4 and successefully compiled all desired libs and dlls to implement physic effects in hook. Hook use static linking to physx. At some stage hook create main physx object that allow to use functionality of all physx subsystems. Due to physx subsystems separated into different libraries, to your game can use ragdoll hairs you need dll's of all subsystems that was used in current project, in our case this is:

  • PhysX3_x86.dll
  • PhysX3Common_x86.dll
  • PhysX3Cooking_x86.dll

(all this files will be uploaded here and on patreon) and of course you should install physx on your PC.

 So basic idea in short terms: create ragdoll skeleton which will represent main hair strands, where all bones will be linked to "root" bone, then asign to that bone position and rotation of the head, then allow to physx to calculate positions for all other ragdoll bones with respect mass and inertia, then get transformations for all bones and render ordinal skinned mesh with all these transforms. To connect physx data to some mesh in game I decided use the same scheme as always - "_pass" file, when game will load some texture and this texture will have _pass file with provided physx data - I will load this data and link with this texture, when game will try render object with this texture - I will not render this object, I will use object transform to run physic simulation and then will render my own mesh with using result of simulation. There is example of _pass file that allow me link texture and physic data:

   name = PhysXModel
   stage2 = _hook5data\hairmaps\hair_normal_map.dds
   physx_rig = R9hair047.RepX   
   physx_hair = R9hair047.h5s
   physx_model = some_model_part.h5s

What is RepX. PhysX plugin for 3dmax allow me create skeleton and define physic properties for all skeleton components, like bones and joints, and then export all this data in one file RepX, later at some moment I can read all this data from this file and recreate the same ragdoll system when game is runing. But there is some problem PhysX and villa use different coordinate system, so I can't just load this file, I had to write a some kind of parser to read data, correct all transforms and only after create objects that will represent ragdoll skeleton. For now there is a few flaws, that should be fixed later. Here examples of skeleton and skeleton with dynamic rig:



Dynamic rigid system is a collection of bones and joints, joints allow to attach one bone to another and define motion properties for attached bone, every bone has a several parameters like mass, friction, collision object and so on. All this properties will used by physx in time of simulation.

What is h5s. The second part of hair physic simulation is render a mesh taht will represent hair. To mesh parts can move with bones, mesh should be skinned with all this bones and this is a difficult part of task, which take most part of time.


h5s - is simple file format that allow me store skinned mesh data in most effective for game kind. To store skinned mesh I writed script for 3dmax, which in time of export also perform calculation of Tangent-Binormal space for every vertices, normalize skin weights for vertices and so on.

Shading - unique shading for hair, but not sure that this is final version, need think more about this question, I want that hair use the same way for shading as other objects, also as you know due to my mistake, hair do not support shadows for now, and this is primary task on near future.

So steps to create hair should be like:
1. Create hair model or stole it somewhere.
2. Create ragdoll skeleton, use physx plugin to asign dynamic rig modyfier and create joints
3. Define properties for every component of skeleton
4. Perform skinning with all this bones
5. Export ragdoll system to RepX
6. Export mesh to h5s
7. Create _pass file for texture of hair which will be replaced, write all desired data
All other job will done hook. This is enougth for simulating movements, but we also want a some simulation of collision.

Collision... idea of hair with physic was in my head a long long time, but I did nothing, because I didn't know how to give physx information about body parts positions to perform collision calculations. A lot of different thoughs and noone works. The final idea simple - I decide add to body some sections which will represent some kind of body bones markers, althought game will try render this markers like ordinal objects, but here is hook, it will block rendering of markers, instead of this hook will use markers transform to place in physx scene collision objects which will represent body parts, in other words - each marker has associated collision object in physx scene and this object will copy positions and rotations of body parts every frame. This is more then enough for collision simulation. To allow this system work you should decode your bodies (I don't know what body addons, replacer you are use)and add to body##.bs markers sections, then encode body##. back (and t** of course). The marker sections you can paste between this sections:

STransform :local_36 . {
   Object.Name "Sbody_mesh_group";
 <------this is place for marker sections
TTransform :local_949 . {
   Object.Name "root_main_group";

I'm use this tool for encode/decode  t**/bs*:

I attached max file as example EXAMPLE_villa_physhair_398.zip, you need max2014, and Physx DCC plugin for 3dmax2014



Huge changes in physix code:
Completely rewrited objects that holds physx data, rendering pipeline for this objects and so on. Also, on first steps I'm hardcoded some ragdoll parameters in hook due to experiments, trying find out reasons for bad hair movements. Now all this code removed, all parameters readed from RepX file without changes, this is correct better experiments with physx params without recompiling of code. Most important parameters is: AngularDamping, joint Spring, joint Damping, joint LinearProjection (read physx documentation if you interested in this). For now one problem bother me - physx do not hold joints rotations limits (non with hard limits, non with soft limits) if I find the reason of this problem then I will assume that physx code finished (or almost finished).

Checked again 3dmax export script and I'm think (at least in export part) it will not be changed, with this I'm think all my frther actions will not affect file reading nor in case of RepX nor in case of h5s, so I'm going to post script on patreon, also base 3Dmax file will be posted

Now physx replacer support hair shading and ordinal PBR shading, pass file now looks like:
name = PhysXModel
physx_rig = path to RepX file
physx_hair = path to h5s file which represent hair model, this model will be rendered with hair shader
physx_model = path to h5s file which represent nonhair model, this model will be rendered with ordinal PBR shader
few another params - will be explained in guide

you can provide only one from physx_hair/physx_model or both in the same time, for example if I create just a hair model, I will provide only physx_hair parameter in pass file, if I create a earrings model I will provide only physx_model parameter, but if I create hair with....hat(for example) I will provide physx_hair for model part with only hair and physx_model for model part with hat only. But both from this parameters require proper physx_rig (RepX file) because it contain physx properties for ragdoll skeleton.

Another strange problem was found by me right before release - shadows for physx replacers seems rendered wrong, but I decided to make release to not delay it and now my primary task is a find and fix this problem.


  • Thanks 5
Link to comment
Share on other sites

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

WARNING! Adult Only Content You must be 18 years of age or older to enter. By accepting you agree to Klub Exile's Terms of Use and Guidelines upon creating an account.