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
    Offline / Send Message
    Farfarer polycounter lvl 17
    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
    Offline / Send Message
    Farfarer polycounter lvl 17
    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 11
    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
    Offline / Send Message
    Farfarer polycounter lvl 17
    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.
    1. #ifndef UNITY_STANDARD_INPUT_INCLUDED
    2. #define UNITY_STANDARD_INPUT_INCLUDED
    3.  
    4. #include "UnityCG.cginc"
    5. #include "UnityShaderVariables.cginc"
    6. #include "UnityStandardConfig.cginc"
    7. #include "UnityPBSLighting.cginc" // TBD: remove
    8. #include "UnityStandardUtils.cginc"
    9.  
    10. //---------------------------------------
    11. // Directional lightmaps & Parallax require tangent space too
    12. #if (_NORMALMAP || !DIRLIGHTMAP_OFF || _PARALLAXMAP)
    13. #define _TANGENT_TO_WORLD 1
    14. #endif
    15.  
    16. #if (_DETAIL_MULX2 || _DETAIL_MUL || _DETAIL_ADD || _DETAIL_LERP)
    17. #define _DETAIL 1
    18. #endif
    19.  
    20. //---------------------------------------
    21. half4 _Color;
    22. half _Cutoff;
    23.  
    24. sampler2D _MainTex;
    25. float4 _MainTex_ST;
    26.  
    27. sampler2D _DetailAlbedoMap;
    28. float4 _DetailAlbedoMap_ST;
    29.  
    30. sampler2D _BumpMap;
    31. half _BumpScale;
    32.  
    33. sampler2D _DetailMask;
    34. sampler2D _DetailNormalMap;
    35. half _DetailNormalMapScale;
    36.  
    37. sampler2D _SpecGlossMap;
    38. sampler2D _MetallicGlossMap;
    39. half _Metallic;
    40. half _Glossiness;
    41.  
    42. sampler2D _OcclusionMap;
    43. half _OcclusionStrength;
    44.  
    45. sampler2D _ParallaxMap;
    46. half _Parallax;
    47. half _UVSec;
    48.  
    49. half4 _EmissionColor;
    50. sampler2D _EmissionMap;
    51.  
    52. //-------------------------------------------------------------------------------------
    53. // Input functions
    54.  
    55. struct VertexInput
    56. {
    57. float4 vertex : POSITION;
    58. half3 normal : NORMAL;
    59. float2 uv0 : TEXCOORD0;
    60. float2 uv1 : TEXCOORD1;
    61. #if defined(DYNAMICLIGHTMAP_ON) || defined(UNITY_PASS_META)
    62. float2 uv2 : TEXCOORD2;
    63. #endif
    64. #ifdef _TANGENT_TO_WORLD
    65. half4 tangent : TANGENT;
    66. #endif
    67. };
    68.  
    69. float4 TexCoords(VertexInput v)
    70. {
    71. float4 texcoord;
    72. texcoord.xy = TRANSFORM_TEX(v.uv0, _MainTex); // Always source from uv0
    73. texcoord.zw = TRANSFORM_TEX(((_UVSec == 0) ? v.uv0 : v.uv1), _DetailAlbedoMap);
    74. return texcoord;
    75. }
    76.  
    77. half DetailMask(float2 uv)
    78. {
    79. return tex2D (_DetailMask, uv).a;
    80. }
    81.  
    82. half3 Albedo(float4 texcoords)
    83. {
    84. half3 albedo = _Color.rgb * tex2D (_MainTex, texcoords.xy).rgb;
    85. #if _DETAIL
    86. #if (SHADER_TARGET < 30)
    87. // SM20: instruction count limitation
    88. // SM20: no detail mask
    89. half mask = 1;
    90. #else
    91. half mask = DetailMask(texcoords.xy);
    92. #endif
    93. half3 detailAlbedo = tex2D (_DetailAlbedoMap, texcoords.zw).rgb;
    94. #if _DETAIL_MULX2
    95. albedo *= LerpWhiteTo (detailAlbedo * unity_ColorSpaceDouble.rgb, mask);
    96. #elif _DETAIL_MUL
    97. albedo *= LerpWhiteTo (detailAlbedo, mask);
    98. #elif _DETAIL_ADD
    99. albedo += detailAlbedo * mask;
    100. #elif _DETAIL_LERP
    101. albedo = lerp (albedo, detailAlbedo, mask);
    102. #endif
    103. #endif
    104. return albedo;
    105. }
    106.  
    107. half Alpha(float2 uv)
    108. {
    109. return tex2D(_MainTex, uv).a * _Color.a;
    110. }
    111.  
    112. half Occlusion(float2 uv)
    113. {
    114. #if (SHADER_TARGET < 30)
    115. // SM20: instruction count limitation
    116. // SM20: simpler occlusion
    117. return tex2D(_OcclusionMap, uv).g;
    118. #else
    119. half occ = tex2D(_OcclusionMap, uv).g;
    120. return LerpOneTo (occ, _OcclusionStrength);
    121. #endif
    122. }
    123.  
    124. half4 SpecularGloss(float2 uv)
    125. {
    126. half4 sg;
    127. #ifdef _SPECGLOSSMAP
    128. sg = tex2D(_SpecGlossMap, uv.xy);
    129. #else
    130. sg = half4(_SpecColor.rgb, _Glossiness);
    131. #endif
    132. return sg;
    133. }
    134.  
    135. half2 MetallicGloss(float2 uv)
    136. {
    137. half2 mg;
    138. #ifdef _METALLICGLOSSMAP
    139. mg = tex2D(_MetallicGlossMap, uv.xy).ra;
    140. #else
    141. mg = half2(_Metallic, _Glossiness);
    142. #endif
    143. return mg;
    144. }
    145.  
    146. half3 Emission(float2 uv)
    147. {
    148. #ifndef _EMISSION
    149. return 0;
    150. #else
    151. return tex2D(_EmissionMap, uv).rgb * _EmissionColor.rgb;
    152. #endif
    153. }
    154.  
    155. #ifdef _NORMALMAP
    156. half3 NormalInTangentSpace(float4 texcoords)
    157. {
    158. half3 normalTangent = UnpackScaleNormal(tex2D (_BumpMap, texcoords.xy), _BumpScale);
    159. // SM20: instruction count limitation
    160. // SM20: no detail normalmaps
    161. #if _DETAIL && !defined(SHADER_API_MOBILE) && (SHADER_TARGET >= 30)
    162. half mask = DetailMask(texcoords.xy);
    163. half3 detailNormalTangent = UnpackScaleNormal(tex2D (_DetailNormalMap, texcoords.zw), _DetailNormalMapScale);
    164. #if _DETAIL_LERP
    165. normalTangent = lerp(
    166. normalTangent,
    167. detailNormalTangent,
    168. mask);
    169. #else
    170. normalTangent = lerp(
    171. normalTangent,
    172. BlendNormals(normalTangent, detailNormalTangent),
    173. mask);
    174. #endif
    175. #endif
    176. return normalTangent;
    177. }
    178. #endif
    179.  
    180. float4 Parallax (float4 texcoords, half3 viewDir)
    181. {
    182. #if !defined(_PARALLAXMAP) || (SHADER_TARGET < 30)
    183. // SM20: instruction count limitation
    184. // SM20: no parallax
    185. return texcoords;
    186. #else
    187. half h = tex2D (_ParallaxMap, texcoords.xy).g;
    188. float2 offset = ParallaxOffset1Step (h, _Parallax, viewDir);
    189. return float4(texcoords.xy + offset, texcoords.zw + offset);
    190. #endif
    191. }
    192. #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 11
    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
    Offline / Send Message
    Farfarer polycounter lvl 17
    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.