Skip to content

Commit

Permalink
Update baketextures for data library referencing (AcademySoftwareFoun…
Browse files Browse the repository at this point in the history
…dation#2074)

This changelist updates the baketextures.py script to take advantage of data library referencing. i.e. `Document::setDataLibrary`.
  • Loading branch information
jstone-lucasfilm authored Oct 17, 2024
1 parent ea4cea0 commit 12cf234
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions python/Scripts/baketextures.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,7 @@ def main():
parser.add_argument(dest="outputFilename", help="Filename of the output document.")
opts = parser.parse_args()

doc = mx.createDocument()
try:
mx.readFromXmlFile(doc, opts.inputFilename)
except mx.ExceptionFileMissing as err:
print(err)
sys.exit(0)

# Load standard and custom data libraries.
stdlib = mx.createDocument()
searchPath = mx.getDefaultDataSearchPath()
searchPath.append(os.path.dirname(opts.inputFilename))
Expand All @@ -48,21 +42,28 @@ def main():
libraryFolders.append(library)
libraryFolders.extend(mx.getDefaultDataLibraryFolders())
mx.loadLibraries(libraryFolders, searchPath, stdlib)
doc.importLibrary(stdlib)

# Read and validate the source document.
doc = mx.createDocument()
try:
mx.readFromXmlFile(doc, opts.inputFilename)
doc.setDataLibrary(stdlib)
except mx.ExceptionFileMissing as err:
print(err)
sys.exit(0)
valid, msg = doc.validate()
if not valid:
print("Validation warnings for input document:")
print(msg)

# Construct the texture baker.
baseType = mx_render.BaseType.FLOAT if opts.hdr else mx_render.BaseType.UINT8


if platform == "darwin" and not opts.useGlslBackend:
baker = mx_render_msl.TextureBaker.create(opts.width, opts.height, baseType)
else:
baker = mx_render_glsl.TextureBaker.create(opts.width, opts.height, baseType)

# Bake materials to textures.
if opts.average:
baker.setAverageImages(True)
baker.writeDocumentPerMaterial(opts.writeDocumentPerMaterial)
Expand Down

0 comments on commit 12cf234

Please sign in to comment.