Skip to content

Instantly share code, notes, and snippets.

@ChristopherBiscardi
Created October 7, 2025 02:48
Show Gist options
  • Save ChristopherBiscardi/eb3dfb2952bd6c9ee5fa57bdaf3ebd80 to your computer and use it in GitHub Desktop.
Save ChristopherBiscardi/eb3dfb2952bd6c9ee5fa57bdaf3ebd80 to your computer and use it in GitHub Desktop.
Converting .exr files from Substance Designer to ktx2
def process_graph [prefix: string; target: string] {
ktx create --format R32G32B32A32_SFLOAT $'assets/raw_assets/($prefix)_base_color.exr' $'($target)/($prefix)_base_color.ktx2'
ktx create --format R32G32B32A32_SFLOAT $'assets/raw_assets/($prefix)_normal_map.exr' $'($target)/($prefix)_normal_map.ktx2'
ktx create --format R32G32B32A32_SFLOAT $'assets/raw_assets/($prefix)_metallic_roughness.exr' $'($target)/($prefix)_metallic_roughness.ktx2'
oiiotool $'assets/raw_assets/($prefix)_depth_map.exr' -chnames R -o $'($target)/($prefix)_intermediate_depth_map.exr'
ktx create --format R32_SFLOAT $'($target)/($prefix)_intermediate_depth_map.exr' $'($target)/($prefix)_depth_map.ktx2'
}
# convert the "processed_single" images into the "processed" directory
# process_graph "floor_graph" "assets/processed-single"
## layers 3
def process_graph_to_texture_array [target: string] {
ktx create --format R32G32B32A32_SFLOAT --layers 3 assets/raw_assets/floor_graph_base_color.exr assets/raw_assets/grass_graph_base_color.exr assets/raw_assets/stone_graph_base_color.exr $'($target)/array_base_color.ktx2'
ktx create --format R32G32B32A32_SFLOAT --layers 3 assets/raw_assets/floor_graph_normal_map.exr assets/raw_assets/grass_graph_normal_map.exr assets/raw_assets/stone_graph_normal_map.exr $'($target)/array_normal_map.ktx2'
ktx create --format R32G32B32A32_SFLOAT --layers 3 assets/raw_assets/floor_graph_metallic_roughness.exr assets/raw_assets/grass_graph_metallic_roughness.exr assets/raw_assets/stone_graph_metallic_roughness.exr $'($target)/array_metallic_roughness.ktx2'
oiiotool $'assets/raw_assets/floor_graph_depth_map.exr' -chnames R -o $'($target)/floor_graph_intermediate_depth_map.exr'
oiiotool $'assets/raw_assets/grass_graph_depth_map.exr' -chnames R -o $'($target)/grass_graph_intermediate_depth_map.exr'
oiiotool $'assets/raw_assets/stone_graph_depth_map.exr' -chnames R -o $'($target)/stone_graph_intermediate_depth_map.exr'
ktx create --format R32G32B32A32_SFLOAT --layers 3 $'($target)/floor_graph_intermediate_depth_map.exr' $'($target)/grass_graph_intermediate_depth_map.exr' $'($target)/stone_graph_intermediate_depth_map.exr' $'($target)/array_depth_map.ktx2'
}
process_graph_to_texture_array "assets/processed_array"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment