Skip to content

Instantly share code, notes, and snippets.

@AndrewHazelden
Created April 29, 2026 13:24
Show Gist options
  • Select an option

  • Save AndrewHazelden/01faa206de7335771aa80d7501751133 to your computer and use it in GitHub Desktop.

Select an option

Save AndrewHazelden/01faa206de7335771aa80d7501751133 to your computer and use it in GitHub Desktop.
The script allows you to create an OpenUSD ASCII (.usda) based wrapper for OpenVDB (.vdb) files. This allows USD compatible 3D scengraphs to load the external VDB based voxel datasets. The "USDA Voxel Wrapper.lua" comp script works in Fusion v19-21+ and Resolve v19-21+.
--[[--
----------------------------------------------------------------------------
USDA Voxel Wrapper.lua - 2026-04-20 6.29 AM
y Andrew Hazelden <andrew@andrewhazelden.com>
Overview:
The script allows you to create an OpenUSD ASCII (.usda) based wrapper for OpenVDB (.vdb) files. This allows USD compatible 3D scengraphs to load the external VDB based voxel datasets.
The "USDA Voxel Wrapper.lua" comp script works in Fusion v19-21+ and Resolve v19-21+.
Easy Installation:
The "USDA Voxel Wrapper.lua" script is typically installed in a single click using the "Reactor" Package Manager.
Manual Installation:
Step 1. Copy the script to your Fusion/Resolve Fusion page user preferences Comp based "Scripts:/" PathMap locations at:
Scripts:/Comp/Andrew Hazelden/
*Note: You will need to create these sub-folders by hand since they won't pre-exist on a manual install.
Fusion Standalone Manual Script Install:
On Windows this works out to:
%AppData%\Blackmagic Design\Fusion\Scripts\Comp\Andrew Hazelden\
On Linux this works out to:
$HOME/.fusion/BlackmagicDesign/Fusion/Scripts/Comp/Andrew Hazelden/
On MacOS this works out to:
$HOME/Library/Application Support/Blackmagic Design/Fusion/Scripts/Comp/Andrew Hazelden/
Resolve Fusion Page Manual Script Install:
On Windows this works out to:
%AppData%\Blackmagic Design\DaVinci Resolve\Fusion\Scripts\Comp\Andrew Hazelden
On Linux this works out to:
$HOME/.fusion/BlackmagicDesign/DaVinci Resolve/Fusion/Scripts/Comp/Andrew Hazelden/
On MacOS this works out to:
$HOME/Library/Application Support/Blackmagic Design/DaVinci Resolve/Fusion/Scripts/Comp/Andrew Hazelden/
Usage:
Step 1. Save your Fusion composite to disk.
Step 2. Run the "Script > Andrew Hazelden > USDA Voxel Wrapper" menu item. After adjusting the settings in the dialog window, a new USDA file will be saved to disk.
--]]--
local primName = "vdbFile1"
-- USD ASCII scene scale = CM
local metersPerUnit = 0.01
-- Maya default style Y-axis Up-coordinate system
local upAxis = 'Y'
-- Translate
local tx = 0.0
local ty = 0.0
local tz = 0.0
-- Rotate
local rx = 0.0
local ry = 0.0
local rz = 0.0
-- Scale
local sx = 1.0
local sy = 1.0
local sz = 1.0
-- File I/O paths
local sourceVDBFile = [[cloud_02_variant_0000.vdb]]
local outputUSDAFile = [[/home/vfx/Desktop/VDB2USDA/OpenVDB to USDA/Media/cloud_02_variant_0000.usda]]
------------------------------------------------------------------------
-- Where the magic happens
function Main()
-- Check if Fusion is running
if not fusion then
print('[Error] This script needs to be run from inside of Fusion.')
return
end
-- Check if a composite is open in Fusion Standalone or the Resolve Fusion page
if not comp then
print('[Error] A Fusion composite needs to be open.')
return
end
print('[OpenVDB to USDA Wrapper] ' .. tostring(_VERSION))
print('[Created By] Andrew Hazelden <andrew@andrewhazelden.com>')
-- Open up the file pointer for the output textfile
outFile, err = io.open(outputUSDAFile,'w')
if err then
print('[VDB 2 USDA] [Error opening file for writing] ' .. tostring(outputUSDAFile))
disp:ExitLoop()
end
-- Write a PIXAR USD ASCII header entry
outFile:write('#usda 1.0\n')
outFile:write('(\n')
outFile:write('\tdefaultPrim = "' .. tostring(primName) .. '"\n')
outFile:write('\tmetersPerUnit = ' .. tostring(metersPerUnit) .. '\n')
outFile:write('\tupAxis = "' .. tostring(upAxis) .. '"\n')
outFile:write(')\n')
outFile:write('\n')
outFile:write('def "' .. tostring(primName) .. '" (\n')
outFile:write('\tprepend references = @./' .. tostring(sourceVDBFile) .. '@\n')
outFile:write(')\n')
outFile:write('{\n')
-- Static (non-animated) camera export
-- Rotate XYZ
outFile:write('\tfloat3 xformOp:rotateXYZ = (' .. rx .. ', ' .. ry .. ', ' .. rz .. ')\n')
-- Translate XYZ
outFile:write('\tdouble3 xformOp:translate = (' .. tx .. ', ' .. ty .. ', ' .. tz .. ')\n')
outFile:write('\tuniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ"]\n')
outFile:write('}\n')
-- File writing complete
outFile:write('\n')
-- Close the file pointer on our Camera textfile
outFile:close()
end
-- Run the main function
Main()
print('[Done]')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment