When using the metallic version of the standard shader I set both metallic and smoothness to max and also switch reflections off the whole object becomes black. Does that mean the portion of the reflection that comes from albedo (in case of metals) is first blended into the reflection cube map and then it’s sampled back from it (in Unity_GlossyEnvironment()) and blended back onto the object?
What I’m trying to say is if Unity_GlossyEnvironment() was only sampling the surrounding environment without the albedo being blended into it already the shader would still need to mix albedo into the reflection at some point after sampling the cube map but I can’t see it being done anywhere that’s why I suspect the albedo must be somehow preblended into the reflection probe.
That however seems rather suboptimal so I’m probably guessing wrong and overlooking something in the shader code completely.
Can you show me what part of the code is blending the reflection with albedo in fully reflective materials? it’s certainly not blended directly with the object as diffusion in such objects appears to be 0.0.
A smooth metal object has essentially zero albedo color and is purely reflective. That’s not a bug that’s working as intended. Don’t turn off reflections on metal materials.
The way “metallic” shaders like the Standard shader work is the albedo texture is used as the specular color when the metallic value is 1.0, and the albedo color is blacked out.
There’s a function called something like “CalculateMetallicSpecular” or something that takes the albedo color and metallic value and returns a new albedo color and specular color. After that the shader works exactly like the Standard Specular shader.
The function is named DiffuseAndSpecularFromMetallic in the MetallicSetup function called by the UNITY_SETUP_BRDF_INPUT macro that is the single differentiator between the Standard (aka metallic workflow) and Standard Specular versions of the shader. It’s also basically the first thing the Standard shader does.
The value of unity_ColorSpaceDielectricSpec.rgb is approximately an sRGB value of 56, 56, 56 (~0.04 in linear), and unity_ColorSpaceDielectricSpec.a is ~0.96 (one minus sRGB 55; 1.0 - 0.04 = 0.96).
Reflections and specular highlights are multiplied by the resulting specular color, direct diffuse and ambient lighting are multiplied by the resulting albedo color. The results of the reflections, specular highlights, diffuse, and ambient are just added together.
Since metal has no albedo, it shows black if there are no reflections or specular highlights. If your smoothness is maxed out it means highlights are infinitely small since lights in Unity are calculated as infinitely small point lights and not area lights.
OK. I posted the previous before I saw your other post. At what point do reflections get multiplied by specular color? That could be the part I’m missing.
Way, way down the line a few function calls deep. I always have trouble finding it. Try searching for “Unity_GlossyEnvironment” in the cginc files, or look for unity_SpecCube0 and follow the very indirect chain to where it finally gets used.
That’s why I mentioned “Unity_GlossyEnvironment” at the beginning of this thread. I can’t for the life of me find where it’s used. And I still can’t. Plus you said the rest of the shader was unified but obviously glossy highlights are nor blended with specColor only metallic ones so that really gets me confused.
The results of the function UnityGI_IndirectSpecular which calls Unity_GlossyEnvironment are stored in “o_gi.indirect.specular”, this is just the glossy environment map modified by roughness. No albedo or specular color, or really any other modifiers beyond the roughness and optionally box projection are applied.
Later this gets passed to UNITY_BRDF_PBS “gi.indirect”, and gets used in the second to last line of BRDF1_Unity_PBS in the block of code that combines all of the lighting, albedo, and specular colors together (along with some other terms for physically based shading).
The majority of materials are theoretically 100% reflective at perfectly parallel glancing angles, both metals and non metals, so the fresnel lerps from the specular color to white. This isn’t exactly correct for a number of reasons*, but it’s a “good enough” approximation. But yes, there’s no such thing as “black” metal. Usually it’s very dark grey, or it’s not actually the reflection from the metal you’re seeing but a clear coat on top of it.
It’s impossible to actually see a surface that’s perfectly parallel in the real world, but you can in 3d graphics because of surface normal interpolation and normal maps leading to over brightening on edges. Some materials, metals especially, can change their reflected color based on the angle, even common materials like copper and aluminum, and might not have a “white” reflection no matter the angle. The theoretical models we’re using for PBR are based on work done in the 70’s and don’t actually match really measured data or the current state of knowledge for material sciences which is proving to be far more complex.