Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
12 changes: 7 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ if(NOT pxr_FOUND)
find_package(pxr REQUIRED)
endif()

# Skip hdMoonray if USD is less than 0.25.5
if(PXR_VERSION VERSION_LESS 2505)
message(STATUS "Skipping hdMoonray build because USD version is less than 0.25.5")
install(CODE " # Empty install action ")
return()
endif()

# This is needed for linking against the USD 0.25.5 libraries
# as they depend on OpenGL but don't specify it in
# their cmake config.
Expand Down Expand Up @@ -135,9 +142,4 @@ install(FILES
${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}-${PROJECT_VERSION}
)

install(
DIRECTORY testSuite
DESTINATION .
USE_SOURCE_PERMISSIONS
)

22 changes: 18 additions & 4 deletions cmake/HatsTest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,27 @@
function(add_hats_test test_basename)
# test_basename: basename of tests. By convention includes relative folder structure, example: geometry_basis_curves

cmake_parse_arguments(ARG "" "CAMERA" "" ${ARGN})
set(oneValueArgs CAMERA RENDER_SETTINGS)
cmake_parse_arguments(ARG "" "${oneValueArgs}" "" ${ARGN})
if (DEFINED ARG_CAMERA)
set(camera_opt -camera "${ARG_CAMERA}")
set(camera_opt "cam=${ARG_CAMERA}")
endif()
if (DEFINED ARG_RENDER_SETTINGS)
set(rs_opt "rs=${ARG_RENDER_SETTINGS}")
endif()

set(input_usd ${CMAKE_CURRENT_SOURCE_DIR}/${test_basename}.usd)
set(generated_rdl ${CMAKE_CURRENT_BINARY_DIR}/${test_basename}.rdla)
set(canonical_rdl ${CMAKE_CURRENT_SOURCE_DIR}/${test_basename}.canonical.rdla)
set(generated_exr ${CMAKE_CURRENT_BINARY_DIR}/${test_basename}.exr)
set(canonical_exr ${CMAKE_CURRENT_BINARY_DIR}/${test_basename}.canonical.exr)

set(dummy_exr /tmp/${test_basename}_dummy.exr)

set(generate_test_name hats_generate_${test_basename})

add_test(NAME ${generate_test_name}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMAND hd_usd2rdl -in "${input_usd}" -out "${generated_rdl}" ${camera_opt}
COMMAND python "${CMAKE_SOURCE_DIR}/cmake/generate_rdla.py" "${input_usd}" "${generated_rdl}" ${rs_opt} ${camera_opt}
)
set_tests_properties(${generate_test_name} PROPERTIES
LABELS "generate"
Expand Down Expand Up @@ -68,4 +74,12 @@ function(add_hats_test test_basename)
LABELS "render"
DEPENDS ${generate_test_name}
)

set(rendercanonical_test_name hats_rendercanonical_${test_basename})
add_test(NAME ${rendercanonical_test_name}
COMMAND moonray -in "${canonical_rdl}" -out "${canonical_exr}"
)
set_tests_properties(${rendercanonical_test_name} PROPERTIES
LABELS "rendercanonical"
)
endfunction()
57 changes: 57 additions & 0 deletions cmake/generate_rdla.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@

# Script to generate rdla from usd using usdrecord.
# It fixes up elements that vary between runs, like hex ids, to enable stable comparison

import os
import sys
import re

if len(sys.argv) < 3:
print("Usage: generate_rdla.py <input_path> <output_path> [rs=<rendersettings>] [cam=<camera>]")
sys.exit(1)
input_path = sys.argv[1]
output_path = sys.argv[2]
tmp_path = "/tmp/generate_tmp.rdla"
if os.path.exists(output_path):
os.remove(output_path)
if os.path.exists(tmp_path):
os.remove(tmp_path)

camera_arg = ""
rs_arg = ""
for i in range(3, len(sys.argv)):
if sys.argv[i].startswith("cam="):
camera_arg = "-cam " + sys.argv[i].split("=")[1]
elif sys.argv[i].startswith("rs="):
rs_arg = "-rs " + sys.argv[i].split("=")[1]
else:
print("Unknown argument: ", sys.argv[i])
sys.exit(1)

os.environ["HDMOONRAY_DISABLE_RENDER"] = "1"
os.environ["HDMOONRAY_RDLA_OUTPUT"] = tmp_path
os.environ["HDMOONRAY_SIMPLIFY_PATHS"] = "1"
os.environ["USDIMAGINGGL_ENGINE_ENABLE_SCENE_INDEX"] = "1"

cmd = f"usdrecord -r Moonray -c medium --disableCameraLight {camera_arg} {rs_arg} {input_path} /tmp/dummy.exr"
print("Running command: ", cmd)
ret = os.system(cmd)
if ret:
sys.exit(ret)

if not os.path.exists(tmp_path):
print("Error: tmp file not created: ", tmp_path)
sys.exit(1)

# replace sequences of 16 hex digits with "H16X"
reps = [ (re.compile(r'_UsdImaging_HdMoonrayRendererPlugin_0x[0-9a-fA-F]{2,16}') , "_UsdImaging_HdMoonrayRendererPlugin_0xID")
]

with open(tmp_path, "r") as f:
data = f.read()

for regex, replacement in reps:
data = re.sub(regex, replacement, data)

with open(output_path, "w") as f:
f.write(data)
2 changes: 0 additions & 2 deletions cmd/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# Copyright 2023-2024 DreamWorks Animation LLC
# SPDX-License-Identifier: Apache-2.0


add_subdirectory(hd_cmd)
add_subdirectory(usd_mipmap_images)
5 changes: 0 additions & 5 deletions cmd/hd_cmd/CMakeLists.txt

This file was deleted.

48 changes: 0 additions & 48 deletions cmd/hd_cmd/hd_render/CMakeLists.txt

This file was deleted.

141 changes: 0 additions & 141 deletions cmd/hd_cmd/hd_render/FreeCamera.cc

This file was deleted.

37 changes: 0 additions & 37 deletions cmd/hd_cmd/hd_render/FreeCamera.h

This file was deleted.

Loading