Psyop / Cryptomatte

Cryptomatte Nuke plugin, Fusion plugin, sample images, and specification
BSD 3-Clause "New" or "Revised" License
637 stars 152 forks source link

[FUSION] exr trouble #100

Closed jeremybepoix closed 3 years ago

jeremybepoix commented 5 years ago

Hi, I encounter problems related to my rendering done under Vray (3dsmax). Under Vray (3.6) 3dsmax I have no choice to go through the frame buffer to get the cryptoMatte.

To output an exr "cleanly" under vray 3dsmax it is necessary to use the aov's Vray (VrayOptionRE). In this VrayOptionRE there are two options "exr auto data windows" and "exr multipart".

More information here : https://docs.chaosgroup.com/display/VRAY3MAX/V-Ray+Render+Options+%7C+VRayOptionRE

When i check "exr auto data windows" cryptoMatte won't display properly and crash after test it on another layer. When i check "exr multipart" cryptoMatte won't work and find nothing. Because is a openExr 2 features ?

note : I can not get out of this project because it is confidential. But I will try to find some time to reproduce these problems

jeremybepoix commented 5 years ago

So,

I did a test next to it and I have exactly the same problems. (Fusion 9.0.2 build 15 studio)

I bring three exr file from 3dsmax 2017, vray 3.60.03 (i've made zip, can't attach .exr on gitHub)

The first (exr_multipart.exr) > Fusion console :

...ion\Reactor\Deploy\Modules\Lua\cryptomatte_utilities.lua:335: attempt to index a nil value
stack traceback:
    ...ion\Reactor\Deploy\Modules\Lua\cryptomatte_utilities.lua:335: in function 'get_manifest_string'
    ...ion\Reactor\Deploy\Modules\Lua\cryptomatte_utilities.lua:362: in function 'parse_manifest'
    ...esign\Fusion\Reactor\Deploy\Fuses\Matte\cryptomatte.fuse:461: in function <...esign\Fusion\Reactor\Deploy\Fuses\Matte\cryptomatte.fuse:449>
Cryptomatte1 failed at time 0

The second (exr_auto_data_window.exr) : I can't get anything, Fusion crash, and suddenly disappears.

The third (exr_normal.exr) works.

++

jeremybepoix commented 5 years ago

I forgot to mention that it was dedicated to fusion. under Nuke it works perfectly

cedricduriau commented 5 years ago

Hi @jeremybepoix

Just tried, here are my results/findings. Same Fusion version (9.0.2 b15) but I'm on free.

exr_normal

exr_normal Everything looks good here.

exr_auto_data_window

exr_auto_data_window Everything looks good here too. Tried with proxy modes, auto proxy modes, all stable.

exr_multipart

exr_multipart

In the console I'm seeing the following error pop up for every action by frame with Cryptomatte. [string` "FFI Script"]:19579: attempt to index local 'img' (a nil value)

This error is not verbose at all, but from what I understand it usually means an image is being constructed out of invalid information. I followed my gut and started evaluating the layers and channels of the exr_multipart source image. Here are all the layers.

layers

The default layer is the beauty, looks fine. The non-indexed one and the 00 are fine as well. The remaining layers do not contain any information. If you check the 01 and 02 layers, the RGBA images are pure black. Cryptomatte needs at least the 00 and 01 to be valid. (@jonahf correct me if I'm wrong.)

Could you check your VRay setup for that?

Cheers Cedric

jeremybepoix commented 5 years ago

hi, bizarre, i try "exr_auto_data_window" here at work and it won't... for "exr_multipart" I think it's openExr2 under fusion, because under nuke it work well. Cryptomatte was install via reactor,

My vray settings are good, and to check, i follow step by step vray help online.

Hardxware : xeon e5-2623 v3 gtx 1080ti i'm not admin logged win 10 x64 pro

jeremybepoix commented 5 years ago

After several attempts, I give up, I do not understand why it works for you, not me ?? while the only difference is Fu studio/free. Werid isn't it?

And i reapeat, all exr work well under nuke.

jonahfriedman commented 5 years ago

@cedricduriau It only needs to 00 layer to be valid. That will give it two ID/coverage pairs.

acrux7245 commented 5 years ago

Hey guys,

I am having same issues you are on the studio and the free version. This is getting really weird, I tried your files and it worked fine for me. Everything I make just does not work at all. Even across diff computers.

acrux7245 commented 5 years ago

Hey guys,

I am having same issues you are on the studio and the free version. This is getting really weird, I tried your files and it worked fine for me. Everything I make just does not work at all. Even across diff computers.

Also I am using same Vray& Max version as you at home and 2019 at the office and same error

aliasguru commented 4 years ago

I believe to have rammed into the same issue here, though my source files come from Blender Cycles. I have modified the lua code a bit to get some debug output in the console of Fusion, here is the end of said log and the error message:

SHELL.196
SHELL.196
4377306624

M1711531000
M1711531000
-1.8126756762271e-09

57305016100_4.052
57305016100_4.052
-3.8591812767663e-07

SHELL.096
SHELL.096
nan

SHELL.096 is nan!!
...agic Design\Fusion\Modules\Lua\cryptomatte_utilities.lua:889: table index is NaN
stack traceback:
    ...agic Design\Fusion\Modules\Lua\cryptomatte_utilities.lua:889: in function 'parse_manifest'
    ...agic Design\Fusion\Modules\Lua\cryptomatte_utilities.lua:732: in function 'initialize'
    ...agic Design\Fusion\Modules\Lua\cryptomatte_utilities.lua:921: in function 'create_cryptomatte_info'
    ...ng/Blackmagic Design/Fusion/Fuses/Matte/cryptomatte.fuse:583: in function <...ng/Blackmagic Design/Fusion/Fuses/Matte/cryptomatte.fuse:568>
Cryptomatte1 failed at time 1

now, this is the code I used to get the debug output:

function CryptomatteInfo:parse_manifest(manifest)
    --[[
    Parse the manifest to store matte id and name information for fast lookup.

    :param manifest: manifest to parse
    :type manifest: table
    --]]
    local from_names = {}
    local from_ids = {}
    local all_names = {}
    local all_ids = {}

    for name, hex in pairs(manifest) do
        -- decode hash to int
        int_flt.i = tonumber(hex, 16)
        -- decode int to float
        local id_float = int_flt.f
        local name_str = tostring(name)
        print(name)
        print(name_str)
        print(id_float)
        print()

        if (id_float ~= id_float) then
            print(string.format("%s is nan!!", name_str))
        end

        -- store name by id float
        from_names[name_str] = id_float
        -- store id float by name
        from_ids[id_float] = name_str
        -- store name in set
        all_names[name_str] = true
        -- store id float in set
        all_ids[id_float] = true
    end

    -- create name to id from hexadecimal value of names
    self.cryptomattes[self.selection]["name_to_id"] = from_names
    self.cryptomattes[self.selection]["id_to_name"] = from_ids
    self.cryptomattes[self.selection]["names"] = all_names
    self.cryptomattes[self.selection]["ids"] = all_ids
end

So what you can see is that one if the id_float values indeed becomes nan causing the script to crash at that point. Then, I tried refactoring the code to only proceed if said id_float is not nan:

function CryptomatteInfo:parse_manifest(manifest)
    --[[
    Parse the manifest to store matte id and name information for fast lookup.

    :param manifest: manifest to parse
    :type manifest: table
    --]]
    local from_names = {}
    local from_ids = {}
    local all_names = {}
    local all_ids = {}

    for name, hex in pairs(manifest) do
        -- decode hash to int
        int_flt.i = tonumber(hex, 16)
        -- decode int to float
        local id_float = int_flt.f
        local name_str = tostring(name)

        if (id_float ~= id_float) then
            print(string.format("%s is nan!!", name_str))
        else
            -- store name by id float
            from_names[name_str] = id_float
            -- store id float by name
            from_ids[id_float] = name_str
            -- store name in set
            all_names[name_str] = true
            -- store id float in set
            all_ids[id_float] = true
        end
    end

    -- create name to id from hexadecimal value of names
    self.cryptomattes[self.selection]["name_to_id"] = from_names
    self.cryptomattes[self.selection]["id_to_name"] = from_ids
    self.cryptomattes[self.selection]["names"] = all_names
    self.cryptomattes[self.selection]["ids"] = all_ids
end

But no luck: there are a few more nan values detected, but before the image processing is completed Fusion simply crashes. I don't have this in every file, only in more complex ones with a high number of object IDs (in the thousands).

garyritchie commented 3 years ago

Same error here:

...ion/Reactor/Deploy/Modules/Lua/cryptomatte_utilities.lua:880: table index is NaN
stack traceback:
    ...ion/Reactor/Deploy/Modules/Lua/cryptomatte_utilities.lua:880: in function 'parse_manifest'
    ...ion/Reactor/Deploy/Modules/Lua/cryptomatte_utilities.lua:732: in function 'initialize'
    ...ion/Reactor/Deploy/Modules/Lua/cryptomatte_utilities.lua:912: in function 'create_cryptomatte_info'
    ...esign/Fusion/Reactor/Deploy/Fuses/Matte/cryptomatte.fuse:583: in function <...esign/Fusion/Reactor/Deploy/Fuses/Matte/cryptomatte.fuse:568>

Ubuntu 20.04; Blender 2.91 + Fusion 9.02b15. Cryptomatte installed via Reactor.

2,560 objects in the Blender file... I also tried "dialing things down to just Assets + 2 Levels. No go.

EvanAW commented 3 years ago

@garyritchie and @aliasguru I believe you are experiencing the issue that PR https://github.com/Psyop/Cryptomatte/pull/120 is designed to fix.

Updates the Fusion implementation to deal with the exponent properly when converting the hash to float

This fixes the issue where the fuse can't load the manifest because the hash to float conversion may create NaNs in some cases.

This is a different issue than the one @jeremybepoix is reporting.

cedricduriau commented 3 years ago

Fixed with cedricduriau#11, cedricduriau#14 and cedricduriau#43