Needle Engine

Changes between version 3.22.4 and 3.22.6
Files changed (1) hide show
  1. src/engine-components/export/usdz/ThreeUSDZExporter.ts +15 -1
src/engine-components/export/usdz/ThreeUSDZExporter.ts CHANGED
@@ -1258,8 +1258,15 @@
1258
1258
 
1259
1259
  }
1260
1260
 
1261
- const effectiveOpacity = ( material.transparent || material.alphaTest ) ? material.opacity : 1;
1261
+ let effectiveOpacity = ( material.transparent || material.alphaTest ) ? material.opacity : 1;
1262
1262
 
1263
+ if ( material instanceof MeshPhysicalMaterial && material.transmission !== undefined) {
1264
+
1265
+ // TODO does not help when a roughnessMap is used
1266
+ effectiveOpacity *= (1 - material.transmission * (1 - (material.roughness * 0.5)));
1267
+
1268
+ }
1269
+
1263
1270
  if ( material.side === DoubleSide ) {
1264
1271
 
1265
1272
  console.warn( 'THREE.USDZExporter: USDZ does not support double sided materials', material );
@@ -1374,6 +1381,13 @@
1374
1381
  inputs.push( `${pad}float inputs:clearcoatRoughness = ${material.clearcoatRoughness}` );
1375
1382
  inputs.push( `${pad}float inputs:ior = ${material.ior}` );
1376
1383
 
1384
+ if ( !material.transparent && ! (material.alphaTest > 0.0) && material.transmissionMap) {
1385
+
1386
+ inputs.push( `${pad}float inputs:opacity.connect = </Materials/Material_${material.id}/Texture_${material.transmissionMap.id}_transmission.outputs:r>` );
1387
+
1388
+ samplers.push( buildTexture( material.transmissionMap, 'transmission' ) );
1389
+ }
1390
+
1377
1391
  }
1378
1392
 
1379
1393
  return `