RGB shader combine

I think a RGB channel shader combine node, would be a great additon to the mix shader and add shader.The reason for the need is,if you build a trichromatic shaderbuild with 3 principled shaders for example,and you want to connect all 3 shaders at the end,you can do this only with a add shader or a mix shader actualy.

However, if you dont make sure that all colorinputs are seperated to RGB peer channel/shader,then you can not use the add shader,because its addition would break the energy conserving if the channels are overlaping.And if you make sure it is seperated,that makes the workflow needless complicated to seperate all inputs before,if its possible at all to all inputs.
The last method left is the mixshader,it is the same problem with the trichromatc seperation.And if you mix the shader with a 50% and 33% then intensitys are reduced due mix factor vs a add channel.

a RGB shader combine node(that has 3 inputs and only takes the Red,Green,and Blue channel from a shader that is connected and adding all the channels together,and has a combined shader output),like the combine RGB color node ,would be a great addition to have.

I can’t get this very clear. What are the benefits? What is the use case? What kind of materials would you create (that you can’t get now?)?

Use case is not clear at all. It seems OP wants something like the existing RGB curves node but simpler. AFAICS, no real benefits with this, but since use case presented is confusing at best, probably a better explanation is requiered.

The only use case I can think of rereading the 1st post is for faking dispersion in glass with 3 refractive shaders (pure R, G and B color) joined via addshader nodes. The cumbersome part is that you have to precisely set the color triplets to 1,0,0 - 0,1,0 - 0,0,1.
If it is all about faking dispersion corner case, better follow the developement of spectral cycles here and on devtalk

Combine RGB with number into Refraction node. Copy twice and adjust numbers. It’s not that much extra work considering a flexible fake dispersion setup would include IOR base and spread with maths for those, and possibly a rough fresnel setup (PBR) for the glossy mixer. At the end of all that you need to figure out how to deal with fake shadows if you want to help caustics or replace caustics.
If that’s the only use case, I’d say it’s not worth it. Would be better to have fake dispersion as a setting on the refraction node letting it do its thing with russian roulette which should be faster. If not going full spectral, in which thin film and NK based (complex fresnel) metals would have higher importance with me.

Exactly what I was trying to say: if the use case is just faking dispersion in refractions, we can live with the “cumbersome” node-rig. Then better ask for what you say: a dedicated option to fake directly in the refraction/glass shader (but I think that adding a ‘fake’ into a shader won’t be acceptable for BF).
Still waiting to hear from OP what is the need

Sry for late reply was busy today.

ok i try to explane it a bit better,excuse my poor english,its not my naitve language.

its is not the simple 3 chromatic IOR dispersion trick,i was talking about,but in the kind of.this means that if you want to combine different shader layer you can not do it this easy way,otherwise i dont would ask for a shader combine node.

A short small offtopic but related.I have allready made a Idea for a color input at the mix shader,for cases like the dispersion trick,with the color input you would only need 3 different IOR nodes-put into the color fac-done.btw lucas sayed that is would be possible ,because the color weights in the fac gets multiplyed anyway,so it could be easly replaced with a color fac.

here you can read the idea with the color fac at the mix shader

back to this topic,this idea was about combine quickly the RGB channels of shaders you want to combine
(like you do with color RGB combine)

here a example where a shader combine node would be very helpful,if not for many other custom node builds,you need layering ect.imagine you want to add another layer and so on.
of course this is mainly for custom node builds,for a simple plastic shader i would not ask for a different node.

here you can see a node group i have builded a few days ago,it should do the diffuse and specular workflow in the rows underneath the shader balls.

i could make it happen,you could make fancy stuff like this, colored specular maps are possible.

here you can see the need for the shader combine node.

the specular layer is splitted with the “dispersion trick” (remember how useful a colored fac input would be?)
however the shader layer underneath,you ca not combine this way i have done.its works for its screenshot,but if you look closely to the underlying shader how there combined.you can not use addshader,because you need the mix,but you only need the RGB channels combined for each “RGB dispersion”

this is one of many situations,if you want to mix or add shader colors and so on together.a simple rgb channel shader combination would help in these cases.
i hope you can see the benefits for this.

look how this combine node would look like

and here with color input fac at mix shader ,would be even more usefull in this build,look how small the build gets.(7 nodes less if i count right)

edit,here another example the shaders combined via mix shader,the result is wrong.
Why?simple math.the high reflective green channel gets mixed by 50%,the otherchannels are black.the energy conservation is broken now.

and connected via add shader
(i have disconnected the underlaying black shader to get only the trichromatic factor values,and not get in the way for this example,would be make not difference,but to make it clear)
as you can see the true reflection factors are way higher peer channel,since this build using a schlick approxximation for metals.this would be the expected result as if a RGB channel shader combine would be used.i hope this makes it clear finally.
if i would use a white shader underneath you can guess,what would happen.now you can see the need for a RGB shader channel combine node ,and not to forget the usefulness of a color fac in the mixshader.

edit,last words at the end,
if you have mixed your shader with the 50%33% method before,dont you wondered why your shader gets so dull?thats the reason.if you dont use a trichromatic factor,the broken energy conservation is not that obviously.because you get 50%50% of a white Fresnel mix (its 1),then 33% and 66,6 (its 1)again.but the underlaying shader mix is wrong.and with the examples above you know why.

the reason for a RGB channel shader combine node is,simplisity and energy conservation.
same goes for a color fac in the mixshader.

At this point, I would have to say “if you say so”. Go for it, check with Lucas and Brecht.
If the main purpose is for specular workflow, then so be it. I don’t use specular workflow.
It’s worth mentioning that the specular workflow is not energy conserving (middle’ish),
and relies completely on the user creating correct map values or inputs.

Side note on the node setup you show: Use layer weight/facing power 5 instead.
That gets you access to node based modified normal. Notmal dot incoming does not.
However, that will still get you glowing edges for high roughness values.
I prefer rough fresnel myself, it’s just a few nodes. But require a dummy bump if inside a group (if that bug still exists).

1 Like

Hi thanks for reply.

sure it depents always on the inputs,same goes for the metallic workflow.This build was just a example.How often you have build a complex carshader or something with more layers where at the end of the noodles you wanted to connect your shader like this?Me very often.

As sayed before,its a example.You can build what ever you want ofcourse.The point is, how can i connect all shader/layers at the end with “correct” intensitys as fast and simple as possible.
Btw…if you look how small the build with a striped down color mix fac would be,the shader would be render more efficient too.(7 less nodes,just in this example)

and like i wrote one year ago within the thread of the color fac idea,it would be backward compatible too,nothing change if you connect your “old” grey inputs into the color fac.

and to not confuse the reader here,at this point these are two ideas.the possibility of a node ,to connect the RGB peer channel of a shader,and the second idea …a mix shader with a color fac input.

No. That’s one of the key selling points about using metallicness workflow - you can put anything into it and no rules will be broken. It’s idiot proof in that respect :slight_smile: The downside is lack of f0 specular, but specular in Principled makes up for that (but it’s kinda broken “by design” in other respects). And lack of colored dielectric speculars, specular tint is not the same.
If I make car paints I only do it for messing around, I never have to render cars.

Thats not correct,it depents on the input (Albedo for reflection color,and the metallic map of course)if you put a wrong Albedo map into your shader that dont fits with the metallic mask then you got the wrong metall reflection/colors.

or do you mean other rules are broken?

Afaik PBR wise,all dielectric reflection colors are white (at least the fresnel reflection not the diffuse color),
metal reflections are colored only,in theory for dielectric there is not much missing.

BTW, I tried your nodetree and then I managed to get more or less the same effect with a principled shader + a coat layer (simpe mix by fresnel of a colored glossy shader). Even better: the latter approach (right) got much more reflections on grazing angles, while your shader (left) has a dim rim all around the edges

and so it fails the white furnace test:

you setup the shader wrong.make a pure black metal shader and sublayer if you want,and a pure green metal reflection on top with the principled shader,good luck.

please show the nodes for the furnace test

btw,the specular build in this starting post,is just a example,you can replace it with any complex trichromatic build you want.
the point is,a color fac input would help to shrink the node count for such builds to a minimum,and make it way faster to build and more simple.you dont need to split all to R-G-B glossys or the sublayers or the calculations.
the channel combine would be a solution if we dont have a color fac.now we have to split every nodetrees for this type of builds.

Maybe my setup was wrong, but my point is still: what is this useful for? What material would you make with it? What effect??

why is it so important to you?this was a custom build for a specular workflow, in the case you have materials that have only specmap ect and you want to use it in blender.then with this build you could use your materials then.

like i sayed before,this build is just a example for many other trichromatic builds.this build doesent matter that much,its only to show one example, how this color fac at the mix shader, or a RGB channel shader combine could be usefull.

No, using a near white albedo with metallic 0 means some bright dielectric like snow, with metallic 1 means some bright metal. Non 0/1 metallic values are ok for antialiasing or fast blending purposes, but you don’t do a “this is a 50% dielectric 50% metallic” material.
Principled fails the white furnace test in several settings. With exposure 0, it’s a 1,1,1 white world with no other lights. Using filmic, it’s easy to see that a sphere can become brighter than its surroundings - that should not happen. Whereas fully white diffuse + glossy fresnel mixed will pass. There will be energy loss for rough glossy using GGX, but switching to Multiscatter GGX fixes it. Many things induce a loss (velvet, oren nayar), it’s the gain that is considered illegal, and loss that is considered illegal where none is expected.

Yes and no - in the strictest sense dielectric reflection is white. But having colored speculars allows shaders with fake iridescence, pearl shaders, and so on. Having specular tint allows simulation of where light picks up the base color (like in thin strands) and re-emits it specularly. Finally, allowing to reduce it by color, not going to full white at glancing angles, allows some rudimentary simulation of polarization. If you ever photographed a water stream with and without polarization filter you know what I’m talking about - how it reduces reflection.

Don’t be too stringent on applying these “laws of physics”, like dielectric should only be white - there are actual physical reasons why you’d want control.

yes i know.

I know this too,addtional in the prinicipled shader the clear coat reflection gets added on top of the material without subtracting the reflection for refractive transmission.(1-R=T).in this clear coat case (Material+R added and break the energy conservation)IIRC the explanation from the devs was,that a thin clear coat should not darken the material underneath.

This is not how iridescence works.I agree and know what you means.As you maybe know i have rebuild a thinfilm shader with nodes.Not to be a smart a** i want to clear here what exactly happens for the reader.

If the light hits the surface on a dielectric material it gets reflected like every other material,and this reflection color is still white.
Whats happens next is that the transmitted light that goes into the thin layer gets a phase shift at is wavelength ,gets reflected back at the substrate and exit at the top of the layer (and partly inside or in deeper layer of course).that gives its color shift.

But as sayed the outer surface layer reflection is still white.if you mix your thinfilm shader correctly then you make a refraction shader for the phase shift layer and a glossy white for top reflection.

could be,not sure atm. sound to me like glass fibre strands where the emitted light gets a internal reflection to the top ends.

Of course i know the effect of polarization filters.As you sayed,it reduces/filters the reflection.

No, but like the explanation with the thinfilm outer surface reflection,its still white with dielectrics.

Ok so it’s for make easier building of materials in Specular workflow. Got it.
I was asking because i thought it was something needed for corner-corner-corner cases, something I doubt was worth the effort.

Sounds reasonable to me. If we want fresnel driven, it’s only a glossy with simple fresnel node (or layer weight-> curve control to avoid having to deal with backfacing issues). For topcoats we can usually ignore rough fresnel. The underlying f0 specular should be reduced if using topcoat, and any gain in bounced energy will come from specular only. Which requires reflective caustics to do the job. With reasonable albedos, I doubt it would be noticeable.

Yes. Hence “fake” iridescence. The reflected coords -> magic remapped to drive wavelength into glossy is good enough for me :smiley: But since it’s not something I need for what I do, I haven’t bothered to much. Still, LuxCore has added thinfilm, I don’t know why Cycles don’t have it yet.

Spec tint. No, not talking about the top of the strands. Like, light passes through a strand and picks up its absorption color. This is then bounced specularly off the next strand it hits, and would be tinted towards its base/absorption color. But of course, without any actual strands.

Not really - just add a colour input node set to pure white, then use the split RGB node to split it into it’s pure RGB components, then send each RGB output to the colour input of a glass shader with the relevant IOR.

However adding three glass/refraction shaders to fake dispersion is very inefficient. Using a sub pixel texture is faster and leads to better results IMO. Also you aren’t limited to just RGB - you can effectively assign a full spectrum of colour/IOR values.