anderslanglands / alShaders2

BSD 3-Clause "New" or "Revised" License
75 stars 38 forks source link

Path-based names Cryptomattes proposal #17

Closed jonahfriedman closed 6 years ago

jonahfriedman commented 6 years ago

I've written up a proposal for better handling of names from path-based apps, such as Katana, Houdini, or Cinema 4D. The basic notion is that it automatically selects a character as the delimiter, and then you can chose which delimiter to split on based on your scene organization. If your scene is organized such as:

sets
 | - car
 | - house
characters
 | - alice
 | - bob
 | - carl

You'd probably want the split to take place after the second delimiter, so the value you would select is "2". This way you'd have a matte for "sets|house", and then one for the contents of that (either with the namespace stripped or not).

In more detail:

The options and defaults:

strip_obj_namespaces: true
strip_mat_namespaces: true
pathname_drop_root: true
pathname_obj_delimiter: 1
pathname_mat_delimiter: 1

HtoA style:   /obj/set/car/wheel/hubcap/insignia
C4dtoA style: c4d|set|car|wheel|hubcap|insignia
MtoA style:   myNamespace:myObjectShape (not path based)

1. Establish the delimiter. 

    If we start with a "/", we're doing a path delimited by "/". 
    If we start with "c4d|", we're doing a path delimited by "|". 

    HtoA:       /obj/set/car/wheel/hubcap/insignia
                (delimiter = "/")
    C4dtoA:     c4d|set|car|wheel|hubcap|insignia
                (delimiter = "|")
    MtoA:       myNamespace:myObjectShape
                (Not a path. )

2. If "pathname_drop_root" is on, and the name is path based, we drop the first segment. 

    HtoA:       set/car/wheel/hubcap/insignia
    C4dtoA:     set|car|wheel|hubcap|insignia
    MtoA:       myNamespace:myObjectShape
                (Not a path. )

2. Find the splittable delimiter. (Same if delimiter is another character)

                set/car/wheel/hubcap/insignia
    positive:  0   1   2     3      4
    negative:     -4  -3    -2     -1

    If strip_obj_namespaces == False, "delimiter" only controls crypto_asset and not crypto_object.  

   -10 (out of range):
        crypto_asset:    {default}
        crypto_object:   set/car/wheel/hubcap/insignia

   -2:
        crypto_asset:    set/car/wheel
        crypto_object:   hubcap/insignia

   -1:
        crypto_asset:    set/car/wheel/hubcap
        crypto_object:   insignia

    0:
        crypto_asset:    {default}
        crypto_object:   set/car/wheel/hubcap/insignia

    1:
        crypto_asset:    set
        crypto_object:   car/wheel/hubcap/insignia

    10 (out of range):
        crypto_asset:    set/car/wheel/hubcap/insignia
        crypto_object:   {default}

Comments, concerns, suggestions, and scene organization scheme examples welcome.

jonahfriedman commented 6 years ago

This particular thing isn't happening, but something somewhat related might (see #22)