Smart Mix Shader for Cycles (mix on Black) 3d model
Warning. This content is not moderated and could be offensive.
cigarette
3dmdb logo
Blend Swap
Smart Mix Shader for Cycles (mix on Black)

Smart Mix Shader for Cycles (mix on Black)

by Blend Swap
Last crawled date: 6 years, 5 months ago
(Revised)Another freebie offered so it may help a community that has come to my rescue countless times while I've been (learning). Apologies to the admin team for my previous "mea culpa" over a missing file that wasn't part of the blend but hadn't been removed.I'm not sure if someone has done this before (I expect they have) but here's my version either way. It's simplified "smart" mix which mixes based on the color of an image texture. This is a special purpose shader for mixing a dielectric (that's an insulator or anything non-metal to us). There's also a metallic version included but it's so similar that I'm only detailing the dielectric variety.I've included an example PNG which uses a CC0 image from Pixabay and with a hole punched in it to show transparency and a simple "gold leaf" shader setup (which is really a very, very quick hack) to show how you use the node groups.This is rather handy for putting more than one shader effect on a single image texture - I've done it with >10 but for most jobs just a couple is quite sufficient. I originally developed the technique for an unused space ship which needed lots of little pin lights but had to be rendered on a modest GPU. This way, I was able to use a single texture to define the surface and the lights without resorting to other tricks and flaming hoops.The included metallic shader is not 100% physically accurate since it takes an albedo (color) map but for should be good for SciFi spaceships since it has an adjustable specularity.There are 7 inputs - the top two should come from your image texture node. You only need to plug transparency in if the image has transparency otherwise set it to 1.0 which is default or adjust to your needs. (Note this is the last mix node so it affects the entire texture.)The final input seems odd but I discovered it was necessary to put a very fine-grained cutoff for the black level. This should only really apply to JPEGs and other lossy formats but packing the PNG images appeared to have a similar effect. So this slider allows you to tune the black level to make sure that only the bits (black or very dark) are included in the selection.The included "is it black" nodegroup which is where the magic happens can be used (with care!) to punch holes in JPEGs (sample included) but be aware this technique is far from perfect since it's impossible to know what will happen in the shadows. YMMV.The shader input is for the shader that's going to replace any pixel area on your image that's mapped to 100% black. That's RGB:0.0.0 - anything else will remain as is. You don't need to set "non-color data" as pure black is not affected by the sRGB tonemap.In the demo I've fed this input with a perturbed glossy yellow shader which gives a "hacked" metallic foil look as you might find on a Christmas or other greeting card. It can be anything that you can feed to the surface input of the Cycles output node: emission, transparency, glass... another one of these nodes (!) you name it.I've provided separate inputs for both diffuse and glossy roughness since this node setup is designed for things like simulated greeting cards - but it's not limited to that. This allows you to control the look of the diffuse texture separately to the "glossy" sheen - that you might see with a laminated card.Sample render also shows a emission shader being driven (hard) by a noise texture just to show there's no cheating.The Normals input is used exactly as you would use any normals input.

Tags