Home Unity

Unity Metallic/Metalness not showing Smoothness Slider

Rhythem02
polycounter lvl 5
Offline / Send Message
Rhythem02 polycounter lvl 5
Hello there folks

I'm pretty new to unity, but its pretty straight forward platform to work on.

There is one thing that I can't figure out.

The metallic option both has metalness slider and Smoothness slider.
But once I add texture to it, the glossiness slider is gone.

The texture is metalness with gloss map on it as alpha. (RGB-A)
Its exported from Substance designer.
The formap is .TGA. I rechecked it in photoshop and confirmed that the gloss map is in the alpha slot.

Here is a screen grab.

Do you guys know how to fix it.

Replies

  • echofourpapa
    Offline / Send Message
    echofourpapa polycounter lvl 4
    That texture's gloss map is used instead of the slider. Just like the metal map used instead of the metal slider.
  • Rhythem02
    Offline / Send Message
    Rhythem02 polycounter lvl 5
    That texture's gloss map is used instead of the slider. Just like the metal map used instead of the metal slider.

    yeah, I just figure that out just now. ;p
  • snake85027
    Offline / Send Message
    snake85027 polycounter lvl 18
    I have a question on pbr workflow. I created a ladder. I made a diffuse map, metallic map and a normal map. I am using unity 5. I am using the standard shader with the metallic workflow. I am not sure how to set up my textures in photoshop to get unity to work correctly. My metallic map has white areas for the parts of the model that reflect and dark areas for parts of the model that do not. I put that in the MEtallic slot but it looks like the entire model still reflects and is unaffected by the values of the textures. Any advice?
  • snake85027
    Offline / Send Message
    snake85027 polycounter lvl 18
    I ended up created a tga file and using the Alpha Channel to define whats metallic and whats not..... If I am creating a metallic texture to define whats reflective and whats not. Why doesnt the rgb define that? Whats the point of having to create a alpha channel in photoshop and storing the metallic information in there? ... If unity only bases whats metallic and whats not off of the alpha channel then should the rbg channles be gray or something or I guess it wouldnt matter?
  • mikolajspy
    Offline / Send Message
    mikolajspy polycounter lvl 7
    In alpha channel you're storing Roughness values. RGB has only Metalness.
    Metalness says how much metal is the surface.
    Roughness - how much the surface is reflective.
    For example, you might have model with shiny plastic surface and rough/worn/dirty non reflective metal; for that you set in RGB which parts is metal, which not, and in alpha reflectivity :)
  • Farfarer
    You've got metalness in the red channel, ambient occlusion in the green and glossiness in the alpha (inverse of roughness).

    So you can store all that in the one texture and plug it in to both the slots. Generally referred to as a material texture (I think, dunno what else) which stores all the scalar channels that define the material in each channel of the texture.
  • snake85027
    Offline / Send Message
    snake85027 polycounter lvl 18
    I guess I am a little confused. Isnt the albedo value determine how much the material absorbs light? The lighter the value of the albedo, the more reflective a surface is? the light rays hit a material and depending on the frequency of the material determines if the light turns to heat(absorbed) or if it reflects...

    so mikolajspy, your saying that metalness says how much metal is the surface..are you refering to how much does the material absorb or reflect light?

    I guess its all confusing to me. If i have Metallic at 0 and the smoothness at 1, the material should not be reflecting light at all because Metallic is at 0, meaning 0 light is being reflected...why does unity act this way.
  • snake85027
    Offline / Send Message
    snake85027 polycounter lvl 18
    to clarify, what the last sentence, when I have this setting my material is still reflective even though the metalness is 0.
  • snake85027
    Offline / Send Message
    snake85027 polycounter lvl 18
    after doing some test with the albedo being white or black, so this just controls how much the color shows up. because i lowered the abledo to black it was still reflective, its just the color was gone...ok cool.
  • echofourpapa
    Offline / Send Message
    echofourpapa polycounter lvl 4
    It still bugs me that Height is on G and not B, so you could pack

    R Metallic
    G AO
    B Height
    A Gloss

    Rather than having to use a separate map for Height on G, or having to choose between AO and Height. I've made my own shader that takes maps packed that way. I've also experimented with putting the AO map in the alpha of the Diffuse Albedo in with the specular setup when I know it's going to be an opaque material. But sticking with a nicely packed metallic setup is just easier.
  • EarthQuake
    Metalness in R, roughness G and ao in A? Nothing in B? That's a really dumb way to do it, and means all your textures are using double the texture memory compared to simply packing them in RGB. Is this really the default in Unity?
  • echofourpapa
    Offline / Send Message
    echofourpapa polycounter lvl 4
    Yes it is, well Metallic in R, AO or Height in G, nothing in B and smoothness in A anyway.

    I was asking a while back(posted here and on Unity's forums) if there was a reason for this. I'll have to find the links. Some people suggested it was because of texture compression reasons, but I'm not 100% sold on that.
  • Farfarer
    EarthQuake wrote: »
    Metalness in R, roughness G and ao in A? Nothing in B? That's a really dumb way to do it, and means all your textures are using double the texture memory compared to simply packing them in RGB. Is this really the default in Unity?
    Stupidly, yes.

    Guessing they're assuming the gloss value will stay relatively well compressed in the alpha, with AO getting next best compression in the green. Metalness doesn't need that much to it, so it gets next best in the red.

    I've had to hack the Standard shaders to use RGB rather than RGA and that's a real pain now - the code is spread out over so many include files :/

    Blue might contain height for parallax?

    Edit: Nope, height is in the green channel of another map (which is likely only used for height).



    The sources for the Standard shaders (the metalness ones anyway) are:

    Albedo & Alpha: RGB & A (hard-coded to be the from same texture)
    Metalness & Glossiness: R & A (hard-coded to be from the same texture)
    Ambient Occlusion: G
    Height: G
    Detail Mask: A
  • Lt_Commander
    Offline / Send Message
    Lt_Commander polycounter lvl 10
    Woah, the AO (or height) can be packed in G for the standard shader? I've never read this anywhere! Is there a reference on the unity manual that confirms this, or was this discovered by digging the the source files?

    I always thought it was incredibly wasteful to only use 2/4 channels in a texture, at least using 3/4 is a little better.
  • Farfarer
    Yeah, just looking through the include files. Although if you hover over the input slots in the editor, then it'll tell you in the tooltip what texture channel it derives the information from (they aren't automatically generated - it's just written out in the custom shader inspector).

    UnityStandardInput.cginc has the source channels/textures in there.
    #ifndef UNITY_STANDARD_INPUT_INCLUDED
    #define UNITY_STANDARD_INPUT_INCLUDED
    
    #include "UnityCG.cginc"
    #include "UnityShaderVariables.cginc"
    #include "UnityStandardConfig.cginc"
    #include "UnityPBSLighting.cginc" // TBD: remove
    #include "UnityStandardUtils.cginc"
    
    //---------------------------------------
    // Directional lightmaps & Parallax require tangent space too
    #if (_NORMALMAP || !DIRLIGHTMAP_OFF || _PARALLAXMAP)
    	#define _TANGENT_TO_WORLD 1 
    #endif
    
    #if (_DETAIL_MULX2 || _DETAIL_MUL || _DETAIL_ADD || _DETAIL_LERP)
    	#define _DETAIL 1
    #endif
    
    //---------------------------------------
    half4		_Color;
    half		_Cutoff;
    
    sampler2D	_MainTex;
    float4		_MainTex_ST;
    
    sampler2D	_DetailAlbedoMap;
    float4		_DetailAlbedoMap_ST;
    
    sampler2D	_BumpMap;
    half		_BumpScale;
    
    sampler2D	_DetailMask;
    sampler2D	_DetailNormalMap;
    half		_DetailNormalMapScale;
    
    sampler2D	_SpecGlossMap;
    sampler2D	_MetallicGlossMap;
    half		_Metallic;
    half		_Glossiness;
    
    sampler2D	_OcclusionMap;
    half		_OcclusionStrength;
    
    sampler2D	_ParallaxMap;
    half		_Parallax;
    half		_UVSec;
    
    half4 		_EmissionColor;
    sampler2D	_EmissionMap;
    
    //-------------------------------------------------------------------------------------
    // Input functions
    
    struct VertexInput
    {
    	float4 vertex	: POSITION;
    	half3 normal	: NORMAL;
    	float2 uv0		: TEXCOORD0;
    	float2 uv1		: TEXCOORD1;
    #if defined(DYNAMICLIGHTMAP_ON) || defined(UNITY_PASS_META)
    	float2 uv2		: TEXCOORD2;
    #endif
    #ifdef _TANGENT_TO_WORLD
    	half4 tangent	: TANGENT;
    #endif
    };
    
    float4 TexCoords(VertexInput v)
    {
    	float4 texcoord;
    	texcoord.xy = TRANSFORM_TEX(v.uv0, _MainTex); // Always source from uv0
    	texcoord.zw = TRANSFORM_TEX(((_UVSec == 0) ? v.uv0 : v.uv1), _DetailAlbedoMap);
    	return texcoord;
    }		
    
    half DetailMask(float2 uv)
    {
    	return tex2D (_DetailMask, uv).a;
    }
    
    half3 Albedo(float4 texcoords)
    {
    	half3 albedo = _Color.rgb * tex2D (_MainTex, texcoords.xy).rgb;
    #if _DETAIL
    	#if (SHADER_TARGET < 30)
    		// SM20: instruction count limitation
    		// SM20: no detail mask
    		half mask = 1; 
    	#else
    		half mask = DetailMask(texcoords.xy);
    	#endif
    	half3 detailAlbedo = tex2D (_DetailAlbedoMap, texcoords.zw).rgb;
    	#if _DETAIL_MULX2
    		albedo *= LerpWhiteTo (detailAlbedo * unity_ColorSpaceDouble.rgb, mask);
    	#elif _DETAIL_MUL
    		albedo *= LerpWhiteTo (detailAlbedo, mask);
    	#elif _DETAIL_ADD
    		albedo += detailAlbedo * mask;
    	#elif _DETAIL_LERP
    		albedo = lerp (albedo, detailAlbedo, mask);
    	#endif
    #endif
    	return albedo;
    }
    
    half Alpha(float2 uv)
    {
    	return tex2D(_MainTex, uv).a * _Color.a;
    }		
    
    half Occlusion(float2 uv)
    {
    #if (SHADER_TARGET < 30)
    	// SM20: instruction count limitation
    	// SM20: simpler occlusion
    	return tex2D(_OcclusionMap, uv).g;
    #else
    	half occ = tex2D(_OcclusionMap, uv).g;
    	return LerpOneTo (occ, _OcclusionStrength);
    #endif
    }
    
    half4 SpecularGloss(float2 uv)
    {
    	half4 sg;
    #ifdef _SPECGLOSSMAP
    	sg = tex2D(_SpecGlossMap, uv.xy);
    #else
    	sg = half4(_SpecColor.rgb, _Glossiness);
    #endif
    	return sg;
    }
    
    half2 MetallicGloss(float2 uv)
    {
    	half2 mg;
    #ifdef _METALLICGLOSSMAP
    	mg = tex2D(_MetallicGlossMap, uv.xy).ra;
    #else
    	mg = half2(_Metallic, _Glossiness);
    #endif
    	return mg;
    }
    
    half3 Emission(float2 uv)
    {
    #ifndef _EMISSION
    	return 0;
    #else
    	return tex2D(_EmissionMap, uv).rgb * _EmissionColor.rgb;
    #endif
    }
    
    #ifdef _NORMALMAP
    half3 NormalInTangentSpace(float4 texcoords)
    {
    	half3 normalTangent = UnpackScaleNormal(tex2D (_BumpMap, texcoords.xy), _BumpScale);
    	// SM20: instruction count limitation
    	// SM20: no detail normalmaps
    #if _DETAIL && !defined(SHADER_API_MOBILE) && (SHADER_TARGET >= 30) 
    	half mask = DetailMask(texcoords.xy);
    	half3 detailNormalTangent = UnpackScaleNormal(tex2D (_DetailNormalMap, texcoords.zw), _DetailNormalMapScale);
    	#if _DETAIL_LERP
    		normalTangent = lerp(
    			normalTangent,
    			detailNormalTangent,
    			mask);
    	#else				
    		normalTangent = lerp(
    			normalTangent,
    			BlendNormals(normalTangent, detailNormalTangent),
    			mask);
    	#endif
    #endif
    	return normalTangent;
    }
    #endif
    
    float4 Parallax (float4 texcoords, half3 viewDir)
    {
    #if !defined(_PARALLAXMAP) || (SHADER_TARGET < 30)
    	// SM20: instruction count limitation
    	// SM20: no parallax
    	return texcoords;
    #else
    	half h = tex2D (_ParallaxMap, texcoords.xy).g;
    	float2 offset = ParallaxOffset1Step (h, _Parallax, viewDir);
    	return float4(texcoords.xy + offset, texcoords.zw + offset);
    #endif
    }
    			
    #endif // UNITY_STANDARD_INPUT_INCLUDED
    
  • echofourpapa
    Offline / Send Message
    echofourpapa polycounter lvl 4
    Does it count as two texture fetches in the different slots?
  • snake85027
    Offline / Send Message
    snake85027 polycounter lvl 18
    What makes a material metal?Is it not the fact that it is reflective but how it handles reflection? For example fine wood and plastic versus metal chrome, all these can be reflective, is it how they handle reflections that makes them a metal or not? Lets
    say I have a fine wooden table with a nice reflection and there is a nice chrome trim on the outside of the table. Within unitys Metal slot what would the rbg look like as well as the glossiness?
  • Lt_Commander
    Offline / Send Message
    Lt_Commander polycounter lvl 10
    you might want to look up on basic PBR theory for that, but in short, the metalness map is really just an answer to the question: Is this (the surface represented by this pixel on the texture) metal? If it is, then the pixel is white. If not, it's black.

    For a wood table with chrome trim, ask yourself, is wood made of metal? No. The wood is black on the metalness map. Is chrome metal? Yes. It's white on the metalness map.

    Smoothness answers another simple question: Is this surface smooth? (On a scale of 0-255) How smooth is it? If it's perfectly polished, then it's near white. If it's rough and porus like chalk or charcoal, then it's essentially black. For your table, since it's mostly polished, the smoothness map would be bright, if not near white.

    When it's packed down, the R would would essentially be black with a white mask for your chrome trim and the alpha would be pretty bright. You can (apparently) pack the baked AO in the green as well.

    The metalness workflow handles all of the old issues, like reflection color, reflection frensel angles, and rimlighting all by anwsering these two questions and taking the color of the diffuse into account. For most simple surfaces, you'll get a pretty decent result for complex materials and things that can only exist in games, you might want to fall back to the specular workflow or author a custom shader.
  • echofourpapa
    Offline / Send Message
    echofourpapa polycounter lvl 4
    snake85027 wrote: »
    What makes a material metal?Is it not the fact that it is reflective but how it handles reflection? For example fine wood and plastic versus metal chrome, all these can be reflective, is it how they handle reflections that makes them a metal or not? Lets
    say I have a fine wooden table with a nice reflection and there is a nice chrome trim on the outside of the table. Within unitys Metal slot what would the rbg look like as well as the glossiness?



    UnityChartsPreview.png

    http://forum.unity3d.com/threads/official-5-0-pbr-calibration-charts.289416/
  • Farfarer
    Does it count as two texture fetches in the different slots?
    I'm not exactly certain at that level.

    The texture is loaded into memory only once, and presumably the bit for that lookup is loaded (it knows that from the vertex shader, and the UVs don't change, nor does the mip level for that point).

    So it's two samples of the same texture at the same place - meaning there is some overhead there that doesn't *need* to be there, but I'm not certain about two texture fetches.

    If it's for AO... with forward rendering, it's probably very slightly beneficial - because AO isn't sampled by the forward add passes used by additional lights. So if you've got 2+ lights affecting the model then you're probably saving a little bit of overhead in the long run?

    I dunno... if you're using the Standard shaders then you're probably not going to notice the difference, really.
  • Martin_Baun
    Hi
    Maybe some of you can help me. Its about the smoothness slider that does not disappear even thou I have a roughness map in the metallic alpha channel.

    Furthermore the smoothness slider effects my roughness map - so if the slider does not disappear what value should I set it to, so Unity shows my material in the correct way?

    I am using Substance Designer for my texture work and export an sbsar file with standard export settings (albedo, normal, roughness, metallic, AO and height)

    - Martin
  • echofourpapa
    Offline / Send Message
    echofourpapa polycounter lvl 4
    If you are using Unity 5.4+ there is a new slider that is a smoothness override slider now.  It's meant to tweak the smoothness value in the alpha of the texture.  It's a multiplier, so it multiplies it's range(from 0.0 to 1.0) against your alpha channel to reduce overall smoothness.  Something important to note between Smoothness and Roughness is that they are opposites, that means you should invert your Roughness map/channel if you want to use it for Smoothness.  However, if you are using the substance directly, Unity will take care of that conversion for you.

    Moral:  you shouldn't worry about that extra slider.
  • Martin_Baun
    Thank you for your answer!

    But what is the default value for the slider? It looks like when I place the slider at 0.8 I get the most resembling result when tab between Substance Designer and Unity. I know that the most logic answer would be 0 or 1 but that is not the case with the tests I have been doing.

    Could you help me with this last question?
  • echofourpapa
    Offline / Send Message
    echofourpapa polycounter lvl 4
    The default is 1.  If 0.8 looks correct, then I would suggest staying with that, unless you want to add that correction to your Substance so the multiply doesn't need to happen in shader. 
Sign In or Register to comment.