Material id color AOV

Use this forum for general user support and related questions.
Forum rules
Please upload a testscene that allows developers to reproduce the problem, and attach some images.
User avatar
Egert_Kanep
Posts: 237
Joined: Tue Mar 13, 2018 10:34 am

Material id color AOV

Post by Egert_Kanep »

Is this feature going to be developed further? Right now it seems that color id's are assigned randomly and getting a mask out of it is not very clean. It would help if one could specify colors, better yet cryptomatte support :D . But it is definitely a feature I'd like to see improved.
User avatar
B.Y.O.B.
Developer
Developer
Posts: 4146
Joined: Mon Dec 04, 2017 10:08 pm
Location: Germany
Contact:

Re: Material id color AOV

Post by B.Y.O.B. »

You can specify a material ID in the output node.
The color is formed like this:
The ID is 4 bytes long.
The lowest byte is taken as the red channel (in range 0 to 255), the next byte is used as green channel, and the next as blue.
The highest byte is ignored.

You can form any color like this, where r, g, b are values in range 0 to 255:
r + (g * 256) + (b * 65536)

So for example pure red would be:
255 + (0 * 256) + (0 * 65536) = 255 as material ID

Pure blue would be:
0 + (0 * 256) + (255 * 65536) = 16711680

In the old LuxBlend addon I had a UI where you could directly input colors and it would compute the necessary ID for it, this could be included in the new addon: https://bitbucket.org/luxrender/luxblen ... #lines-915
Attachments
2018-10-25_14-46-56.png
User avatar
FarbigeWelt
Donor
Donor
Posts: 1046
Joined: Sun Jul 01, 2018 12:07 pm
Location: Switzerland
Contact:

Re: Material id color AOV

Post by FarbigeWelt »

Hi B.Y.O.P.
What about the idea to use the highest bit to change brightness of defined color to get values in 32 bit range?
Should be possible with little adjustments of default color node.
Maybe define RGB 0 to 255 and ‚move‘ in 32 bit color range with brightness slider -127 to +127.
Light and Word designing Creator - www.farbigewelt.ch - aka quantenkristall || #luxcorerender
MacBook Air with M1
User avatar
B.Y.O.B.
Developer
Developer
Posts: 4146
Joined: Mon Dec 04, 2017 10:08 pm
Location: Germany
Contact:

Re: Material id color AOV

Post by B.Y.O.B. »

I don't really understand what you want to say, sorry.
Why do you need a 32 bit color from the material ID?
User avatar
Dade
Developer
Developer
Posts: 5672
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: Material id color AOV

Post by Dade »

It may be a good idea to add an (optional ?) color input and do the math internally :?:
Support LuxCoreRender project with salts and bounties
User avatar
FarbigeWelt
Donor
Donor
Posts: 1046
Joined: Sun Jul 01, 2018 12:07 pm
Location: Switzerland
Contact:

Re: Material id color AOV

Post by FarbigeWelt »

B.Y.O.B. wrote: Thu Oct 25, 2018 2:18 pm I don't really understand what you want to say, sorry.
Why do you need a 32 bit color from the material ID?
First of all I do not like spoilingl one byte out of four (means 25% loss of possible information) even if does not count much compared with today's memory capacity.
Then I thought about the way one can adjust colors running Photoshop on 32 bit color depth. I used this option to set a bright spot as sun in a blue sky HDRI.
Next step would be to use material ID as color input for objects or vice a versa. If there were only 8 bit vailable per channel and one liked to define different shining objects, 8 bit is not much considering an eye's range of about 1e5 (day light). And then there might be rays with depth>8 bouncing around objects with 0.5 absorbance.
Sure there is a limitation, because all channels would be 'moved' with same factor. This means my idea does not increase channels' resolution but in my opinion brightness is in the given example more relevant; also eyes are less capable to differentiate colors.
Light and Word designing Creator - www.farbigewelt.ch - aka quantenkristall || #luxcorerender
MacBook Air with M1
User avatar
B.Y.O.B.
Developer
Developer
Posts: 4146
Joined: Mon Dec 04, 2017 10:08 pm
Location: Germany
Contact:

Re: Material id color AOV

Post by B.Y.O.B. »

If you just need distinct material IDs, you have 0xfffffffe available.

@Dade yes, I linked such a solution in my post above (used in old LuxBlend).
User avatar
Egert_Kanep
Posts: 237
Joined: Tue Mar 13, 2018 10:34 am

Re: Material id color AOV

Post by Egert_Kanep »

B.Y.O.B. wrote: Thu Oct 25, 2018 12:51 pm You can specify a material ID in the output node.
The color is formed like this:
The ID is 4 bytes long.
The lowest byte is taken as the red channel (in range 0 to 255), the next byte is used as green channel, and the next as blue.
The highest byte is ignored.

You can form any color like this, where r, g, b are values in range 0 to 255:
r + (g * 256) + (b * 65536)

So for example pure red would be:
255 + (0 * 256) + (0 * 65536) = 255 as material ID

Pure blue would be:
0 + (0 * 256) + (255 * 65536) = 16711680
Thanks for explaining. Although doing it like this can be a bit uncomfortable, not a very standard way of defining color, if I may say so :D. Especially for new users. An additional color input would be great, it is good to have visual representation of what is happening within one's scene.

if the material id color could be defined like this 255,255,0 it already would make things much clearer. then additional color node would not be needed.
Last edited by Egert_Kanep on Fri Oct 26, 2018 7:11 am, edited 1 time in total.
User avatar
B.Y.O.B.
Developer
Developer
Posts: 4146
Joined: Mon Dec 04, 2017 10:08 pm
Location: Germany
Contact:

Re: Material id color AOV

Post by B.Y.O.B. »

Well, it's an ID after all.
Interpreting it as a color is more a side application.
User avatar
Egert_Kanep
Posts: 237
Joined: Tue Mar 13, 2018 10:34 am

Re: Material id color AOV

Post by Egert_Kanep »

Maybe I am trying to use it for wrong purposes? The way I see how it could be used, is for generating masks, but for pulling clear mask I can only use pure rgb (which I can now do, YES!) but I was wondering what is developers idea with this aov, is it something more technical? Because I am kind of lost now, with all this ID stuff, does this serve another purpose?
Post Reply