@@ -47,6 +47,7 @@ bool FImport_Processer::Process_JSON_Data(const FString& Filename)
4747 const FString data_ambient_occlusion = json->GetStringField (TEXT (" ambient_occlusion" ));
4848 const FString data_metallic = json->GetStringField (TEXT (" metallic" ));
4949 const FString data_roughness = json->GetStringField (TEXT (" roughness" ));
50+ const FString data_emissive = json->GetStringField (TEXT (" emissive" ));
5051
5152 FString PackageName = TEXT (" /Game/" ) + data_path + data_name;
5253
@@ -58,6 +59,9 @@ bool FImport_Processer::Process_JSON_Data(const FString& Filename)
5859 Package->FullyLoad ();
5960 Package->SetDirtyFlag (true );
6061
62+ int32 position_x = -400 ;
63+ int32 position_y = -300 ;
64+
6165 // Base Color
6266
6367 if (data_base_color != " " ) {
@@ -69,10 +73,15 @@ bool FImport_Processer::Process_JSON_Data(const FString& Filename)
6973 UMaterialExpressionTextureSample* TextureExpression = NewObject<UMaterialExpressionTextureSample>(UnrealMaterial);
7074 TextureExpression->Texture = Texture_Base_Color;
7175 TextureExpression->SamplerType = SAMPLERTYPE_Color;
76+ TextureExpression->MaterialExpressionEditorX = position_x;
77+ TextureExpression->MaterialExpressionEditorY = position_y;
7278 UnrealMaterial->Expressions .Add (TextureExpression);
7379 UnrealMaterial->BaseColor .Expression = TextureExpression;
80+
7481 }
75-
82+
83+ position_y += 300 ;
84+
7685 }
7786
7887 // ORM
@@ -86,14 +95,17 @@ bool FImport_Processer::Process_JSON_Data(const FString& Filename)
8695 UMaterialExpressionTextureSample* TextureExpression = NewObject<UMaterialExpressionTextureSample>(UnrealMaterial);
8796 TextureExpression->Texture = Texture_ORM;
8897 TextureExpression->SamplerType = SAMPLERTYPE_Color;
98+ TextureExpression->MaterialExpressionEditorX = position_x;
99+ TextureExpression->MaterialExpressionEditorY = position_y;
89100 UnrealMaterial->Expressions .Add (TextureExpression);
90-
91101 UnrealMaterial->AmbientOcclusion .Connect (1 , TextureExpression); // R
92102 UnrealMaterial->Roughness .Connect (2 , TextureExpression); // G
93103 UnrealMaterial->Metallic .Connect (3 , TextureExpression); // B
94-
104+
95105 }
96-
106+
107+ position_y += 300 ;
108+
97109 } else {
98110
99111 // Ambient Occlusion
@@ -107,9 +119,13 @@ bool FImport_Processer::Process_JSON_Data(const FString& Filename)
107119 UMaterialExpressionTextureSample* TextureExpression = NewObject<UMaterialExpressionTextureSample>(UnrealMaterial);
108120 TextureExpression->Texture = Texture_Ambient_Occlusion;
109121 TextureExpression->SamplerType = SAMPLERTYPE_Color;
122+ TextureExpression->MaterialExpressionEditorX = position_x;
123+ TextureExpression->MaterialExpressionEditorY = position_y;
110124 UnrealMaterial->Expressions .Add (TextureExpression);
111125 UnrealMaterial->AmbientOcclusion .Expression = TextureExpression;
112126 }
127+
128+ position_y += 300 ;
113129
114130 }
115131
@@ -124,9 +140,13 @@ bool FImport_Processer::Process_JSON_Data(const FString& Filename)
124140 UMaterialExpressionTextureSample* TextureExpression = NewObject<UMaterialExpressionTextureSample>(UnrealMaterial);
125141 TextureExpression->Texture = Texture_Metallic;
126142 TextureExpression->SamplerType = SAMPLERTYPE_Color;
143+ TextureExpression->MaterialExpressionEditorX = position_x;
144+ TextureExpression->MaterialExpressionEditorY = position_y;
127145 UnrealMaterial->Expressions .Add (TextureExpression);
128146 UnrealMaterial->Metallic .Expression = TextureExpression;
129147 }
148+
149+ position_y += 300 ;
130150
131151 }
132152
@@ -141,12 +161,38 @@ bool FImport_Processer::Process_JSON_Data(const FString& Filename)
141161 UMaterialExpressionTextureSample* TextureExpression = NewObject<UMaterialExpressionTextureSample>(UnrealMaterial);
142162 TextureExpression->Texture = Texture_Roughness;
143163 TextureExpression->SamplerType = SAMPLERTYPE_Color;
164+ TextureExpression->MaterialExpressionEditorX = position_x;
165+ TextureExpression->MaterialExpressionEditorY = position_y;
144166 UnrealMaterial->Expressions .Add (TextureExpression);
145167 UnrealMaterial->Roughness .Expression = TextureExpression;
146168 }
169+
170+ position_y += 300 ;
171+
172+ }
173+
174+ }
175+
176+ // Emissive
177+
178+ if (data_emissive != " " ) {
179+
180+ FStringAssetReference AssetPath_Emissive (TEXT (" /Game/" ) + data_path + data_emissive);
181+ UTexture* Texture_Emissive = Cast<UTexture>(AssetPath_Emissive.TryLoad ());
182+ if (Texture_Emissive)
183+ {
184+ UMaterialExpressionTextureSample* TextureExpression = NewObject<UMaterialExpressionTextureSample>(UnrealMaterial);
185+ TextureExpression->Texture = Texture_Emissive;
186+ TextureExpression->SamplerType = SAMPLERTYPE_Color;
187+ TextureExpression->MaterialExpressionEditorX = position_x;
188+ TextureExpression->MaterialExpressionEditorY = position_y;
189+ UnrealMaterial->Expressions .Add (TextureExpression);
190+ UnrealMaterial->EmissiveColor .Expression = TextureExpression;
147191
148192 }
149193
194+ position_y += 300 ;
195+
150196 }
151197
152198 // Normal
@@ -160,9 +206,13 @@ bool FImport_Processer::Process_JSON_Data(const FString& Filename)
160206 UMaterialExpressionTextureSample* TextureExpression = NewObject<UMaterialExpressionTextureSample>(UnrealMaterial);
161207 TextureExpression->Texture = Texture_Normal;
162208 TextureExpression->SamplerType = SAMPLERTYPE_Normal;
209+ TextureExpression->MaterialExpressionEditorX = position_x;
210+ TextureExpression->MaterialExpressionEditorY = position_y;
163211 UnrealMaterial->Expressions .Add (TextureExpression);
164212 UnrealMaterial->Normal .Expression = TextureExpression;
165213 }
214+
215+ position_y += 300 ;
166216
167217 }
168218
0 commit comments