Hey Guys,
I’m just wondering what the best/most accurate way is to create a Normal scale slider (similar to the Unity Standard shader one). Ideally one that can go from 0 - 3 or even more. I have tried a couple of different ways with mixed results. I have looked briefly at the way Unity does it in their shader but I didnt really understand how to replicate it.
Any help would be great!
Here are some examples on the methods I have tried.
sampler2D _MainTex;
sampler2D _BumpMap;
struct Input {
float2 uv_MainTex;
};
half _Glossiness;
half _BumpScale;
half _Metallic;
fixed4 _Color;
half3 _NormalDefault;
void surf (Input IN, inout SurfaceOutputStandard o) {
// Albedo comes from a texture tinted by color
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = c.rgb;
// Metallic and smoothness come from slider variables
o.Metallic = _Metallic;
o.Smoothness = _Glossiness;
//Method 1
o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_MainTex) *_BumpScale);
//Method 2
//_NormalDefault = Half3(128, 128, 255) --found these values online
o.Normal = lerp(_NormalDefault, UnpackNormal(tex2D(_BumpMap, IN.uv_MainTex)), _BumpScale);
//fallback method
o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_MainTex));
//o.Normal = _NormalDefault;
o.Alpha = c.a;
}