@@ -329,6 +329,84 @@ private BabylonTexture ExportORMTexture(BabylonScene babylonScene, MFnDependency
329329 return babylonTexture ;
330330 }
331331
332+ private BabylonTexture ExportCoatTexture ( MFnDependencyNode intensityTextureDependencyNode , MFnDependencyNode roughnessTextureDependencyNode , BabylonScene babylonScene , string materialName , float intensity , float roughness )
333+ {
334+ // Prints
335+ if ( intensityTextureDependencyNode != null )
336+ {
337+ Print ( intensityTextureDependencyNode , logRankTexture , "Print ExportCoatTexture intensityTextureDependencyNode" ) ;
338+ }
339+ if ( roughnessTextureDependencyNode != null )
340+ {
341+ Print ( roughnessTextureDependencyNode , logRankTexture , "Print ExportCoatTexture roughnessTextureDependencyNode" ) ;
342+ }
343+
344+ // Use one as a reference for UVs parameters
345+ var textureDependencyNode = intensityTextureDependencyNode != null ? intensityTextureDependencyNode : roughnessTextureDependencyNode ;
346+ if ( textureDependencyNode == null )
347+ {
348+ return null ;
349+ }
350+
351+ var id = textureDependencyNode . uuid ( ) . asString ( ) ;
352+ var babylonTexture = new BabylonTexture ( id )
353+ {
354+ name = materialName + "_coat" + ".jpg" // TODO - unsafe name, may conflict with another texture name
355+ } ;
356+
357+ // Level
358+ babylonTexture . level = 1.0f ;
359+
360+ // Alpha
361+ babylonTexture . hasAlpha = false ;
362+ babylonTexture . getAlphaFromRGB = false ;
363+
364+ // UVs
365+ _exportUV ( textureDependencyNode , babylonTexture ) ;
366+
367+ // Is cube
368+ string sourcePath = getSourcePathFromFileTexture ( textureDependencyNode ) ;
369+ if ( sourcePath == null )
370+ {
371+ return null ;
372+ }
373+ if ( sourcePath == "" )
374+ {
375+ RaiseError ( "Texture path is missing." , logRankTexture + 1 ) ;
376+ return null ;
377+ }
378+ _exportIsCube ( sourcePath , babylonTexture , false ) ;
379+
380+
381+ // --- Merge base color and opacity maps ---
382+
383+ if ( CopyTexturesToOutput )
384+ {
385+ // Load bitmaps
386+ var intensityBitmap = LoadTexture ( intensityTextureDependencyNode ) ;
387+ var roughnessBitmap = LoadTexture ( roughnessTextureDependencyNode ) ;
388+
389+ // Merge bitmaps
390+ Bitmap [ ] bitmaps = new Bitmap [ ] { intensityBitmap , roughnessBitmap , null , null } ;
391+ int [ ] defaultValues = new int [ ] { ( int ) ( intensity * 255 ) , ( int ) ( roughness * 255 ) , 0 , 1 } ;
392+ Bitmap coatBitmap = MergeBitmaps ( bitmaps , defaultValues , "Coat intensity and roughness" ) ;
393+
394+ // Write bitmap
395+ if ( isBabylonExported )
396+ {
397+ RaiseMessage ( $ "Texture | write image '{ babylonTexture . name } '", logRankTexture + 1 ) ;
398+ SaveBitmap ( coatBitmap , babylonScene . OutputPath , babylonTexture . name , System . Drawing . Imaging . ImageFormat . Jpeg ) ;
399+ }
400+ else
401+ {
402+ // Store created bitmap for further use in gltf export
403+ babylonTexture . bitmap = coatBitmap ;
404+ }
405+ }
406+
407+ return babylonTexture ;
408+ }
409+
332410 private BabylonTexture ExportBaseColorAlphaTexture ( MFnDependencyNode baseColorTextureDependencyNode , MFnDependencyNode opacityTextureDependencyNode , BabylonScene babylonScene , string materialName , Color defaultBaseColor , float defaultOpacity = 1.0f )
333411 {
334412 // Prints
0 commit comments