Skip to content

Commit 604abff

Browse files
authored
Merge pull request #95 from soupday/dev
Dev
2 parents f8f4d86 + beac073 commit 604abff

17 files changed

+416
-135
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
11
Changelog
22
=========
33

4+
### 1.6.3
5+
- Wrinkle manager update Blend shape indices button.
6+
- Wrinkle system setup will look for wrinkle masks in Assets as well as packages. (If tools installed into assets and not with package manager)
7+
- Wrinkle system added to URP shader graph shaders.
8+
- Anisotropic highlights added to URP shader graph hair shaders.
9+
- Mesh extraction checks for duplicate blend shape names.
10+
- URP Amplify hair shaders support for Forward+ additional lights.
11+
- URP Amplify shaders recompiled for ASE-1.9.6 (Fixes URP17 issues).
12+
- Fix to colliders not being added with just hair physics.
13+
- Fix to HDRP diffusion profiles not being added in HDRP17.
14+
415
### 1.6.2
516
- URP Amplify shader fix for when there is no main light.
617
- Work around to intermittent CC4 specular export issue when exporting with 'Bake diffuse maps from skin color' option (which is enabled by default now).
18+
- Fix to physics assignment when shared materials count does not match submesh count.
719

820
### 1.6.1
921
- Magica Cloth 2 support for hair physics.

Editor/Compute/RLBakeShader.compute

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@
6161
#pragma kernel RLChannelPackLinear
6262
#pragma kernel RLChannelPackSymmetryLinear
6363

64+
#pragma multi_compile _ _MAC_OS
65+
6466
// Defines
6567
//
6668
#define SAMPLE(tex,coord) tex.SampleLevel (sampler##tex,coord, 0)
@@ -351,6 +353,8 @@ float4 LinearTosRGB(float4 In)
351353
{
352354
#ifdef UNITY_COLORSPACE_GAMMA
353355
return In;
356+
#elif _MAC_OS
357+
return In;
354358
#else
355359
float3 sRGBLo = In.xyz * 12.92;
356360
float3 sRGBHi = (pow(max(abs(In.xyz), 1.192092896e-07), float3(1.0 / 2.4, 1.0 / 2.4, 1.0 / 2.4)) * 1.055) - 0.055;
@@ -804,7 +808,8 @@ void RLHeadMask(uint3 id : SV_DispatchThreadID)
804808

805809
float metallic = mask.r;
806810
float ao = INVERTED_SCALE(mask.g, aoStrength) * cavityAO;
807-
float detailMask = mask.b * subsurfaceFlattenNormals;
811+
//float detailMask = mask.b * subsurfaceFlattenNormals;
812+
float detailMask = mask.b;
808813
float smoothness = lerp(smoothnessMin, smoothnessMax, pow(mask.a, smoothnessPower));
809814
smoothness = saturate((1.0 + smoothnessMod + microSmoothnessMod) * smoothness);
810815
float4 packed = float4(metallic, ao, detailMask, smoothness);
@@ -864,7 +869,8 @@ void RLSkinMask(uint3 id : SV_DispatchThreadID)
864869

865870
float metallic = mask.r;
866871
float ao = INVERTED_SCALE(mask.g, aoStrength);
867-
float detailMask = mask.b * subsurfaceFlattenNormals;
872+
//float detailMask = mask.b * subsurfaceFlattenNormals;
873+
float detailMask = mask.b;
868874
float smoothness = lerp(smoothnessMin, smoothnessMax, pow(mask.a, smoothnessPower));
869875
smoothness = saturate((1.0 + smoothnessMod + microSmoothnessMod) * smoothness);
870876
float4 packed = float4(metallic, ao, detailMask, smoothness);
@@ -887,7 +893,8 @@ void RLHeadMetallicGloss(uint3 id : SV_DispatchThreadID)
887893

888894
float metallic = mask.r;
889895
float ao = INVERTED_SCALE(mask.g, aoStrength) * cavityAO;
890-
float detailMask = mask.b * subsurfaceFlattenNormals;
896+
//float detailMask = mask.b * subsurfaceFlattenNormals;
897+
float detailMask = mask.b;
891898
float smoothness = lerp(smoothnessMin, smoothnessMax, pow(mask.a, smoothnessPower));
892899
smoothness = saturate((1.0 + smoothnessMod + microSmoothnessMod) * smoothness);
893900
float4 packed = float4(metallic, metallic, metallic, smoothness);
@@ -909,7 +916,8 @@ void RLSkinMetallicGloss(uint3 id : SV_DispatchThreadID)
909916

910917
float metallic = mask.r;
911918
float ao = INVERTED_SCALE(mask.g, aoStrength);
912-
float detailMask = mask.b * subsurfaceFlattenNormals;
919+
//float detailMask = mask.b * subsurfaceFlattenNormals;
920+
float detailMask = mask.b;
913921
float smoothness = lerp(smoothnessMin, smoothnessMax, pow(mask.a, smoothnessPower));
914922
smoothness = saturate((1.0 + smoothnessMod + microSmoothnessMod) * smoothness);
915923
float4 packed = float4(metallic, metallic, metallic, smoothness);
@@ -989,11 +997,13 @@ void RLHeadNormal(uint3 id : SV_DispatchThreadID)
989997
float3 normalBlend = SAMPLE_NORMAL(NormalBlend, uv);
990998
float microScatteringMultiplier = HeadScatterMask(uv) * subsurfaceScale;
991999
float subsurface = SAMPLE(Subsurface, uv).y * microScatteringMultiplier;
992-
float subsurfaceFlattenNormals = saturate(1.0 - (subsurface * subsurface * sssNormalSoften));
1000+
float subsurfaceFlattenNormals = saturate(1.0 - (subsurface * subsurface * sssNormalSoften));
9931001

9941002
float3 mn, bn, on;
995-
NormalStrength_float3(normal, normalStrength * subsurfaceFlattenNormals, mn);
996-
NormalStrength_float3(normalBlend, normalBlendStrength * subsurfaceFlattenNormals, bn);
1003+
//NormalStrength_float3(normal, normalStrength * subsurfaceFlattenNormals, mn);
1004+
//NormalStrength_float3(normalBlend, normalBlendStrength * subsurfaceFlattenNormals, bn);
1005+
NormalStrength_float3(normal, normalStrength, mn);
1006+
NormalStrength_float3(normalBlend, normalBlendStrength, bn);
9971007
NormalBlend_float3(mn, bn, on);
9981008

9991009
Result[id.xy] = PackNormal(on);
@@ -1011,7 +1021,8 @@ void RLSkinNormal(uint3 id : SV_DispatchThreadID)
10111021
float subsurfaceFlattenNormals = saturate(1.0 - (subsurface * subsurface * sssNormalSoften));
10121022

10131023
float3 ns;
1014-
NormalStrength_float3(normal, normalStrength * subsurfaceFlattenNormals, ns);
1024+
//NormalStrength_float3(normal, normalStrength * subsurfaceFlattenNormals, ns);
1025+
NormalStrength_float3(normal, normalStrength, ns);
10151026

10161027
Result[id.xy] = PackNormal(ns);
10171028
}

Editor/ComputeBake.cs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1562,10 +1562,11 @@ private Material BakeHairMaterial(Material mat, string sourceName,
15621562
firstPass = null;
15631563
secondPass = null;
15641564

1565-
bool useAmplify = characterInfo.BakeCustomShaders && mat.shader.name.iContains("/Amplify/");
1565+
bool useAmplify = characterInfo.BakeCustomShaders && mat.shader.name.iContains("/Amplify/");
15661566
bool useTessellation = characterInfo.BuiltFeatureTessellation;
15671567
bool useWrinkleMaps = characterInfo.BuiltFeatureWrinkleMaps;
15681568
bool useDigitalHuman = characterInfo.BakeCustomShaders && mat.shader.name.iEndsWith("_DH");
1569+
float diffuseAO = (useAmplify || (IS_URP && CUSTOM_SHADERS)) ? 0f : aoOccludeAll;
15691570

15701571
Texture2D bakedBaseMap = diffuse;
15711572
Texture2D bakedMaskMap = mask;
@@ -1577,7 +1578,7 @@ private Material BakeHairMaterial(Material mat, string sourceName,
15771578
if (enableColor)
15781579
{
15791580
bakedBaseMap = BakeHairDiffuseMap(diffuse, blend, id, root, mask,
1580-
diffuseStrength, alphaPower, alphaRemap, aoStrength, (useAmplify ? 0f : aoOccludeAll),
1581+
diffuseStrength, alphaPower, alphaRemap, aoStrength, diffuseAO,
15811582
rootColor, rootColorStrength, endColor, endColorStrength, globalStrength,
15821583
invertRootMap, baseColorStrength, highlightBlend,
15831584
highlightAColor, highlightADistribution, highlightAOverlapEnd,
@@ -1590,7 +1591,7 @@ private Material BakeHairMaterial(Material mat, string sourceName,
15901591
else
15911592
{
15921593
bakedBaseMap = BakeHairDiffuseMap(diffuse, blend, mask,
1593-
diffuseStrength, alphaPower, alphaRemap, aoStrength, (useAmplify ? 0f : aoOccludeAll),
1594+
diffuseStrength, alphaPower, alphaRemap, aoStrength, diffuseAO,
15941595
blendStrength, vertexBaseColor, vertexColorStrength,
15951596
sourceName + "_BaseMap");
15961597
}
@@ -1620,6 +1621,7 @@ private Material BakeHairMaterial(Material mat, string sourceName,
16201621
Action<Material> SetCustom = (bakeMat) =>
16211622
{
16221623
bakeMat.SetFloatIf("_AOOccludeAll", aoOccludeAll);
1624+
Debug.Log("AO Occlude All = " + aoOccludeAll);
16231625
bakeMat.SetTextureIf("_FlowMap", flow);
16241626
bakeMat.SetFloatIf("_FlowMapFlipGreen", flowMapFlipGreen);
16251627
bakeMat.SetFloatIf("_Translucency", translucency);
@@ -1913,7 +1915,8 @@ public Texture2D BakeChannelPackLinear(string folder,
19131915
alphaChannel = CheckBlank(alphaChannel);
19141916

19151917
int kernel = bakeShader.FindKernel("RLChannelPackLinear");
1916-
bakeTarget.Create(bakeShader, kernel);
1918+
bakeTarget.Create(bakeShader, kernel);
1919+
19171920
bakeShader.SetTexture(kernel, "RedChannel", redChannel);
19181921
bakeShader.SetTexture(kernel, "GreenChannel", greenChannel);
19191922
bakeShader.SetTexture(kernel, "BlueChannel", blueChannel);
@@ -1949,7 +1952,8 @@ public Texture2D BakeChannelPackSymmetryLinear(string folder,
19491952
alphaChannelR = CheckBlank(alphaChannelR);
19501953

19511954
int kernel = bakeShader.FindKernel("RLChannelPackSymmetryLinear");
1952-
bakeTarget.Create(bakeShader, kernel);
1955+
bakeTarget.Create(bakeShader, kernel);
1956+
19531957
bakeShader.SetTexture(kernel, "RedChannelL", redChannelL);
19541958
bakeShader.SetTexture(kernel, "GreenChannelL", greenChannelL);
19551959
bakeShader.SetTexture(kernel, "BlueChannelL", blueChannelL);
@@ -2192,7 +2196,8 @@ private Texture2D BakeHeadDiffuseMap(Texture2D diffuse, Texture2D blend, Texture
21922196
cavityAO = CheckMask(cavityAO);
21932197

21942198
int kernel = bakeShader.FindKernel("RLHeadDiffuse");
2195-
bakeTarget.Create(bakeShader, kernel);
2199+
bakeTarget.Create(bakeShader, kernel);
2200+
21962201
bakeShader.SetTexture(kernel, "Diffuse", diffuse);
21972202
bakeShader.SetTexture(kernel, "ColorBlend", blend);
21982203
bakeShader.SetTexture(kernel, "CavityAO", cavityAO);
@@ -2431,7 +2436,8 @@ private Texture2D BakeHeadSubsurfaceMap(Texture2D subsurface,
24312436
baseMap = CheckDiffuse(baseMap);
24322437

24332438
int kernel = bakeShader.FindKernel(kernelName);
2434-
bakeTarget.Create(bakeShader, kernel);
2439+
bakeTarget.Create(bakeShader, kernel);
2440+
24352441
bakeShader.SetTexture(kernel, "Subsurface", subsurface);
24362442
bakeShader.SetTexture(kernel, "NMUILMask", NMUIL);
24372443
bakeShader.SetTexture(kernel, "CFULCMask", CFULC);

Editor/Importer.cs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2040,8 +2040,9 @@ private void ConnectHQHairMaterial(GameObject obj, string sourceName, Material s
20402040
mat.SetFloatIf("_BlendStrength", Mathf.Clamp01(matJson.GetFloatValue("Textures/Blend/Strength") / 100f));
20412041
mat.SetColorIf("_VertexBaseColor", Util.LinearTosRGB(matJson.GetColorValue("Custom Shader/Variable/VertexGrayToColor")));
20422042
mat.SetFloatIf("_VertexColorStrength", 1f * matJson.GetFloatValue("Custom Shader/Variable/VertexColorStrength"));
2043-
mat.SetFloatIf("_BaseColorStrength", 1f * matJson.GetFloatValue("Custom Shader/Variable/BaseColorMapStrength"));
2043+
mat.SetFloatIf("_BaseColorStrength", 1f * matJson.GetFloatValue("Custom Shader/Variable/BaseColorMapStrength"));
20442044
mat.SetFloatIf("_DiffuseStrength", 1f * matJson.GetFloatValue("Custom Shader/Variable/Diffuse Strength"));
2045+
20452046
diffuseColor = Util.LinearTosRGB(matJson.GetColorValue("Diffuse Color"));
20462047
mat.SetColorIf("_DiffuseColor", diffuseColor);
20472048

@@ -2077,13 +2078,24 @@ private void ConnectHQHairMaterial(GameObject obj, string sourceName, Material s
20772078
mat.SetFloatIf("_RimTransmissionIntensity", 0.75f * specMapStrength * Mathf.Pow(rimTransmission, 0.5f));
20782079
mat.SetFloatIf("_FlowMapFlipGreen", 1f -
20792080
matJson.GetFloatValue("Custom Shader/Variable/TangentMapFlipGreen"));
2080-
mat.SetFloatIf("_SpecularShiftMin",
2081+
mat.SetFloatIf("_SpecularShiftMin",
2082+
matJson.GetFloatValue("Custom Shader/Variable/BlackColor Reflection Offset Z"));
2083+
mat.SetFloatIf("_SpecularShiftMax",
2084+
matJson.GetFloatValue("Custom Shader/Variable/WhiteColor Reflection Offset Z"));
2085+
}
2086+
else if (RP == RenderPipeline.URP && !USE_AMPLIFY_SHADER)
2087+
{
2088+
mat.SetFloatIf("_DiffuseStrength", 1.15f * matJson.GetFloatValue("Custom Shader/Variable/Diffuse Strength"));
2089+
mat.SetFloatIf("_SmoothnessMin", 0f);
2090+
mat.SetFloatIf("_SpecularMultiplier", Mathf.Lerp(0.1f, 0.5f, specMapStrength * specStrength));
2091+
mat.SetFloatIf("_FlowMapFlipGreen", 1f - matJson.GetFloatValue("Custom Shader/Variable/TangentMapFlipGreen"));
2092+
mat.SetFloatIf("_SpecularShiftMin",
20812093
matJson.GetFloatValue("Custom Shader/Variable/BlackColor Reflection Offset Z"));
20822094
mat.SetFloatIf("_SpecularShiftMax",
2083-
matJson.GetFloatValue("Custom Shader/Variable/WhiteColor Reflection Offset Z"));
2095+
matJson.GetFloatValue("Custom Shader/Variable/WhiteColor Reflection Offset Z"));
20842096
}
20852097
else
2086-
{
2098+
{
20872099
if (USE_AMPLIFY_SHADER)
20882100
{
20892101
SetFloatPowerRange(mat, "_SmoothnessMin", smoothnessStrength, 0f, smoothnessMax, smoothnessPowerMod);
@@ -2097,7 +2109,7 @@ private void ConnectHQHairMaterial(GameObject obj, string sourceName, Material s
20972109
matJson.GetFloatValue("Custom Shader/Variable/WhiteColor Reflection Offset Z"));
20982110
}
20992111
else
2100-
{
2112+
{
21012113
mat.SetFloatIf("_SmoothnessMin", Util.CombineSpecularToSmoothness(specMapStrength * specStrength, smoothnessStrength));
21022114
}
21032115
}

0 commit comments

Comments
 (0)