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
yeah, I just figure that out just now. ;p
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
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.
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.
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.
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.
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
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.
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_INCLUDEDsay 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?
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.
http://forum.unity3d.com/threads/official-5-0-pbr-calibration-charts.289416/
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.
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
Moral: you shouldn't worry about that extra slider.
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?