Page MenuHome

Compositor: Added Color Key node that maps object IDs to random colors
AbandonedPublic

Authored by Lukas Stockner (lukasstockner97) on Feb 16 2015, 5:34 PM.

Details

Reviewers
Sergey Sharybin (sergey)
Group Reviewers
Compositing
Summary

This patch adds a node that takes a value input, rounds it to the nearest integer, and then calculates a color from the hashed ID.
It's mainly useful for Object/Material ID pass visualisation.
Zero is mapped to alpha 0, since it's the default value for the background.

Diff Detail

Repository
rB Blender
Branch
math_hash

Event Timeline

Lukas Stockner (lukasstockner97) retitled this revision from to Compositor: Added Color Key node that maps object IDs to random colors.

note would call something different - the term Key has a specific meaning when compositing, maybe call ID to Color ?

But before updating probably get approval on functionality.

Sergey Sharybin (sergey) requested changes to this revision.Feb 18 2015, 9:44 AM

I can see this is useful for debugging, but i'm not sure it gives enough control for the artists. Also, this behavior can easily be achieved with color ramp node for such a visualization. And if 32 colors wouldn't be enough you can still use Pass Mask node which will give you mask for a given object which you then can colorize and combine back.

I would prefer not to have nodes for each of crazy usecase, especially if they can be done relatively easy with existing nodes.

This revision now requires changes to proceed.Feb 18 2015, 9:44 AM

Hm, generally I agree that it's maybe too special, but the ColorRamp quickly gets annoying to set up and use for many different IDs.
My suggestion would be to implement a "Hash" operation for the math node instead. You could then create a "hash cascade" that gives you 3 hashes and use a "Combine RGB" to get the color. Would something like this be accepted?

Lukas Stockner (lukasstockner97) edited edge metadata.

I moved the hash option to the Math Node, this should be more generic and flexible.
By using the hash as the H input of a HSV Combine node, a color mask can still be generated pretty easily.

Sergey Sharybin (sergey) requested changes to this revision.Jun 7 2015, 6:56 PM
Sergey Sharybin (sergey) edited edge metadata.

I don't see why it'll be useful feature for any node tree outside of the compositor, and surely it's not something to be added to SVM. That's why we've got OSL shading backend.

As for difficulty of setting up color ramp node, you don't need to set it up all the time, it's either a matter of adding an addon which sets up the color ramp node (as a short term solution) or have a template-based node tree construction (proper approach, more long term).

Hash is quite bad for such things anyway, because you then don't have any control over the palette while with the color ramp you could easily control all the colors, avoiding situations when hash gives you nearly undistinguishable results.

This revision now requires changes to proceed.Jun 7 2015, 6:56 PM

I do see the use case, as in some other renderers you get direct visual impressions. But mimicking this in cycles/compo is not the place imho.

If you want Object/Material ID pass visualisation then perhaps the Image editor might be a better location (?), but we currently don't have the appropriate design for these kind of things.

J & M