Skip to content

Commit

Permalink
Test out some OpenImageIO openexr filling & compositing.
Browse files Browse the repository at this point in the history
Signed-off-by: furby™ <[email protected]>
  • Loading branch information
furby-tm committed Sep 18, 2024
1 parent 4663bf2 commit edf9881
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 19 deletions.
33 changes: 33 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"originHash" : "441d732484c04a83333068eff13c95e4fa471b615e6733979a17d697b0b22314",
"pins" : [
{
"identity" : "metaversepythonframework",
"kind" : "remoteSourceControl",
"location" : "https://github.com/wabiverse/MetaversePythonFramework",
"state" : {
"revision" : "e2f4ba867b7e287a283a27a0005ab64deef14279",
"version" : "3.11.7"
}
},
{
"identity" : "metaversevulkanframework",
"kind" : "remoteSourceControl",
"location" : "https://github.com/wabiverse/MetaverseVulkanFramework",
"state" : {
"revision" : "13c7061599c61a4959c558d8ec1836e5b32b640b",
"version" : "1.26.2"
}
},
{
"identity" : "pythonkit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pvieito/PythonKit.git",
"state" : {
"revision" : "43647b36cacb99558e57ef98e97ef598f91d1164",
"version" : "0.5.0"
}
}
],
"version" : 3
}
18 changes: 7 additions & 11 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -325,18 +325,14 @@ let package = Package(

.target(
name: "MXResources",
exclude: [
// FIXME:
// temporary workaround for metal shaders
// erroring on compilation, so we don't
// gunk up SwiftUSD and everything else.
"libraries",
"Resources/Lights",
"Resources/Geometry",
"Resources/Materials",
],
resources: [
.process("Resources/Images"),
.copy("libraries"),
.copy("Resources/Geometry"),
.copy("Resources/Images"),
.copy("Resources/Lights"),
.copy("Resources/Materials"),
.copy("Resources/CMakeLists.txt"),
.copy("Resources/README.md"),
],
cxxSettings: [
.define("_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH", .when(platforms: [.windows])),
Expand Down
25 changes: 17 additions & 8 deletions Sources/MetaversalDemo/Creator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,28 +141,37 @@ class Creator
OCIO.GetCurrentConfig()
}

public typealias Extent = OIIO.span_size_t

static func configImaging()
{
/* create some exr images. */
let dtp = OIIO.TypeDesc(.init("FLOAT"))
let dtp = OIIO.TypeDesc(.init("float"))
let fmt = OIIO.ImageSpec(512, 89, 4, dtp)

var fg = OIIO.ImageBuf(.init(std.string("fg.exr")), fmt, OIIO.InitializePixels.Yes)
let bg = OIIO.ImageBuf(.init(std.string("bg.exr")), fmt, OIIO.InitializePixels.Yes)

fg.set_origin(512, 89, 0)
fg.set_origin(0, 0, 0)

let comp = OIIO.ImageBufAlgo.over(fg, bg, fmt.roi(), 0)
if !comp.has_error()
if OIIO.ImageBufAlgo.fill(&fg, .init(Float(0.01)), .init(Float(0.01)), .init(Float(1.0)), .init(Float(0.01)), .init(), 0)
{
if comp.write(.init(std.string("composite.exr")), OIIO.TypeDesc(.init("UNKNOWN")), .init(""), nil, nil) == false || comp.has_error()
let comp = OIIO.ImageBufAlgo.over(fg, bg, .init(), 0)
if !comp.has_error()
{
if comp.write(.init(std.string("composite.exr")), OIIO.TypeDesc(.init("UNKNOWN")), .init(""), nil, nil) == false || comp.has_error()
{
print("Error writing image: \(comp.geterror(true))")
}
}
else
{
print("Error writing image: \(comp.geterror(true))")
}
}
else
}
else
{
print("Error writing image: \(comp.geterror(true))")
print("Error filling fg image.")
}
}

Expand Down
Binary file modified composite.exr
Binary file not shown.

0 comments on commit edf9881

Please sign in to comment.