User Tools

Site Tools


pidi_advanced_skin_shader_2

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
pidi_advanced_skin_shader_2 [2020/08/25 01:59]
irrsoft [Advanced Set up Topics]
pidi_advanced_skin_shader_2 [2020/08/30 02:50] (current)
irrsoft [Tension Maps vs Region Maps comparison]
Line 217: Line 217:
 ==== Deferred Setup ==== ==== Deferred Setup ====
  
-###+<WRAP justify>
 Deferred shading in Unity is extremely useful since it allows you to render a huge amount of lights without additional passes on each object. However, to do this, all control over the lighting portion of a shader is removed and handled instead by the Deferred Shading shader. This makes it impossible to add new features such as scattering or translucency to any deferred shader without modifying or replacing entirely the internal Deferred Shading code used by Unity.  Deferred shading in Unity is extremely useful since it allows you to render a huge amount of lights without additional passes on each object. However, to do this, all control over the lighting portion of a shader is removed and handled instead by the Deferred Shading shader. This makes it impossible to add new features such as scattering or translucency to any deferred shader without modifying or replacing entirely the internal Deferred Shading code used by Unity. 
-###+</WRAP>
  
-###+<WRAP justify>
 In order to avoid this and to make our Advanced Skin Shader work with any deferred shading system we decided to provide the missing lighting information manually. This allows the shader to work seamlessly with Deferred Shading while keeping the features mostly intact, but with the drawback of the scattering and translucency being limited to just four specific lights and the translucency itself not being affected by shadows. In order to avoid this and to make our Advanced Skin Shader work with any deferred shading system we decided to provide the missing lighting information manually. This allows the shader to work seamlessly with Deferred Shading while keeping the features mostly intact, but with the drawback of the scattering and translucency being limited to just four specific lights and the translucency itself not being affected by shadows.
-###+</WRAP>
  
-###+<WRAP justify>
 These limitations, while small, still have to be considered. The shader does a good job at simulating the shadowing created by shadows over the translucency but this is not as accurate as real shadowing in Forward mode. The scattering is also highly accurate but its mixing with the rest of the lighting is not as soft and accurate as the one in Forward mode. Despite all this, for games using Deferred Shading mode, the Advanced Skin Shader still provides all the features and high quality with minimal setup being required.  These limitations, while small, still have to be considered. The shader does a good job at simulating the shadowing created by shadows over the translucency but this is not as accurate as real shadowing in Forward mode. The scattering is also highly accurate but its mixing with the rest of the lighting is not as soft and accurate as the one in Forward mode. Despite all this, for games using Deferred Shading mode, the Advanced Skin Shader still provides all the features and high quality with minimal setup being required. 
-###+</WRAP>
  
 \\ \\
Line 233: Line 233:
 \\ \\
  
-###+<WRAP justify>
 To start, set the **DEFERRED COMPATIBILITY** mode to Enabled. This will create an additional tab called **DEFERRED LIGHTS**, in which you can assign the four lights that will have effect over the scattering and translucency. Assign the lights that you want to affect the skin shader to that list. In our case, we will add the Directional light used in the previous scene to display translucency. To start, set the **DEFERRED COMPATIBILITY** mode to Enabled. This will create an additional tab called **DEFERRED LIGHTS**, in which you can assign the four lights that will have effect over the scattering and translucency. Assign the lights that you want to affect the skin shader to that list. In our case, we will add the Directional light used in the previous scene to display translucency.
-###+</WRAP>
  
 \\ \\
Line 241: Line 241:
 \\ \\
  
-###+<WRAP justify>
 And as you can see, there is little to no difference between the quality of the end results once the deferred shading settings have been properly set up. Be aware that materials cannot be just switched between both renderings without any changes, since the final color and gloss may vary slightly between both rendering modes.  Keep this in mind and remember to set up your materials accordingly. And as you can see, there is little to no difference between the quality of the end results once the deferred shading settings have been properly set up. Be aware that materials cannot be just switched between both renderings without any changes, since the final color and gloss may vary slightly between both rendering modes.  Keep this in mind and remember to set up your materials accordingly.
-###+</WRAP>
  
 \\ \\
Line 249: Line 249:
 \\ \\
  
-###+<WRAP justify>
 The gif below shows the shader working properly in deferred mode (as seen by setting the scene view to display the deferred normals of the scene) and with all features performing as expected, including the dynamic wrinkles through tension maps The gif below shows the shader working properly in deferred mode (as seen by setting the scene view to display the deferred normals of the scene) and with all features performing as expected, including the dynamic wrinkles through tension maps
-###+</WRAP>
  
 \\ \\
Line 308: Line 308:
  
  
-###+<WRAP justify>
 The first method to add dynamic wrinkles to your models is the Tension map approach. Tension maps are run-time generated data sets that define which areas of a mesh are suffering deformation, and based on that deformation a transition between a "Resting" normal map and a "Wrinkled" normal map are evaluated and performed. The first method to add dynamic wrinkles to your models is the Tension map approach. Tension maps are run-time generated data sets that define which areas of a mesh are suffering deformation, and based on that deformation a transition between a "Resting" normal map and a "Wrinkled" normal map are evaluated and performed.
-###+</WRAP>
  
-###+<WRAP justify>
 Our approach takes a "Resting" Normal map, a "Wrinkled" normal map and 3 different poses as references to compute and predict all possible wrinkled regions within the face of a character. While it provides with fast, high quality results that are computed entirely on the GPU and on any device and it is extremely easy to set up, it also has some inaccuracies that are unavoidable due to its results being predicted from a limited amount of data. Our approach takes a "Resting" Normal map, a "Wrinkled" normal map and 3 different poses as references to compute and predict all possible wrinkled regions within the face of a character. While it provides with fast, high quality results that are computed entirely on the GPU and on any device and it is extremely easy to set up, it also has some inaccuracies that are unavoidable due to its results being predicted from a limited amount of data.
-###+</WRAP>
  
-###+<WRAP justify>
 However, if the amount of normal maps you have is limited or you need high performance over multiple instances and a faster set up without perfect accuracy on every single pose being a huge concern, or if you need to deploy your project on lower end devices then the Tension Maps approach is the best method to use. However, if the amount of normal maps you have is limited or you need high performance over multiple instances and a faster set up without perfect accuracy on every single pose being a huge concern, or if you need to deploy your project on lower end devices then the Tension Maps approach is the best method to use.
-###+</WRAP>
  
-###+<WRAP justify>
 The three poses used as reference by the asset are the "Rest Pose", a "Pulling Pose" (extreme surprise) and a "Pushing Pose" (extreme anger). This will ensure that the maximum deformations of the face are registered to calculate the transitions between its resting pose and these two extremes.  The three poses used as reference by the asset are the "Rest Pose", a "Pulling Pose" (extreme surprise) and a "Pushing Pose" (extreme anger). This will ensure that the maximum deformations of the face are registered to calculate the transitions between its resting pose and these two extremes. 
-###+</WRAP>
  
-###+<WRAP justify>
 Using a high quality sculpt or 3D model of your character performing said expressions and displaying the correct wrinkles should be used to generate the normal map that will be assigned as the "Wrinkle" normal map. This process needs to be done carefully, to ensure that there are not too many different wrinkles overlapping each other and that they do cover most of the expressions that the character can make. Below you can find a screenshot of one of the sculpts used by our team when creating the wrinkles map for the Old Man model Using a high quality sculpt or 3D model of your character performing said expressions and displaying the correct wrinkles should be used to generate the normal map that will be assigned as the "Wrinkle" normal map. This process needs to be done carefully, to ensure that there are not too many different wrinkles overlapping each other and that they do cover most of the expressions that the character can make. Below you can find a screenshot of one of the sculpts used by our team when creating the wrinkles map for the Old Man model
-###+</WRAP>
  
 \\ \\
Line 332: Line 332:
 \\ \\
  
-###+<WRAP justify>
 Once you have generated the normal map for the wrinkles, we can start working on generating the tension maps in Unity. First, make sure that you are using a "Tension Map" enabled shaders. All the shaders that support Tension Maps contain "TensionMap" in their name. Then, enable the Dynamic Wrinkles feature on the General Settings tab of the Advanced Skin Shader UI. Once you have generated the normal map for the wrinkles, we can start working on generating the tension maps in Unity. First, make sure that you are using a "Tension Map" enabled shaders. All the shaders that support Tension Maps contain "TensionMap" in their name. Then, enable the Dynamic Wrinkles feature on the General Settings tab of the Advanced Skin Shader UI.
-###+</WRAP>
  
 \\ \\
Line 340: Line 340:
 \\ \\
  
-###+<WRAP justify>
 Assign the Wrinkles normal map in the corresponding slot as well as the Head Bone of your character rig, and set the vertex threshold value to a higher value. This threshold defines how much the vertices have to move before they start being tracked for the Tension Map to be generated. If the value is too small then wrinkles may appear while the face is at rest and if it is too high they may not appear at all. Make sure that your mesh has a 1,1,1 scale and a 0,0,0 position and rotation before proceeding to the next steps.  Assign the Wrinkles normal map in the corresponding slot as well as the Head Bone of your character rig, and set the vertex threshold value to a higher value. This threshold defines how much the vertices have to move before they start being tracked for the Tension Map to be generated. If the value is too small then wrinkles may appear while the face is at rest and if it is too high they may not appear at all. Make sure that your mesh has a 1,1,1 scale and a 0,0,0 position and rotation before proceeding to the next steps. 
-###+</WRAP>
  
 \\ \\
Line 348: Line 348:
 \\ \\
  
-###+<WRAP justify>
 Place the character in the rest facial pose, and then press the "SAVE REST POSE" button. This will create a snapshot of the rest pose and make the wrinkles from the wrinkle map disappear. Now, set the character in the first reference pose and press the "SAVE POSE ONE" button. Place the character on the second reference pose and press "SAVE POSE TWO". Now your character is ready and set up to start using the Tension maps. You can see the dynamic Tension map working and changing by enabling the debug mode inside the Dynamic Wrinkles tab. Place the character in the rest facial pose, and then press the "SAVE REST POSE" button. This will create a snapshot of the rest pose and make the wrinkles from the wrinkle map disappear. Now, set the character in the first reference pose and press the "SAVE POSE ONE" button. Place the character on the second reference pose and press "SAVE POSE TWO". Now your character is ready and set up to start using the Tension maps. You can see the dynamic Tension map working and changing by enabling the debug mode inside the Dynamic Wrinkles tab.
-###+</WRAP>
  
 \\ \\
Line 359: Line 359:
 === Notices about Prefabs === === Notices about Prefabs ===
  
-###+<WRAP justify>
 When using Dynamic Wrinkles with the Tension Maps method the original mesh of your character will be patched with additional information that will allow it to work in low end devices while keeping your original mesh intact. However, since this is a runtime procedural mesh it cannot be saved as part of a prefab, it has to be exported to the disk before being stored within a prefab object. When using Dynamic Wrinkles with the Tension Maps method the original mesh of your character will be patched with additional information that will allow it to work in low end devices while keeping your original mesh intact. However, since this is a runtime procedural mesh it cannot be saved as part of a prefab, it has to be exported to the disk before being stored within a prefab object.
-###+</WRAP>
  
-###+<WRAP justify>
 In order to do this, simply press the "SAVE PATCHED MESH" button and select a location within your project to store this mesh. Once this is done, this new mesh will be automatically assigned to your character model and the dynamic wrinkles will keep working as intended and, since the generated and patched mesh has been saved to the disk, you can now create your prefabs as usual. In order to do this, simply press the "SAVE PATCHED MESH" button and select a location within your project to store this mesh. Once this is done, this new mesh will be automatically assigned to your character model and the dynamic wrinkles will keep working as intended and, since the generated and patched mesh has been saved to the disk, you can now create your prefabs as usual.
-###+</WRAP>
  
 \\ \\
Line 373: Line 373:
  
  
-###+<WRAP justify>
 The second method included with this tool to add dynamic wrinkles to your characters is called Region Maps approach. With this setup, instead of having a "Rest Pose" normal map and a "Wrinkles" normal map you can have any number of expression poses each one with its own unique wrinkles map, allowing higher quality results. While setting it up is a more involved task that has many more steps than the Tension Maps approach the results you can get with it are far more consistent, easier to customize and control, and allow for a much higher quality at the cost of a higher performance impact.  The second method included with this tool to add dynamic wrinkles to your characters is called Region Maps approach. With this setup, instead of having a "Rest Pose" normal map and a "Wrinkles" normal map you can have any number of expression poses each one with its own unique wrinkles map, allowing higher quality results. While setting it up is a more involved task that has many more steps than the Tension Maps approach the results you can get with it are far more consistent, easier to customize and control, and allow for a much higher quality at the cost of a higher performance impact. 
-###+</WRAP>
  
-###+<WRAP justify>
 **However, when dynamic wrinkles are disabled these shaders are far more efficient than their tension map counterparts so it is always recommended that if you are not going to use Dynamic Wrinkles at all you assign a Regions Map shader to your characters, even in Mobile.** **However, when dynamic wrinkles are disabled these shaders are far more efficient than their tension map counterparts so it is always recommended that if you are not going to use Dynamic Wrinkles at all you assign a Regions Map shader to your characters, even in Mobile.**
-###+</WRAP>
  
-\\+<WRAP justify>
 {{ :advss_createwrinkleasset.jpg?direct |}} {{ :advss_createwrinkleasset.jpg?direct |}}
-\\+</WRAP>
  
-###+<WRAP justify>
 Let's add regions map wrinkles to our model, but first we will need to create a Wrinkles Data Asset which will act as a list containing all of the Wrinkle Normal maps available for this character.  Let's add regions map wrinkles to our model, but first we will need to create a Wrinkles Data Asset which will act as a list containing all of the Wrinkle Normal maps available for this character. 
-###+</WRAP>
  
  
Line 394: Line 394:
 \\ \\
  
-###+<WRAP justify>
 And on this asset, let's add all the normal maps we have generated for this model to the corresponding list. The Wrinkle Data Asset is designed to help you organize your maps, especially in projects where there are dozens of normal maps per character. On top of this, as more updates are released for this tool the Wrinkle Data Asset will gain additional features and settings that will allow you to have further control over the wrinkles on your character in an easy, reusable "template-like" fashion. In our case, we only have one wrinkle normal map on this character. And on this asset, let's add all the normal maps we have generated for this model to the corresponding list. The Wrinkle Data Asset is designed to help you organize your maps, especially in projects where there are dozens of normal maps per character. On top of this, as more updates are released for this tool the Wrinkle Data Asset will gain additional features and settings that will allow you to have further control over the wrinkles on your character in an easy, reusable "template-like" fashion. In our case, we only have one wrinkle normal map on this character.
-###+</WRAP>
  
 \\ \\
Line 402: Line 402:
 \\ \\
  
-###+<WRAP justify>
 Next, we need to create a regions map. A regions map defines how the different normal maps, the one from the rest pose and those from the different wrinkle maps will be blended in up to four different zones (channels R, G, B and A). Each channel represents an area of the face and each one of them will be multiplied by unique per-pose blending values. You can have one general regions map to be shared across all expression poses or override it with a unique regions map on any of the individual poses. Next, we need to create a regions map. A regions map defines how the different normal maps, the one from the rest pose and those from the different wrinkle maps will be blended in up to four different zones (channels R, G, B and A). Each channel represents an area of the face and each one of them will be multiplied by unique per-pose blending values. You can have one general regions map to be shared across all expression poses or override it with a unique regions map on any of the individual poses.
-###+</WRAP>
  
  
Line 411: Line 411:
 \\ \\
  
-###+<WRAP justify>
 Once this is ready, assign the Wrinkle Data Asset, Head Bone and Regions Map to their corresponding slots. Then, press on the "ADD NEW WRINKLES SNAPSHOT" button Once this is ready, assign the Wrinkle Data Asset, Head Bone and Regions Map to their corresponding slots. Then, press on the "ADD NEW WRINKLES SNAPSHOT" button
-###+</WRAP>
  
 \\ \\
Line 419: Line 419:
 \\ \\
  
-###+<WRAP justify>
 This will add a new sub-group called **WRINKLE DATA SET** followed by a number. This data set represents a pose or expression that your character can make and contains the information of which bones or blendshapes are used for said expression and thus should be tracked, which normal map corresponds to said expression, which region map to use to control its influence in case we want to override the default one, the influence of each one of the four regions in the region map (RED, GREEN, BLUE and an inverse ALPHA channel) and finally the blendshapes and bones that have to be tracked to detect whether the character is performing the expression described in the snapshot or not This will add a new sub-group called **WRINKLE DATA SET** followed by a number. This data set represents a pose or expression that your character can make and contains the information of which bones or blendshapes are used for said expression and thus should be tracked, which normal map corresponds to said expression, which region map to use to control its influence in case we want to override the default one, the influence of each one of the four regions in the region map (RED, GREEN, BLUE and an inverse ALPHA channel) and finally the blendshapes and bones that have to be tracked to detect whether the character is performing the expression described in the snapshot or not
-###+</WRAP>
  
-###+<WRAP justify>
 You **DO NOT** need to define a snapshot for the rest pose, this is generated automatically and stored internally. Once you have added all the blendshapes and bones that you want to track to the lists you just need to place your character in the pose you want to save and click on the **SAVE POSE SNAPSHOT** button. You **DO NOT** need to define a snapshot for the rest pose, this is generated automatically and stored internally. Once you have added all the blendshapes and bones that you want to track to the lists you just need to place your character in the pose you want to save and click on the **SAVE POSE SNAPSHOT** button.
-###+</WRAP>
  
 \\ \\
Line 432: Line 432:
  
  
-###+<WRAP justify>
 In the Tension Map vs Region Map demo scene included with the asset you can see a fully set up example of the Regions Map usage with the Old Man Demo. One wrinkle snapshot has been created for each one of the five different blendshapes that the model has. In all of them the same normal map has been used but some of the expressions make use of a different region map that instead of defining regions for the sides of the mouth and both sides of the brow cover instead the brow and the forehead. In the Tension Map vs Region Map demo scene included with the asset you can see a fully set up example of the Regions Map usage with the Old Man Demo. One wrinkle snapshot has been created for each one of the five different blendshapes that the model has. In all of them the same normal map has been used but some of the expressions make use of a different region map that instead of defining regions for the sides of the mouth and both sides of the brow cover instead the brow and the forehead.
-###+</WRAP>
  
-###+<WRAP justify>
 In the CGI Stylized demo you can see another usage of this technique, this time in a character whose animation is fully driven by bone animation and which uses two different wrinkle maps and two region maps for the small expressions set In the CGI Stylized demo you can see another usage of this technique, this time in a character whose animation is fully driven by bone animation and which uses two different wrinkle maps and two region maps for the small expressions set
-###+</WRAP>
  
-###+<WRAP justify>
 While the regions map approach works on mobile devices as well as in most devices that support RenderTextures (which are used internally to generate additional wrinkle data) they are CPU bound and thus may not be the most performant in low end devices. For a full breakdown of the pros and cons of each method please check the table below. While the regions map approach works on mobile devices as well as in most devices that support RenderTextures (which are used internally to generate additional wrinkle data) they are CPU bound and thus may not be the most performant in low end devices. For a full breakdown of the pros and cons of each method please check the table below.
-###+</WRAP>
  
 \\ \\
Line 454: Line 454:
 | Main wrinkle calculation processor |  GPU  |  CPU  | | Main wrinkle calculation processor |  GPU  |  CPU  |
 | Mobile Ready |  ✓  |  ✓  | | Mobile Ready |  ✓  |  ✓  |
-| SRP Ready |  ✓  |   |  +| SRP Ready |  ✓  |  ✓  |  
 | Supports Decals on Mobile |  X  |  ✓  | | Supports Decals on Mobile |  X  |  ✓  |
 | Max. Reference poses |  3  |  32+  |  | Max. Reference poses |  3  |  32+  | 
 | Max. Wrinkle Normal maps |  1  |  32+  | | Max. Wrinkle Normal maps |  1  |  32+  |
-| Wrinkle Occlusion maps |  With Occlusion Map's Alpha  |  Coming Q1 2020  |+| Wrinkle Occlusion maps |  With Occlusion Map's Alpha  |   |
 | Per Pose Wrinkle Weights |  Automatic, variable  |  Manual, 4 weights per pose  | | Per Pose Wrinkle Weights |  Automatic, variable  |  Manual, 4 weights per pose  |
 | Per Pose Performance Cost |  Stable Performance  |  Additive  | | Per Pose Performance Cost |  Stable Performance  |  Additive  |
Line 473: Line 473:
 \\ \\
  
-###+<WRAP justify>
 Adding overlay or simple decal textures to the skin shaders is very easy. Simply go to the GENERAL SETTINGS tab and set the Decal / Overlay Effects setting to true. This will add a new tab called SKIN FX SETTINGS.  Adding overlay or simple decal textures to the skin shaders is very easy. Simply go to the GENERAL SETTINGS tab and set the Decal / Overlay Effects setting to true. This will add a new tab called SKIN FX SETTINGS. 
-###+</WRAP>
  
 \\ \\
Line 481: Line 481:
 \\ \\
  
-###+<WRAP justify>
 In this tab, you can assign up to two different color maps to be used as overlays each one to be mixed in their own unique way with three blending modes : Masked, Additive and Multiplied. Each one of these two decals can have their own color, specularity / gloss maps and be displayed either on the UV0 or UV1 coordinates channel. In this tab, you can assign up to two different color maps to be used as overlays each one to be mixed in their own unique way with three blending modes : Masked, Additive and Multiplied. Each one of these two decals can have their own color, specularity / gloss maps and be displayed either on the UV0 or UV1 coordinates channel.
-###+</WRAP>
  
 \\ \\
Line 489: Line 489:
 \\ \\
  
-###+<WRAP justify>
 These decals allow you to easily and efficiently add effects such as sweat, wounds, tattoos, war paint etc to your characters while having full control over how it mixes with the skin under them and all their PBR properties. They are influenced by scattering, translucency and wrinkles as the rest of the skin and are available in all platforms. These decals allow you to easily and efficiently add effects such as sweat, wounds, tattoos, war paint etc to your characters while having full control over how it mixes with the skin under them and all their PBR properties. They are influenced by scattering, translucency and wrinkles as the rest of the skin and are available in all platforms.
-###+</WRAP>
  
 \\ \\
  
  
pidi_advanced_skin_shader_2.1598320792.txt.gz · Last modified: 2020/08/25 01:59 by irrsoft