@@ -43,30 +43,31 @@ public enum SmoothnessMapChannel
43
43
44
44
private static class Styles
45
45
{
46
- public static GUIContent uvSetLabel = EditorGUIUtility . TrTextContent ( "UV Set" ) ;
47
-
48
- public static GUIContent albedoText = EditorGUIUtility . TrTextContent ( "Albedo" , "Albedo (RGB) and Transparency (A)" ) ;
49
- public static GUIContent alphaCutoffText = EditorGUIUtility . TrTextContent ( "Alpha Cutoff" , "Threshold for alpha cutoff" ) ;
50
- public static GUIContent specularMapText = EditorGUIUtility . TrTextContent ( "Specular" , "Specular (RGB) and Smoothness (A)" ) ;
51
- public static GUIContent metallicMapText = EditorGUIUtility . TrTextContent ( "Metallic" , "Metallic (R) and Smoothness (A)" ) ;
52
- public static GUIContent smoothnessText = EditorGUIUtility . TrTextContent ( "Smoothness" , "Smoothness value" ) ;
53
- public static GUIContent smoothnessScaleText = EditorGUIUtility . TrTextContent ( "Smoothness" , "Smoothness scale factor" ) ;
54
- public static GUIContent smoothnessMapChannelText = EditorGUIUtility . TrTextContent ( "Source" , "Smoothness texture and channel" ) ;
55
- public static GUIContent highlightsText = EditorGUIUtility . TrTextContent ( "Specular Highlights" , "Specular Highlights" ) ;
56
- public static GUIContent reflectionsText = EditorGUIUtility . TrTextContent ( "Reflections" , "Glossy Reflections" ) ;
57
- public static GUIContent normalMapText = EditorGUIUtility . TrTextContent ( "Normal Map" , "Normal Map" ) ;
58
- public static GUIContent heightMapText = EditorGUIUtility . TrTextContent ( "Height Map" , "Height Map (G)" ) ;
59
- public static GUIContent occlusionText = EditorGUIUtility . TrTextContent ( "Occlusion" , "Occlusion (G)" ) ;
60
- public static GUIContent emissionText = EditorGUIUtility . TrTextContent ( "Color" , "Emission (RGB)" ) ;
61
- public static GUIContent detailMaskText = EditorGUIUtility . TrTextContent ( "Detail Mask" , "Mask for Secondary Maps (A)" ) ;
62
- public static GUIContent detailAlbedoText = EditorGUIUtility . TrTextContent ( "Detail Albedo x2" , "Albedo (RGB) multiplied by 2" ) ;
63
- public static GUIContent detailNormalMapText = EditorGUIUtility . TrTextContent ( "Normal Map" , "Normal Map" ) ;
46
+ public static GUIContent uvSetLabel = new GUIContent ( "UV Set" ) ;
47
+
48
+ public static GUIContent albedoText = new GUIContent ( "Albedo" , "Albedo (RGB) and Transparency (A)" ) ;
49
+ public static GUIContent alphaCutoffText = new GUIContent ( "Alpha Cutoff" , "Threshold for alpha cutoff" ) ;
50
+ public static GUIContent specularMapText = new GUIContent ( "Specular" , "Specular (RGB) and Smoothness (A)" ) ;
51
+ public static GUIContent metallicMapText = new GUIContent ( "Metallic" , "Metallic (R) and Smoothness (A)" ) ;
52
+ public static GUIContent smoothnessText = new GUIContent ( "Smoothness" , "Smoothness value" ) ;
53
+ public static GUIContent smoothnessScaleText = new GUIContent ( "Smoothness" , "Smoothness scale factor" ) ;
54
+ public static GUIContent smoothnessMapChannelText = new GUIContent ( "Source" , "Smoothness texture and channel" ) ;
55
+ public static GUIContent highlightsText = new GUIContent ( "Specular Highlights" , "Specular Highlights" ) ;
56
+ public static GUIContent reflectionsText = new GUIContent ( "Reflections" , "Glossy Reflections" ) ;
57
+ public static GUIContent normalMapText = new GUIContent ( "Normal Map" , "Normal Map" ) ;
58
+ public static GUIContent heightMapText = new GUIContent ( "Height Map" , "Height Map (G)" ) ;
59
+ public static GUIContent occlusionText = new GUIContent ( "Occlusion" , "Occlusion (G)" ) ;
60
+ public static GUIContent emissionText = new GUIContent ( "Color" , "Emission (RGB)" ) ;
61
+ public static GUIContent detailMaskText = new GUIContent ( "Detail Mask" , "Mask for Secondary Maps (A)" ) ;
62
+ public static GUIContent detailAlbedoText = new GUIContent ( "Detail Albedo x2" , "Albedo (RGB) multiplied by 2" ) ;
63
+ public static GUIContent detailNormalMapText = new GUIContent ( "Normal Map" , "Normal Map" ) ;
64
64
65
65
public static string primaryMapsText = "Main Maps" ;
66
66
public static string secondaryMapsText = "Secondary Maps" ;
67
67
public static string forwardText = "Forward Rendering Options" ;
68
68
public static string renderingMode = "Rendering Mode" ;
69
69
public static string advancedText = "Advanced Options" ;
70
+ public static GUIContent emissiveWarning = new GUIContent ( "Emissive value is animated but the material has not been configured to support emissive. Please make sure the material itself has some amount of emissive." ) ;
70
71
public static readonly string [ ] blendNames = Enum . GetNames ( typeof ( BlendMode ) ) ;
71
72
}
72
73
@@ -103,6 +104,7 @@ private static class Styles
103
104
104
105
MaterialEditor m_MaterialEditor ;
105
106
WorkflowMode m_WorkflowMode = WorkflowMode . Specular ;
107
+ ColorPickerHDRConfig m_ColorPickerHDRConfig = new ColorPickerHDRConfig ( 0f , 99f , 1 / 99f , 3f ) ;
106
108
107
109
bool m_FirstTimeApply = true ;
108
110
@@ -169,7 +171,7 @@ public void FindProperties(MaterialProperty[] props)
169
171
bumpMapDXTScalers = FindProperty ( "_BumpMapDXTScalers" , props ) ;
170
172
detailNormalMapDXTScalers = FindProperty ( "_DetailNormalMapDXTScalers" , props ) ;
171
173
emissionMapDXTScalers = FindProperty ( "_EmissionMapDXTScalers" , props ) ;
172
-
174
+
173
175
mainTexColorSpaceOrigin = FindProperty ( "_MainTexColorSpaceOrigin" , props ) ;
174
176
mainTexColorSpaceVector1 = FindProperty ( "_MainTexColorSpaceVector1" , props ) ;
175
177
mainTexColorSpaceVector2 = FindProperty ( "_MainTexColorSpaceVector2" , props ) ;
@@ -250,7 +252,7 @@ public void ShaderPropertiesGUI(Material material)
250
252
GUILayout . Label ( Styles . primaryMapsText , EditorStyles . boldLabel ) ;
251
253
DoAlbedoArea ( material ) ;
252
254
DoSpecularMetallicArea ( ) ;
253
- DoNormalArea ( ) ;
255
+ m_MaterialEditor . TexturePropertySingleLine ( Styles . normalMapText , bumpMap , bumpMap . textureValue != null ? bumpScale : null ) ;
254
256
m_MaterialEditor . TexturePropertySingleLine ( Styles . heightMapText , heightMap , heightMap . textureValue != null ? heigtMapScale : null ) ;
255
257
m_MaterialEditor . TexturePropertySingleLine ( Styles . occlusionText , occlusionMap , occlusionMap . textureValue != null ? occlusionStrength : null ) ;
256
258
m_MaterialEditor . TexturePropertySingleLine ( Styles . detailMaskText , detailMask ) ;
@@ -286,8 +288,8 @@ public void ShaderPropertiesGUI(Material material)
286
288
287
289
EditorGUILayout . Space ( ) ;
288
290
289
- // NB renderqueue editor is not shown on purpose: we want to override it based on blend mode
290
291
GUILayout . Label ( Styles . advancedText , EditorStyles . boldLabel ) ;
292
+ m_MaterialEditor . RenderQueueField ( ) ;
291
293
m_MaterialEditor . EnableInstancingField ( ) ;
292
294
m_MaterialEditor . DoubleSidedGIField ( ) ;
293
295
}
@@ -361,18 +363,6 @@ void BlendModePopup()
361
363
EditorGUI . showMixedValue = false ;
362
364
}
363
365
364
- void DoNormalArea ( )
365
- {
366
- m_MaterialEditor . TexturePropertySingleLine ( Styles . normalMapText , bumpMap , bumpMap . textureValue != null ? bumpScale : null ) ;
367
- if ( bumpScale . floatValue != 1 && UnityEditorInternal . InternalEditorUtility . IsMobilePlatform ( EditorUserBuildSettings . activeBuildTarget ) )
368
- if ( m_MaterialEditor . HelpBoxWithButton (
369
- EditorGUIUtility . TrTextContent ( "Bump scale is not supported on mobile platforms" ) ,
370
- EditorGUIUtility . TrTextContent ( "Fix Now" ) ) )
371
- {
372
- bumpScale . floatValue = 1 ;
373
- }
374
- }
375
-
376
366
void DoAlbedoArea ( Material material )
377
367
{
378
368
m_MaterialEditor . TexturePropertySingleLine ( Styles . albedoText , albedoMap , albedoColor ) ;
@@ -390,7 +380,7 @@ void DoEmissionArea(Material material)
390
380
bool hadEmissionTexture = emissionMap . textureValue != null ;
391
381
392
382
// Texture and HDR color controls
393
- m_MaterialEditor . TexturePropertyWithHDRColor ( Styles . emissionText , emissionMap , emissionColorForRendering , false ) ;
383
+ m_MaterialEditor . TexturePropertyWithHDRColor ( Styles . emissionText , emissionMap , emissionColorForRendering , m_ColorPickerHDRConfig , false ) ;
394
384
395
385
// If texture was assigned and color was black set color to white
396
386
float brightness = emissionColorForRendering . colorValue . maxColorComponent ;
@@ -546,15 +536,14 @@ private bool CheckIfPreprocessWillBeLong()
546
536
}
547
537
548
538
549
-
550
539
/*********************************************************************/
551
540
/*********************************************************************/
552
541
/*************Procedural Stochastic Texturing Pre-process*************/
553
542
/*********************************************************************/
554
543
/*********************************************************************/
555
- const float GAUSSIAN_AVERAGE = 0.5f ; // Expectation of the Gaussian distribution
556
- const float GAUSSIAN_STD = 0.16666f ; // Std of the Gaussian distribution
557
- const int LUT_WIDTH = 128 ; // Size of the look-up table
544
+ const float GAUSSIAN_AVERAGE = 0.5f ; // Expectation of the Gaussian distribution
545
+ const float GAUSSIAN_STD = 0.16666f ; // Std of the Gaussian distribution
546
+ const int LUT_WIDTH = 128 ; // Size of the look-up table
558
547
559
548
struct TextureData
560
549
{
@@ -1056,7 +1045,7 @@ TextureData TextureToTextureData(Texture2D input, ref TextureFormat inputFormat)
1056
1045
// Copy input texture pixel data
1057
1046
Color [ ] colors = input . GetPixels ( ) ;
1058
1047
TextureData res = new TextureData ( input . width , input . height ) ;
1059
- for ( int x = 0 ; x < res . width ; x ++ )
1048
+ for ( int x = 0 ; x < res . width ; x ++ )
1060
1049
{
1061
1050
for ( int y = 0 ; y < res . height ; y ++ )
1062
1051
{
@@ -1130,10 +1119,10 @@ void SerializePrecomputedTextures(Texture2D input, ref TextureFormat inputFormat
1130
1119
}
1131
1120
1132
1121
private void Precomputations (
1133
- ref TextureData input , // input: example image
1134
- List < int > channels , // input: channels to process
1135
- ref TextureData Tinput , // output: T(input) image
1136
- ref TextureData invT , // output: T^{-1} look-up table
1122
+ ref TextureData input , // input: example image
1123
+ List < int > channels , // input: channels to process
1124
+ ref TextureData Tinput , // output: T(input) image
1125
+ ref TextureData invT , // output: T^{-1} look-up table
1137
1126
string inputName ,
1138
1127
ref int stepCounter ,
1139
1128
int totalSteps )
@@ -1195,7 +1184,7 @@ private void RescaleForDXTCompression(ref TextureData Tinput, ref Vector3 DXTSca
1195
1184
}
1196
1185
}
1197
1186
}
1198
-
1187
+
1199
1188
/*****************************************************************************/
1200
1189
/**************** Section 1.3.1 Target Gaussian distribution *****************/
1201
1190
/*****************************************************************************/
@@ -1260,7 +1249,7 @@ private float invCDF(float U, float mu, float sigma)
1260
1249
float x = sigma * Mathf . Sqrt ( 2.0f ) * ErfInv ( 2.0f * U - 1.0f ) + mu ;
1261
1250
return x ;
1262
1251
}
1263
-
1252
+
1264
1253
/*****************************************************************************/
1265
1254
/**** Section 1.3.2 Applying the histogram transformation T on the input *****/
1266
1255
/*****************************************************************************/
@@ -1298,7 +1287,7 @@ private void ComputeTinput(ref TextureData input, ref TextureData T_input, int c
1298
1287
T_input . SetColor ( x , y , channel , G ) ;
1299
1288
}
1300
1289
}
1301
-
1290
+
1302
1291
/*****************************************************************************/
1303
1292
/** Section 1.3.3 Precomputing the inverse histogram transformation T^{-1} ***/
1304
1293
/*****************************************************************************/
@@ -1329,7 +1318,7 @@ private void ComputeinvT(ref TextureData input, ref TextureData Tinv, int channe
1329
1318
Tinv . SetColor ( i , 0 , channel , I ) ;
1330
1319
}
1331
1320
}
1332
-
1321
+
1333
1322
/*****************************************************************************/
1334
1323
/******** Section 1.4 Improvement: using a decorrelated color space **********/
1335
1324
/*****************************************************************************/
@@ -1355,7 +1344,7 @@ private void ComputeEigenVectors(ref TextureData input, Vector3[] eigenVectors)
1355
1344
GB += col . g * col . b ;
1356
1345
}
1357
1346
}
1358
-
1347
+
1359
1348
R /= ( float ) ( input . width * input . height ) ;
1360
1349
G /= ( float ) ( input . width * input . height ) ;
1361
1350
B /= ( float ) ( input . width * input . height ) ;
@@ -1370,15 +1359,15 @@ private void ComputeEigenVectors(ref TextureData input, Vector3[] eigenVectors)
1370
1359
double [ ] [ ] covarMat = new double [ 3 ] [ ] ;
1371
1360
for ( int i = 0 ; i < 3 ; i ++ )
1372
1361
covarMat [ i ] = new double [ 3 ] ;
1373
- covarMat [ 0 ] [ 0 ] = RR - R * R ;
1374
- covarMat [ 0 ] [ 1 ] = RG - R * G ;
1375
- covarMat [ 0 ] [ 2 ] = RB - R * B ;
1376
- covarMat [ 1 ] [ 0 ] = RG - R * G ;
1377
- covarMat [ 1 ] [ 1 ] = GG - G * G ;
1378
- covarMat [ 1 ] [ 2 ] = GB - G * B ;
1379
- covarMat [ 2 ] [ 0 ] = RB - R * B ;
1380
- covarMat [ 2 ] [ 1 ] = GB - G * B ;
1381
- covarMat [ 2 ] [ 2 ] = BB - B * B ;
1362
+ covarMat [ 0 ] [ 0 ] = RR - R * R ;
1363
+ covarMat [ 0 ] [ 1 ] = RG - R * G ;
1364
+ covarMat [ 0 ] [ 2 ] = RB - R * B ;
1365
+ covarMat [ 1 ] [ 0 ] = RG - R * G ;
1366
+ covarMat [ 1 ] [ 1 ] = GG - G * G ;
1367
+ covarMat [ 1 ] [ 2 ] = GB - G * B ;
1368
+ covarMat [ 2 ] [ 0 ] = RB - R * B ;
1369
+ covarMat [ 2 ] [ 1 ] = GB - G * B ;
1370
+ covarMat [ 2 ] [ 2 ] = BB - B * B ;
1382
1371
1383
1372
// Find eigen values and vectors using Jacobi algorithm
1384
1373
double [ ] [ ] eigenVectorsTemp = new double [ 3 ] [ ] ;
@@ -1388,9 +1377,9 @@ private void ComputeEigenVectors(ref TextureData input, Vector3[] eigenVectors)
1388
1377
ComputeEigenValuesAndVectors ( covarMat , eigenVectorsTemp , eigenValuesTemp ) ;
1389
1378
1390
1379
// Set return values
1391
- eigenVectors [ 0 ] = new Vector3 ( ( float ) eigenVectorsTemp [ 0 ] [ 0 ] , ( float ) eigenVectorsTemp [ 1 ] [ 0 ] , ( float ) eigenVectorsTemp [ 2 ] [ 0 ] ) ;
1392
- eigenVectors [ 1 ] = new Vector3 ( ( float ) eigenVectorsTemp [ 0 ] [ 1 ] , ( float ) eigenVectorsTemp [ 1 ] [ 1 ] , ( float ) eigenVectorsTemp [ 2 ] [ 1 ] ) ;
1393
- eigenVectors [ 2 ] = new Vector3 ( ( float ) eigenVectorsTemp [ 0 ] [ 2 ] , ( float ) eigenVectorsTemp [ 1 ] [ 2 ] , ( float ) eigenVectorsTemp [ 2 ] [ 2 ] ) ;
1380
+ eigenVectors [ 0 ] = new Vector3 ( ( float ) eigenVectorsTemp [ 0 ] [ 0 ] , ( float ) eigenVectorsTemp [ 1 ] [ 0 ] , ( float ) eigenVectorsTemp [ 2 ] [ 0 ] ) ;
1381
+ eigenVectors [ 1 ] = new Vector3 ( ( float ) eigenVectorsTemp [ 0 ] [ 1 ] , ( float ) eigenVectorsTemp [ 1 ] [ 1 ] , ( float ) eigenVectorsTemp [ 2 ] [ 1 ] ) ;
1382
+ eigenVectors [ 2 ] = new Vector3 ( ( float ) eigenVectorsTemp [ 0 ] [ 2 ] , ( float ) eigenVectorsTemp [ 1 ] [ 2 ] , ( float ) eigenVectorsTemp [ 2 ] [ 2 ] ) ;
1394
1383
}
1395
1384
1396
1385
// ----------------------------------------------------------------------------
@@ -1538,12 +1527,12 @@ private int ComputeEigenValuesAndVectors(double[][] A, double[][] Q, double[] w)
1538
1527
1539
1528
// Main function of Section 1.4
1540
1529
private void DecorrelateColorSpace (
1541
- ref TextureData input , // input: example image
1542
- ref TextureData input_decorrelated , // output: decorrelated input
1543
- ref Vector3 colorSpaceVector1 , // output: color space vector1
1544
- ref Vector3 colorSpaceVector2 , // output: color space vector2
1545
- ref Vector3 colorSpaceVector3 , // output: color space vector3
1546
- ref Vector3 colorSpaceOrigin ) // output: color space origin
1530
+ ref TextureData input , // input: example image
1531
+ ref TextureData input_decorrelated , // output: decorrelated input
1532
+ ref Vector3 colorSpaceVector1 , // output: color space vector1
1533
+ ref Vector3 colorSpaceVector2 , // output: color space vector2
1534
+ ref Vector3 colorSpaceVector3 , // output: color space vector3
1535
+ ref Vector3 colorSpaceOrigin ) // output: color space origin
1547
1536
{
1548
1537
// Compute the eigenvectors of the histogram
1549
1538
Vector3 [ ] eigenvectors = new Vector3 [ 3 ] ;
@@ -1752,6 +1741,5 @@ private bool InputIsSelected(int layerToCheck)
1752
1741
MaterialProperty emissionColorSpaceVector1 = null ;
1753
1742
MaterialProperty emissionColorSpaceVector2 = null ;
1754
1743
MaterialProperty emissionColorSpaceVector3 = null ;
1755
-
1756
1744
}
1757
1745
} // namespace UnityEditor
0 commit comments