@@ -60,7 +60,7 @@ private struct Styles
60
60
public static readonly GUIContent Specular = new GUIContent ( "Specular" ) ;
61
61
public static readonly GUIContent Metallic = new GUIContent ( "Metallic" ) ;
62
62
public static readonly GUIContent Smoothness = new GUIContent ( "Smoothness" ) ;
63
- public static readonly GUIContent EnableHairSpecular = new GUIContent ( "HairSpecular " ) ;
63
+ public static readonly GUIContent SpecularType = new GUIContent ( "SpecularType " ) ;
64
64
public static readonly GUIContent SpecularShiftMap = new GUIContent ( "HairShiftMap" ) ;
65
65
public static readonly GUIContent SpecularShift = new GUIContent ( "SpecularShift" ) ;
66
66
public static readonly GUIContent SpecularHighlights = new GUIContent ( "Enable Specular Highlights" ) ;
@@ -72,7 +72,8 @@ private struct Styles
72
72
73
73
//Rim
74
74
public static readonly GUIContent RimFlip = new GUIContent ( "RimFlip" ) ;
75
- public static readonly GUIContent RimBlend = new GUIContent ( "RimBlend" ) ;
75
+ public static readonly GUIContent RimBlendShadow = new GUIContent ( "RimBlendShadow" ) ;
76
+ public static readonly GUIContent RimBlendLdotV = new GUIContent ( "RimBlendLdotV(BackLight)" ) ;
76
77
public static readonly GUIContent RimColor = new GUIContent ( "RimColor" ) ;
77
78
public static readonly GUIContent RimPow = new GUIContent ( "RimPow" ) ;
78
79
public static readonly GUIContent RimStep = new GUIContent ( "RimStep" ) ;
@@ -129,7 +130,7 @@ private struct MPropertyNames
129
130
public static readonly string SpecStep = "_SpecularStep" ;
130
131
public static readonly string SpecFeather = "_SpecularFeather" ;
131
132
public static readonly string Smoothness = "_Smoothness" ;
132
- public static readonly string EnableHairSpecular = "_EnableHairSpecular " ;
133
+ public static readonly string SpecularType = "_SpecularType " ;
133
134
public static readonly string SpecularShiftMap = "_SpecularShiftMap" ;
134
135
public static readonly string SpecularShiftIntensity = "_SpecularShiftIntensity" ;
135
136
public static readonly string SpecularShift = "_SpecularShift" ;
@@ -150,7 +151,8 @@ private struct MPropertyNames
150
151
151
152
//Rim
152
153
public static readonly string RimFlip = "_RimFlip" ;
153
- public static readonly string RimBlend = "_RimBlend" ;
154
+ public static readonly string RimBlendShadow = "_RimBlendShadow" ;
155
+ public static readonly string RimBlendLdotV = "_RimBlendLdotV" ;
154
156
public static readonly string RimColor = "_RimColor" ;
155
157
public static readonly string RimStep = "_RimStep" ;
156
158
public static readonly string RimFeather = "_RimFeather" ;
@@ -197,6 +199,13 @@ public enum ShadowType
197
199
FaceSDFShadow = 2
198
200
}
199
201
202
+ public enum SpecularType
203
+ {
204
+ Default = 0 ,
205
+ HairSpecularViewNormal ,
206
+ HairSpecularTangent
207
+ }
208
+
200
209
#endregion
201
210
202
211
#region Fields
@@ -266,7 +275,7 @@ public enum ShadowType
266
275
private MaterialProperty m_SpecFeatherProp ;
267
276
private MaterialProperty m_SmoothnessProp ;
268
277
private MaterialProperty m_SpecularHighlightsProp ;
269
- private MaterialProperty m_EnableHairSpecularProp ;
278
+ private MaterialProperty m_SpecularTypeProp ;
270
279
private MaterialProperty m_SpeculatShiftMapProp ;
271
280
private MaterialProperty m_SpecularShiftIntensityProp ;
272
281
private MaterialProperty m_SpecularShiftProp ;
@@ -279,7 +288,8 @@ public enum ShadowType
279
288
280
289
//Rim
281
290
private MaterialProperty m_RimFlipProp ;
282
- private MaterialProperty m_RimBlendProp ;
291
+ private MaterialProperty m_RimBlendShadowProp ;
292
+ private MaterialProperty m_RimBlendLdotVProp ;
283
293
private MaterialProperty m_RimColorProp ;
284
294
private MaterialProperty m_RimStepProp ;
285
295
private MaterialProperty m_RimFeatherProp ;
@@ -357,7 +367,7 @@ public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] pro
357
367
m_OcclusionStrengthProp = FindProperty ( MPropertyNames . OcclusionStrength , properties , false ) ;
358
368
m_EmissionMapProp = FindProperty ( MPropertyNames . EmissionMap , properties , false ) ;
359
369
m_EmissionColorProp = FindProperty ( MPropertyNames . EmissionColor , properties , false ) ;
360
- m_EnableHairSpecularProp = FindProperty ( MPropertyNames . EnableHairSpecular , properties , false ) ;
370
+ m_SpecularTypeProp = FindProperty ( MPropertyNames . SpecularType , properties , false ) ;
361
371
362
372
//Outline
363
373
m_EnableOutlineProp = FindProperty ( MPropertyNames . EnableOutline , properties , false ) ;
@@ -367,7 +377,8 @@ public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] pro
367
377
368
378
//Rim
369
379
m_RimFlipProp = FindProperty ( MPropertyNames . RimFlip , properties , false ) ;
370
- m_RimBlendProp = FindProperty ( MPropertyNames . RimBlend , properties , false ) ;
380
+ m_RimBlendShadowProp = FindProperty ( MPropertyNames . RimBlendShadow , properties , false ) ;
381
+ m_RimBlendLdotVProp = FindProperty ( MPropertyNames . RimBlendLdotV , properties , false ) ;
371
382
m_RimColorProp = FindProperty ( MPropertyNames . RimColor , properties , false ) ;
372
383
m_RimStepProp = FindProperty ( MPropertyNames . RimStep , properties , false ) ;
373
384
m_RimFeatherProp = FindProperty ( MPropertyNames . RimFeather , properties , false ) ;
@@ -473,7 +484,8 @@ private void SetMaterialKeywords(Material material)
473
484
SetKeyword ( material , "_EMISSION" , hasEmissionMap || emissionColor != Color . black ) ;
474
485
475
486
// HairSpecular
476
- SetKeyword ( material , "_HAIRSPECULAR" , material . HasProperty ( MPropertyNames . EnableHairSpecular ) && material . GetFloat ( MPropertyNames . EnableHairSpecular ) == 1.0f ) ;
487
+ SetKeyword ( material , "_HAIRSPECULAR" , material . HasProperty ( MPropertyNames . SpecularType ) && material . GetFloat ( MPropertyNames . SpecularType ) == 2.0f ) ;
488
+ SetKeyword ( material , "_HAIRSPECULARVIEWNORMAL" , material . HasProperty ( MPropertyNames . SpecularType ) && material . GetFloat ( MPropertyNames . SpecularType ) == 1.0f ) ;
477
489
478
490
//Outline
479
491
SetKeyword ( material , "_USESMOOTHNORMAL" , material . GetFloat ( MPropertyNames . UseSmoothNormal ) == 1.0 ) ;
@@ -887,10 +899,19 @@ private void DrawSpecularProperties(MaterialEditor materialEditor)
887
899
}
888
900
889
901
// HairSpecular
890
- if ( material . HasProperty ( MPropertyNames . EnableHairSpecular ) )
902
+ if ( material . HasProperty ( MPropertyNames . SpecularType ) )
891
903
{
892
- materialEditor . ShaderProperty ( m_EnableHairSpecularProp , Styles . EnableHairSpecular ) ;
893
- if ( m_EnableHairSpecularProp . floatValue == 1.0 )
904
+ EditorGUI . showMixedValue = m_SpecularTypeProp . hasMixedValue ;
905
+ EditorGUI . BeginChangeCheck ( ) ;
906
+ var specularType = EditorGUILayout . Popup ( Styles . SpecularType , ( int ) m_SpecularTypeProp . floatValue , Enum . GetNames ( typeof ( SpecularType ) ) ) ;
907
+ if ( EditorGUI . EndChangeCheck ( ) )
908
+ {
909
+ materialEditor . RegisterPropertyChangeUndo ( Styles . SpecularType . text ) ;
910
+ m_SpecularTypeProp . floatValue = specularType ;
911
+ }
912
+ EditorGUI . showMixedValue = false ;
913
+
914
+ if ( m_SpecularTypeProp . floatValue == 2.0 )
894
915
{
895
916
materialEditor . TexturePropertySingleLine ( Styles . SpecularShiftMap , m_SpeculatShiftMapProp , m_SpecularShiftIntensityProp ) ;
896
917
materialEditor . TextureScaleOffsetProperty ( m_SpeculatShiftMapProp ) ;
@@ -919,13 +940,15 @@ private void DrawRimProperties(MaterialEditor materialEditor)
919
940
materialEditor . ShaderProperty ( m_RimFlipProp , Styles . RimFlip ) ;
920
941
EditorGUI . BeginChangeCheck ( ) ;
921
942
EditorGUI . indentLevel += 2 ;
922
- var rimBlend = EditorGUILayout . Slider ( Styles . RimBlend , m_RimBlendProp . floatValue , 0f , 1f ) ;
943
+ var rimBlendShadow = EditorGUILayout . Slider ( Styles . RimBlendShadow , m_RimBlendShadowProp . floatValue , 0f , 1f ) ;
944
+ var rimBlendLdotV = EditorGUILayout . Slider ( Styles . RimBlendLdotV , m_RimBlendLdotVProp . floatValue , 0f , 1f ) ;
923
945
var rimStep = EditorGUILayout . Slider ( Styles . RimStep , m_RimStepProp . floatValue , 0f , 1f ) ;
924
946
var rimFeather = EditorGUILayout . Slider ( Styles . RimFeather , m_RimFeatherProp . floatValue , 0f , 1f ) ;
925
947
EditorGUI . indentLevel -= 2 ;
926
948
if ( EditorGUI . EndChangeCheck ( ) )
927
949
{
928
- m_RimBlendProp . floatValue = rimBlend ;
950
+ m_RimBlendShadowProp . floatValue = rimBlendShadow ;
951
+ m_RimBlendLdotVProp . floatValue = rimBlendLdotV ;
929
952
m_RimStepProp . floatValue = rimStep ;
930
953
m_RimFeatherProp . floatValue = rimFeather ;
931
954
}
0 commit comments