Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions fusion/Modules/Lua/cryptomatte_utilities.lua
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ function module._get_log_level()
Setting the log level to a high number than specified log levels will
result in applying all lower log levels.

:rtype: number
:rtype: number
]]
local log_level = os.getenv(ENV_VAR_LOG_LEVEL)
if log_level == nil then
Expand Down Expand Up @@ -560,16 +560,16 @@ end
function module._is_position_in_rect(rect, x, y)
--[[
Validates if the given x and y coordinates are in the given rect bounds.

:param rect: Integer rectangle position to validate x and y position with.
:type rect: FuRectInt

:param x: Y position to validate.
:type x: number

:param y: Y position to validate.
:type y: number

:rtype: bool
--]]
if x < rect.left or x > rect.right then
Expand Down Expand Up @@ -908,6 +908,19 @@ function module.create_matte_image(input_image, layer_images, manifest, matte_na
matte_values[0.0] = true
else
local matte_id = manifest[matte_name]

if string.match(matte_name, "*") then
wildcard = string.gsub(matte_name, "*", ".*.?")
for crypto_name, __ in pairs(manifest) do
wildcard_match = string.match(crypto_name, wildcard)
if wildcard_match == crypto_name then
matte_id = manifest[crypto_name]
local matte_value = module._hex_to_float(matte_id)
matte_values[matte_value] = true
end
end
end
Comment on lines +912 to +922

@cedricduriau cedricduriau Dec 27, 2024

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jamesdeschenes

Looks like a solid idea you got there!

My only comment would be to isolate this wildcard solving logic and call it before using this function. Primary reason is to split responsibilities and keep things simple. One function to solve wildcards to their matched absolute results, and this function can stay as is considering the matte_names argument.

-- step #1: read matte list input
-- step #2: parse matte list input to proper list
-- step #3: solve wildcards
-- step #4: use existing code as is, enjoy life, proceed

WDYT?


if matte_id == nil then
module.log_warning(string.format("matte not present in manifest: %s", matte_name))
else
Expand Down