Guest User

Here is an example of a basic fur shader for Unity

a guest
Jan 16th, 2023
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "Custom/Fur" {
  2.     Properties {
  3.         _MainTex ("Fur Texture", 2D) = "white" {}
  4.         _BumpMap ("Normal Map", 2D) = "bump" {}
  5.         _FurLength ("Fur Length", Range(0, 1)) = 0.1
  6.         _FurDensity ("Fur Density", Range(0, 1)) = 0.5
  7.         _FurDirection ("Fur Direction", Vector) = (0, 1, 0)
  8.         _FurColor ("Fur Color", Color) = (0.8, 0.8, 0.8, 1)
  9.         _FurSpecular ("Fur Specular", Range(0, 1)) = 0.5
  10.         _FurShininess ("Fur Shininess", Range(0, 1)) = 0.07
  11.     }
  12.  
  13.     SubShader {
  14.         Tags {"Queue"="Transparent"}
  15.         LOD 200
  16.  
  17.         CGPROGRAM
  18.         #pragma surface surf Lambert
  19.  
  20.         sampler2D _MainTex;
  21.         sampler2D _BumpMap;
  22.         float _FurLength;
  23.         float _FurDensity;
  24.         float3 _FurDirection;
  25.         fixed4 _FurColor;
  26.         float _FurSpecular;
  27.         float _FurShininess;
  28.  
  29.         struct Input {
  30.             float2 uv_MainTex;
  31.             float2 uv_BumpMap;
  32.             float3 viewDir;
  33.         };
  34.  
  35.         void surf (Input IN, inout SurfaceOutput o) {
  36.             fixed4 tex = tex2D (_MainTex, IN.uv_MainTex);
  37.             fixed4 bump = tex2D (_BumpMap, IN.uv_BumpMap);
  38.             float furAmount = dot(bump.rgb, _FurDirection) * _FurDensity;
  39.             o.Albedo = tex.rgb * _FurColor.rgb;
  40.             o.Alpha = tex.a * (1 - furAmount * _FurLength);
  41.             o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
  42.             o.Specular = _FurSpecular;
  43.             o.Gloss = _FurShininess;
  44.         }
  45.         ENDCG
  46.     }
  47.     FallBack "Diffuse"
  48. }
  49.  
Advertisement
Add Comment
Please, Sign In to add comment