anderslanglands / alShaders2

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

Add support for C4DtoA scenes #7

Closed SenH closed 7 years ago

SenH commented 7 years ago

• Adds clean object, asset and material names from C4DtoA scenes. • Fixes an issue with writing the metadata manifest for materials in the EXR file. • Avoids an "ai_bad_shader" appearing by default in the material manifest.

jonahfriedman commented 7 years ago

Thank you for this. We'll need to review it, but I just wanted to note I very much appreciate the contribution of c4d name parsing as well as the bug fix for the metadata.

One question, how does this avoid "ai_bad_shader" in the manifest?

SenH commented 7 years ago

One question, how does this avoid "ai_bad_shader" in the manifest?

Without b1362b0 there is an internal root shape that has an ai_bad_shader attached which show up in the respective manifests by default. Since this root shape has no real world use, it can be safely skipped.

jonahfriedman commented 7 years ago

Makes sense. Do you think there's ever a case where list_aggregate shapes should be considered? I'm not at all aware of what this node does in C4DtoA.

Also, do you think it'd be possible to supply an ass file with some examples of C4D naming and structure in it?

SenH commented 7 years ago

Do you think there's ever a case where list_aggregate shapes should be considered? I'm not at all aware of what this node does in C4DtoA.

Afaik this node is only available internally in the Arnold core and not even visible in the exported ass file. As a user you're not even aware that this node exists.

Here is a simple interior scene: Quiet_Room.zip Since C4D has no concept of namespaces, most people organise their scenes by grouping using null objects. The patch puts the first level of hierarchy in the assets manifest: Room, Ball Chair, Hanging Lights and Light Rods. The object and material AOV are as you would expect (except with cleaner naming).

c4d_object_manager

I agree that this is kind of debatable but I was reasoning most people would not disable the assets AOV so it's better to put something into it than leaving it empty. In any case it's always possible to override the naming/grouping by using the Cryptomatte userdata strings.

jonahfriedman commented 7 years ago

Agreed, top level groups for "asset" makes sense. Thanks for all this. I'll try to get this all merged in soon, unless there's something else to discuss.

SenH commented 7 years ago

@jonahfriedman I added another commit for issue described in #9 I could not create another branch for it since it depends on the C4DtoA fixes.

SenH commented 7 years ago

Peter suggested to use the whole parent hierarchy as namespace string instead of the first object in the hierarchy only. The major advantage is that we capture all nested hierarchy levels.

hierarchy

Without 54a2630 the asset AOV would only contain FG & BG. Now it contains FG.Robot, FG.Car, BG.Mountains, BG.Mountains.Trees, BG.Sky etc. Since it's very easy to multi-select Cryptomattes in the compositing package the mattes can always be combined to go back to a higher level.

jonahfriedman commented 7 years ago

So, this is awesome. I think both ways are useful. I have no objections to this going in in whatever way people think would be most useful for C4D workflows, however I have another idea.

I think that path based applications, such as C4D, Houdini, and Katana could benefit from a generalized version of this kind of thing. I had an idea- the users could specify which delimiter they would like to split on. It'd be a control, where -1 gives the behavior you have now (the last delimiter), 1 gives you behavior you had before (the first delimiter). -2 would be the second to last, etc.

In Maya the delimiter would be ":" (to resolve nested namespaces this way), in C4D names the delimiter would be "|", but in Katana and Houdini the delimiter would be "/".

SenH commented 7 years ago

I'm mostly familiar with C4D but it would be very nice if you could tweak it depending on scene complexity or user preference.

jonahfriedman commented 7 years ago

Hi Sen,

This has been merged into my dev branch. I made some changes though, and later refactored the whole function it was in. Here's the unit tests:

https://github.com/jonahfriedman/alShaders2/blob/master/cryptomatte/cryptomatte_tests.h#L175-L185

So for example:

        assert_clean_names("c4d-1", "c4d|hi|er|arch|chy", true, 
                           "chy", "hi|er|arch");

"c4d|hi|er|arch|chy" becomes:

If you'd like full object names, you can turn off namespace stripping (that's the "true" argument there) on the shader and then you get the results in c4d-4:

Sound good? That brings the c4d name processing more in line with everything else.

SenH commented 7 years ago

Excellent, looking forward to the new release.