Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Fur Shader

Discussion in 'Made With Unity' started by Jonathan Czeck, Apr 13, 2007.

  1. Apocolyptosaur

    Apocolyptosaur

    Joined:
    Dec 21, 2011
    Posts:
    13
    Apologies for the bump.

    I could really use this shader, but the unify website is down. does anyone have any other links to it?
     
  2. Dingodongo

    Dingodongo

    Joined:
    Oct 2, 2012
    Posts:
    1
  3. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    Probably old news but i'm having a long hard look at this shader in the hope it can be someewhat made to work with ogles2.0, as i'm quite set on getting some form of such a shader working, i'm hoping for something that might approximate very short carpet fuzz, and it seems it should be adaptable to use unity's lights and such but the problem remains i have no idea how to either make it a surface shader (is this possible?) or add a suitable fragment shader for it to work in timely fashion, or i'd like to know if im barking up the wrong tree entirely

    I've also been looking at quite a well known treatment of the problem here and trying to figure out how i can get it to work, i think i'm mainly getting unstuck by some of the matrices, i get something appearing but its a bit bonkers and little like fur

    If anyone has an idea on how to go about this i'd be very grateful too see their thoughts, it's not a suitable method for most fur but i can certainly see uses for it, especially with more interaction with unity's lights and control over strand length and direction
     
  4. caseym

    caseym

    Joined:
    Nov 29, 2012
    Posts:
    2
    Does this work for anyone in unity 4? For me it just shows up as a black sphere, no fur of any kind on the test scene.

    -I got it to work, turned off DX11 and changed to forward rendering and restarted unity, not sure which of those solved it
     
    Last edited: Dec 18, 2012
  5. Sasmaster

    Sasmaster

    Joined:
    Jan 19, 2010
    Posts:
    44
    For me it doesn't work with Unity 4 with DX11 on.
     
  6. JStaples

    JStaples

    Joined:
    Jan 21, 2013
    Posts:
    11
    Here's to hoping this doesn't get buried...
    I was wondering if there was a way to have the hair shorter on some parts of the body, like the hands and face. Or if not, if there is a was a can show the features of the face through the fur.
     
  7. hulnglei

    hulnglei

    Joined:
    Mar 6, 2013
    Posts:
    1
    I did as you said, but not work. Anybody can give us advices?
     
  8. HarvesteR

    HarvesteR

    Joined:
    May 22, 2009
    Posts:
    531
    Should be possible on SM3. If you set #pragma target 3.0 and #pragma glsl, you'll be able to use tex2Dlod to read a texture on the vertex shader. You could then feed a "hair length" map to the shader, and have it multiply the vertex length.

    Cheers
     
  9. Freezy

    Freezy

    Joined:
    Jul 15, 2012
    Posts:
    234
    have tried to get a fur shader to work with more complex models, but keep running into all kinds of depth sorting issues.

    anyone still working on this?

    One trick i figured out is to include the helper file before the shader then you can call on it from anywhere in the shader.
    This allows an offset to be passed with less code in the main shader, which helps with readability.
    Not sure if it helps with compile size, but unless there is a way to get loops this seems the best we can hope for.

    Create a
    v2f FurVert(fixed multiplier, appdata v)​
    and a
    fixed4 FurFrag( v2f IN ) : COLOR​

    in "FurHelpers.cginc"
    that do what you want it to do


    Code (csharp):
    1.  
    2. CGINCLUDE    
    3.     #include "FurHelpers.cginc"
    4. ENDCG
    5.  
    6.  
    7. Shader "FurBase"
    8. {
    9.     Category
    10.     {
    11.         Lighting On
    12.         Cull Back
    13.         ZWrite On
    14.         ZTest LEqual
    15.         Tags {"Queue" = "Transparent"  "IgnoreProjector"="True" "RenderType"="Transparent"}
    16.         Blend SrcAlpha OneMinusSrcAlpha
    17.                
    18.         SubShader {
    19.             Pass
    20.             {
    21.                 CGPROGRAM
    22.                     #pragma vertex vert
    23.                     #pragma fragment FurFrag
    24.                     v2f vert (appdata v) { return FurVert(0.3, v); }
    25.                 ENDCG                
    26.             }
    27.             Pass
    28.             {            
    29.                 CGPROGRAM
    30.                     #pragma vertex vert
    31.                     #pragma fragment FurFrag
    32.                     v2f vert (appdata v) { return FurVert(0.6, v); }
    33.                 ENDCG                
    34.             }
    35.             Pass
    36.             {            
    37.                 CGPROGRAM
    38.                     #pragma vertex vert
    39.                     #pragma fragment FurFrag
    40.                     v2f vert (appdata v) { return FurVert(1.0, v); }
    41.                 ENDCG                
    42.             }
    43.         }
    44.     }
    45. }
    46.  
     
  10. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,291
    Has anyone implemented shadows on the fur ?
     
  11. Play_Edu

    Play_Edu

    Joined:
    Jun 10, 2012
    Posts:
    722
  12. sarahc

    sarahc

    Joined:
    Oct 8, 2013
    Posts:
    1
    "Try reading the thread. The answer isn't in this thread but in the wiki." is it possible that the fixed shader (unity 3) doesn´t support untiy 3.5?
     
  13. Hoeloe

    Hoeloe

    Joined:
    May 9, 2013
    Posts:
    31
  14. ABerlemont

    ABerlemont

    Joined:
    Sep 27, 2012
    Posts:
    67
    5 years bump
    All the lastest links to sources in this thread are dead :( (except the assetstore ones ;))
    Anyone still have the related zip in an older folder somewhere :D ?
     
  15. ABerlemont

    ABerlemont

    Joined:
    Sep 27, 2012
    Posts:
    67
  16. Dolzen

    Dolzen

    Joined:
    Mar 26, 2014
    Posts:
    90
  17. Max_Aigner

    Max_Aigner

    Joined:
    May 9, 2017
    Posts:
    42
    Hi there,
    I love that shader, great work!

    However it only works in editor mode for me. Does that happen to you, too?
    Normal (long fur):
    upload_2020-1-9_10-48-3.png
    Editor (super tiny fur only):
    upload_2020-1-9_10-48-30.png
     
  18. Gareth-Tech

    Gareth-Tech

    Joined:
    Jul 10, 2015
    Posts:
    20
    Hi all,

    Wow this shader seems to be keeping devs busy through the years.

    I have this shader partially working on mobile, it works fine in Editor (Unity 2020.2.2f).
    The issue is that lighting fails to work with the fur, so we have a dark material on mobile.

    Assumptions on compatibility on mobile have been taken into account but the fur is so damn good so I can't just give up on it with out reaching out.

    Is there anything that can be done with the shader that fixes the lighting issue.
    The texture is visible barely but that may suggest an emission could be added to give the dark fur the light we need.
    If this is possible how could I implement this.
     
  19. Gareth-Tech

    Gareth-Tech

    Joined:
    Jul 10, 2015
    Posts:
    20
    For anyone still following this thread. Add a second material to your object and it works amazingly on mobile :D