@@ -60,13 +60,31 @@ private static bool FindTexture(int nameID,
6060
6161 // If there is no such texture, create one with the given fallback value:
6262
63- float value = fallbackPropertyValue ;
64- if ( materialProperties . TryGetValue ( fallbackPropertyNameID , out IMaterialPropertyData fallbackMaterialProperty ) )
65- value = fallbackMaterialProperty . floatValue ;
63+ Color value = new Color (
64+ fallbackPropertyValue ,
65+ fallbackPropertyValue ,
66+ fallbackPropertyValue ,
67+ fallbackPropertyValue ) ;
68+
69+ if ( materialProperties . TryGetValue ( fallbackPropertyNameID ,
70+ out IMaterialPropertyData fallbackMaterialProperty ) ) {
71+ switch ( fallbackMaterialProperty . type ) {
72+ case IMaterialPropertyData . Type . Float :
73+ float v = fallbackMaterialProperty . floatValue ;
74+ value = new Color ( v , v , v , v ) ;
75+ break ;
76+ case IMaterialPropertyData . Type . Vector :
77+ value = fallbackMaterialProperty . vectorValue ;
78+ break ;
79+ default :
80+ Debug . LogError ( $ "Unsupported fallback property type: { fallbackMaterialProperty . type } !") ;
81+ break ;
82+ }
83+ }
6684
6785 const int dim = 8 ;
6886
69- Color [ ] pixels = Enumerable . Repeat ( new Color ( value , value , value , value ) , dim * dim ) . ToArray ( ) ;
87+ Color [ ] pixels = Enumerable . Repeat ( value , dim * dim ) . ToArray ( ) ;
7088
7189 disposableTexture =
7290 new Texture2DDisposable ( new Texture2D ( dim , dim , UnityEngine . TextureFormat . RFloat , false , true ) ) ;
@@ -176,7 +194,7 @@ private static void BakeSmoothness(Material destMat,
176194 // Bake to albedo alpha
177195 channelName = MeshSyncConstants . _MainTex ;
178196 texturesExist |=
179- FindTexture ( MeshSyncConstants . _MainTex , textureHolders , materialProperties , 0 , 0 ,
197+ FindTexture ( MeshSyncConstants . _MainTex , textureHolders , materialProperties , MeshSyncConstants . _Color , 0 ,
180198 out rgbTexture ) ;
181199 }
182200 else {
0 commit comments