Dunfey · Hotel WWDC as data, est. 1983
Front desk everything
Years
Topics

2022 Spatial ComputingGraphics & Games

WWDC22 · 22 min · Spatial Computing / Graphics & Games

Explore USD tools and rendering

Discover the latest advancements in tooling to help you generate, inspect, and convert Universal Scene Description (USD) assets. We’ll learn about updates to these tools and help you integrate them into your content creation pipeline. We’ll also explore the power of USD Hydra rendering, and show how you can integrate it into your own apps. For an introduction to USD, watch "Understand USD fundamentals" from WWDC22.

Watch at developer.apple.com ↗

Transcript all transcripts

Code shown on screen · 7 snippets

Phyton usdconvert --help python · at 3:00 ↗
% python usdzconvert --help
usdzconvert 0.66
usage: usdzconvert inputFile [outputFile]
                   [-h] [-version] [-f file] [-v]
                   [-path path[+path2[...]]]
                   [-url url]
                   [-copyright copyright]
                   [-copytextures]
                   [-metersPerUnit value]
                   // ...
                   [-diffuseColor           r,g,b]
                   [-diffuseColor           <file> fr,fg,fb]
                   [-normal                 x,y,z]
                   [-normal                 <file> fx,fy,fz]
                   // ...
choosing lighting in usda metadata objectivec · at 9:00 ↗
// asset.usda
#usda 1.0
(
    customLayerData = {
        dictionary Apple = {
             int preferredIblVersion = 2
        }
    }
)
Build USD + Hydra python · at 17:50 ↗
// Rosetta
% arch -x86_64 /bin/zsh

// Download source code
% git clone https://github.com/PixarAnimationStudios/USD.git 

// Build USD + Hydra
% python3 USD/build_scripts/build_usd.py --generator Xcode --no-python USDInstall
Load USD ViewController objectivec · at 18:54 ↗
// AAPLViewController.mm

- (void)viewDidAppear
{   
    NSOpenPanel* panel = [NSOpenPanel openPanel];
    panel.allowedContentTypes = @[UTTypeUSD, UTTypeUSDZ];
   
    [panel beginWithCompletionHandler:^(NSModalResponse result) {
        if (result == NSModalResponseOK)
        {
            NSURL* url = panel.URLs[0];
            [self->_renderer setupScene:[url path]];
        }
    }];
}

// AAPLRenderer.mm

- (bool)loadStage:(NSString*)filePath
{
    _stage = UsdStage::Open([filePath UTF8String]);
    // ...
}
Create Scene Camera objectivec · at 19:30 ↗
// AAPLRenderer.mm

- (void)setupCamera
{
    _viewCamera = [[AAPLCamera alloc] initWithRenderer:self];
    
    [self calculateWorldCenterAndSize];
    
    [_viewCamera setDistance:_worldSize];
    [_viewCamera setFocus:_worldCenter];

}
Create Scene Light objectivec · at 19:54 ↗
// AAPLRenderer.mm

GlfSimpleLight computeCameraLight(const GfMatrix4d& cameraTransform)
{
    GlfSimpleLight light;
    light.SetPosition(GfVec4f(cameraPosition[0], cameraPosition[1], cameraPosition[2], 1));
    
    return light;
}
transport to storm objectivec · at 20:17 ↗
// AAPLRenderer.mm

- (void)initializeEngine
{
    _engine.reset(new UsdImagingGLEngine(_stage->GetPseudoRoot().GetPath(),
                                         excludedPaths,
                                         SdfPathVector(),
                                         SdfPath::AbsoluteRootPath(),
                                         driver));
}

// AAPLRenderer.mm

- (HgiTextureHandle)drawWithHydraAt:(double)timeCode
                           viewSize:(CGSize)viewSize
{
      _engine->SetCameraState(modelViewMatrix, projMatrix);
      _engine->SetLightingState(lights, _material, _sceneAmbient);
  
      UsdImagingGLRenderParams params;
      params.clearColor = GfVec4f(0.0f, 0.0f, 0.0f, 0.0f);
      params.frame = timeCode;

      // ... 
}

Resources