@@ -343,21 +343,24 @@ function buildMaterial( material ) {
343343 float2 outputs:result
344344 }
345345
346- def Shader "Texture_${ texture . id } "
346+ def Shader "Texture_${ texture . id } _ ${ mapType } "
347347 {
348348 uniform token info:id = "UsdUVTexture"
349349 asset inputs:file = @textures/Texture_${ texture . id } .jpg@
350350 float2 inputs:st.connect = </Materials/Material_${ material . id } /Transform2d_${ mapType } .outputs:result>
351351 token inputs:wrapS = "repeat"
352352 token inputs:wrapT = "repeat"
353+ float outputs:r
354+ float outputs:g
355+ float outputs:b
353356 float3 outputs:rgb
354357 }` ;
355358
356359 }
357360
358361 if ( material . map !== null ) {
359362
360- parameters . push ( `${ pad } color3f inputs:diffuseColor.connect = </Materials/Material_${ material . id } /Texture_${ material . map . id } .outputs:rgb>` ) ;
363+ parameters . push ( `${ pad } color3f inputs:diffuseColor.connect = </Materials/Material_${ material . id } /Texture_${ material . map . id } _diffuse .outputs:rgb>` ) ;
361364
362365 textures . push ( buildTexture ( material . map , 'diffuse' ) ) ;
363366
@@ -369,7 +372,7 @@ function buildMaterial( material ) {
369372
370373 if ( material . emissiveMap !== null ) {
371374
372- parameters . push ( `${ pad } color3f inputs:emissiveColor.connect = </Materials/Material_${ material . id } /Texture_${ material . emissiveMap . id } .outputs:rgb>` ) ;
375+ parameters . push ( `${ pad } color3f inputs:emissiveColor.connect = </Materials/Material_${ material . id } /Texture_${ material . emissiveMap . id } _emissive .outputs:rgb>` ) ;
373376
374377 textures . push ( buildTexture ( material . emissiveMap , 'emissive' ) ) ;
375378
@@ -381,15 +384,15 @@ function buildMaterial( material ) {
381384
382385 if ( material . normalMap !== null ) {
383386
384- parameters . push ( `${ pad } normal3f inputs:normal.connect = </Materials/Material_${ material . id } /Texture_${ material . normalMap . id } .outputs:rgb>` ) ;
387+ parameters . push ( `${ pad } normal3f inputs:normal.connect = </Materials/Material_${ material . id } /Texture_${ material . normalMap . id } _normal .outputs:rgb>` ) ;
385388
386389 textures . push ( buildTexture ( material . normalMap , 'normal' ) ) ;
387390
388391 }
389392
390393 if ( material . aoMap !== null ) {
391394
392- parameters . push ( `${ pad } float inputs:occlusion.connect = </Materials/Material_${ material . id } /Texture_${ material . aoMap . id } .outputs:r>` ) ;
395+ parameters . push ( `${ pad } float inputs:occlusion.connect = </Materials/Material_${ material . id } /Texture_${ material . aoMap . id } _occlusion .outputs:r>` ) ;
393396
394397 textures . push ( buildTexture ( material . aoMap , 'occlusion' ) ) ;
395398
@@ -409,7 +412,7 @@ function buildMaterial( material ) {
409412
410413 if ( material . metalnessMap !== null ) {
411414
412- parameters . push ( `${ pad } float inputs:metallic.connect = </Materials/Material_${ material . id } /Texture_${ material . metalnessMap . id } _metalness .outputs:b>` ) ;
415+ parameters . push ( `${ pad } float inputs:metallic.connect = </Materials/Material_${ material . id } /Texture_${ material . metalnessMap . id } _metallic .outputs:b>` ) ;
413416
414417 textures . push ( buildTexture ( material . metalnessMap , 'metallic' ) ) ;
415418
@@ -422,30 +425,30 @@ function buildMaterial( material ) {
422425 parameters . push ( `${ pad } float inputs:opacity = ${ material . opacity } ` ) ;
423426
424427 return `
425- def Material "Material_${ material . id } "
426- {
427- def Shader "PreviewSurface"
428- {
429- uniform token info:id = "UsdPreviewSurface"
428+ def Material "Material_${ material . id } "
429+ {
430+ def Shader "PreviewSurface"
431+ {
432+ uniform token info:id = "UsdPreviewSurface"
430433${ parameters . join ( '\n' ) }
431- int inputs:useSpecularWorkflow = 0
432- token outputs:surface
433- }
434+ int inputs:useSpecularWorkflow = 0
435+ token outputs:surface
436+ }
434437
435- token outputs:surface.connect = </Materials/Material_${ material . id } /PreviewSurface.outputs:surface>
436- token inputs:frame:stPrimvarName = "st"
438+ token outputs:surface.connect = </Materials/Material_${ material . id } /PreviewSurface.outputs:surface>
439+ token inputs:frame:stPrimvarName = "st"
437440
438- def Shader "uvReader_st"
439- {
440- uniform token info:id = "UsdPrimvarReader_float2"
441- token inputs:varname.connect = </Materials/Material_${ material . id } .inputs:frame:stPrimvarName>
442- float2 inputs:fallback = (0.0, 0.0)
443- float2 outputs:result
444- }
441+ def Shader "uvReader_st"
442+ {
443+ uniform token info:id = "UsdPrimvarReader_float2"
444+ token inputs:varname.connect = </Materials/Material_${ material . id } .inputs:frame:stPrimvarName>
445+ float2 inputs:fallback = (0.0, 0.0)
446+ float2 outputs:result
447+ }
445448
446449${ textures . join ( '\n' ) }
447450
448- }
451+ }
449452` ;
450453
451454}
0 commit comments