Hi,
I have a shader that uses a (Damage) normal map, and I want to control this map’s strength with a float between 1 and 0, 0 = no strength and 1 = full strength (Just like the standard shader),
How can I do it?
This is the normal map lines :
_DamageMap ("Damagemap", 2D) = "bump" {}
_Damage ("Damage Value", Range(0.0,10.0)) = 0.0
sampler2D _DamageMap;
half _Damage;
void surf (Input IN, inout SurfaceOutput o)
{
fixed4 Dmg = tex2D(_DamageMap, IN.uv_MainTex);
o.Normal = UnpackNormal (Dmg);
}
1 Like
_DamageMap (“Damagemap”, 2D) = “bump” {}
_Damage (“Damage Value”, Range (0.0,10.0)) = 0.0
sampler2D _DamageMap;
half _Damage;
void surf (Input IN, inout SurfaceOutput o)
{
fixed4 Dmg = UnpackScaleNormal(tex2D(_DamageMap, IN.uv_MainTex),_Damage);
o.Normal =Dmg;
}
3 Likes
unfortunately, It didn’t work, but i have got the method from the UnityStandardUtils.cginc file itself form the UnpackScaleNormal function inside it :
fixed3 Dmg = UnpackNormal(tex2D(_DamageMap, IN.uv_MainTex));
Dmg.xy *= _Damage;
o.Normal = normalize(Dmg);
thanks for your reply.
3 Likes
Just lerp between your texture and (0.5, 0.5, 1):
float3 normal = lerp(float3(0.5, 0.5, 1), tex2D(_DamageMap, IN.uv_MainTex), _Damage);
o.Normal = UnpackNormal(normal);
15 Likes
6 years later, jbooth, thank you…
7 years later, @jbooth_1 , thanks!
8 years later, @jbooth_1 thank you.
VZPX
July 21, 2022, 7:37pm
8
9 years later, @jbooth_1 sheesh!
Emsoba
September 29, 2025, 9:28pm
12
Yea, 10 years later, thanks jbooth1