beersandrew / usd-thumbnail-generator

Given a USD file, take a picture and assign it as it's thumbnail.
Creative Commons Zero v1.0 Universal
14 stars 1 forks source link

USD Thumbnail Generator

Purpose

Given a USD file, take a picture and assign it as it's thumbnail.

Usage

Single File Generation: python generate_thumbnail.py --usd-file <usd_file> Generation for Entire Directory: python generate_thumbnail.py --directory <directory> Generation for Entire Directory and Recursive Child Folders: python generate_thumbnail.py --directory <directory> --recursive

optional arguments:

How it works

Given a USD file to use as the subject of the thumbnail do the following

  1. Generate a camera such that the subject is in view
  2. Sublayer the subject in the camera
  3. Run usdrecord to take a snapshot and store it in /thumbnails/<input>.png
    • macOS
      • usdrecord --camera ZCamera --imageWidth 2048 --renderer Metal camera.usda <input>.png
    • windows
      • usdrecord --camera ZCamera --imageWidth 2048 --renderer GL camera.usda <input>.png
      • note: this will run with shell=True for the subprocess call
    • linux
      • usdrecord --camera ZCamera --imageWidth 2048 --renderer Metal camera.usda <input>.png
    • ZCamera & camera.usda are generated in step 2
  4. If the file is not a USDZ file, assign that image as the usd's thumbnail image
  5. If the file is a USDZ file, create a new <subject_usd_file>_Thumbnail.usda, assign the image as the thumbnail, and sublayer <subject_usd_file>.usdz
  6. If --create-usdz-result is passed in, combine all of the files into a USDZ, in the case of a USD file it would be the input file and the image. In the case of a USDZ file it would be the new USDA, the image, and the input USDZ

Thumbnail Usage

Thumbnails are being used in these apps: