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

Builtin Unity shaders source

Discussion in 'Shaders' started by Aras, Jun 21, 2006.

  1. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    Source code for Unity built-in shaders can be always found here: https://unity3d.com/get-unity/download/archive

    The source code is provided for reference and learning purposes. You don't need to put the shaders into your project; they're all built-in. If you do, be sure to modify shader name at start of the file, otherwise names will collide with the builtins and it will be confusing which one means which.
     
    Last edited: Dec 23, 2015
  2. joacoerazo_legacy

    joacoerazo_legacy

    Joined:
    Apr 5, 2006
    Posts:
    214
    Thank you Aras

    This is must learn for me.
     
  3. Jessy

    Jessy

    Joined:
    Jun 7, 2007
    Posts:
    7,325
    I seemingly did need to put these into my project, and I don't see any problems arising due to the names. Any reason for this? I guess I've been using Unity successfully in some kind of cripple state, but I have no idea what is going on.
     
  4. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    No, you don't need to put them into your project. These are the sources if you want to develop your own shaders and want to take a look at how built-in ones are done.

    Presumably your Unity installation is corrupt (or maybe you're out of disk space?). Try reinstalling Unity.
     
  5. Jessy

    Jessy

    Joined:
    Jun 7, 2007
    Posts:
    7,325
    For any other neophytes that seem to have this problem, just get out of debug mode and pick your shader then. Thanks, Daniel!
     
  6. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    Updated with Unity 2.0 and 1.6.2 shaders.
     
  7. Jonathan Czeck

    Jonathan Czeck

    Joined:
    Mar 17, 2005
    Posts:
    1,713
    When someone has a chance, could we please have the 2.1 shader update?

    Thanks,
    -Jon
     
  8. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    paternostrox, spamove and BilalGuvenc like this.
  9. Jonathan Czeck

    Jonathan Czeck

    Joined:
    Mar 17, 2005
    Posts:
    1,713
    Even better, thank you!
     
  10. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    Edited the initial post, now always links to latest shaders.
     
  11. minevr

    minevr

    Joined:
    Mar 4, 2008
    Posts:
    1,018
    Thank you! :twisted:
     
  12. JonnyHilly

    JonnyHilly

    Joined:
    Sep 4, 2009
    Posts:
    749
    If I want to deliberately replace one of the builtin unity shaders with a slightly modified one, how would I do that ?

    If I add it to my project with the same name... which one will be used ?
    for example the vertex_lit shader that unity uses on the detail objects. like bushes and rocks.
     
  13. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    if you add your own one with the same name, yours will override the builtin one.

    thats how the SM3 enhanced terrain shader (showcase board) works :)
     
  14. JonnyHilly

    JonnyHilly

    Joined:
    Sep 4, 2009
    Posts:
    749
    awesome, thanks
     
  15. jcarpay

    jcarpay

    Joined:
    Aug 15, 2008
    Posts:
    561
    Last edited: Oct 1, 2010
  16. gfxguru

    gfxguru

    Joined:
    Jun 5, 2010
    Posts:
    107
  17. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    As Aras said, the link in the first post always has the current shaders.
     
  18. HonoraryBob

    HonoraryBob

    Joined:
    May 26, 2011
    Posts:
    1,214
    I downloaded the file that contains the source code for the built-in shaders, but the (plain) "Specular Shader" isn't in there. I was hoping to see how it creates that beautiful, realistic glow which the other specular shaders in Unity don't seem to produce.
     
  19. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    Welcome to the forum, HonoraryBob!

    The code for the Specular shader (at the root of the menu) is actually included in the archive but the filename is a bit misleading - it's in the Normal-Glossy.shader file.
     
  20. brn

    brn

    Joined:
    Feb 8, 2011
    Posts:
    320
    Hi Aras, Are the 3.5 beta shaders available? Im getting some requests to make my shader pack compatible to the new functionality.
    If I've missed a thread some where id be happily re directed to it.

    Cheers
    Brn
     
  21. Waz

    Waz

    Joined:
    May 1, 2010
    Posts:
    287
    Still not available?
     
  22. mindlace

    mindlace

    Joined:
    Mar 31, 2007
    Posts:
    24
    How about the 3.5-release shaders?
     
  23. snaker

    snaker

    Joined:
    Feb 25, 2012
    Posts:
    11
    Thank you!
     
  24. Manuk

    Manuk

    Joined:
    Jan 20, 2012
    Posts:
    2
    Does anyone else think that the files in there should have a header stating their version?

    Is the current file 3.5 already?

    Replacing the Internal-PrePassLighting.shader works, but not for cameras with HDR activated - there you get no lighting (all medium gray).

    Does this warrant a Bug-Report? Or does Aras monitor this thread?
     
  25. Manuk

    Manuk

    Joined:
    Jan 20, 2012
    Posts:
    2
    Seems fixed now.

    I had a look at the file dates:
    A downloads from 9. March 2012 were probably built 13. February 2012 (date of folders in zip).
    The file I downloaded today 11. June 2012 was probably built 11. March 2012.

    It now is working with 3.5 as expected (e.g. including HDR paths in the prepass-lighting shader).

    It seems something in the deployment of the builtin-shaders package went wrong. Or is it always lagging a few months behind?
     
  26. Jtbentley_v2

    Jtbentley_v2

    Joined:
    Sep 5, 2012
    Posts:
    174
    The download link on the first post is broken... ?
     
  27. breakeren

    breakeren

    Joined:
    Jun 8, 2010
    Posts:
    1
    I cant download Either
     
  28. Nemox

    Nemox

    Joined:
    Feb 16, 2010
    Posts:
    396
    I also can't download any of the built-in shaders. The ones on the examples pages seem to be missing important parts, so this package is very important to me.
     
  29. Martin-Kraus

    Martin-Kraus

    Joined:
    Feb 18, 2011
    Posts:
    617
    Which URL are you referring to? This page: http://unity3d.com/support/resources/assets/built-in-shaders doesn't appear to have "examples" in its address. Which specific shader are you missing?
     
  30. DrakharStudio

    DrakharStudio

    Joined:
    Mar 2, 2012
    Posts:
    8
  31. Chickenlord

    Chickenlord

    Joined:
    May 13, 2011
    Posts:
    381
  32. Manul

    Manul

    Joined:
    Nov 30, 2012
    Posts:
    18
  33. MRKane

    MRKane

    Joined:
    Oct 4, 2012
    Posts:
    54
    I think this is topic relevant, but including one of the internal shaders in the project doesn't seem to overwrite it's function, for instance "Hidden/Internal-Flare". Are there any notes on project behavior when trying to include these shaders as part of it?
     
  34. HaoEver1987

    HaoEver1987

    Joined:
    Sep 29, 2012
    Posts:
    8
    Hi Aras, from DX11Examples-4.0.0b7.zip I have taken in many new ideas.
    But I find these shaders can not adjust shadow, do you have any idea?
    I'm going to write hair shader.
    Please contact me by Email: haoxutao88@126.com, thank you very much.
     
    Last edited: Apr 8, 2013
  35. MadM

    MadM

    Joined:
    Mar 6, 2012
    Posts:
    9
    Hi,

    I just want to know if I am allowed legally to use these shaders code as source (and also with modifications) within my commercial Unity projects as long as I give them new names ? we have pro licences. Or is there some license restrictions (GPL or other) ?

    Best regards,

    Pierre
     
  36. Farfarer

    Farfarer

    Joined:
    Aug 17, 2010
    Posts:
    2,249
    You're free to use them in your Unity projects - they're here for reference and modifying :)
     
  37. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
  38. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
  39. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Anyone know how to replace a cginclude? I am attempting custom shadow filtering, but I have no idea where to put the new autolight.cginc...
     
  40. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,607
    Just paste the contents inside the CGPROGRAM. Or you can do an include if you have a lot of shaders that need to share it, include it like this in each:

    Code (csharp):
    1.  CGPROGRAM
    2.  #pragma debug
    3.  #pragma surface surf Lambert_AlphaTestGlowFix alphatest:_Cutoff
    4.  #include "includes/SurfaceOutputVtxC.cginc"
    5.  #include "includes/LightingModels.cginc"
    The path is relative to the shader file.
     
  41. Farfarer

    Farfarer

    Joined:
    Aug 17, 2010
    Posts:
    2,249
    If you want to replace the built-in ones I think you can place them in the root of your Assets folder?
     
  42. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Actually, I worked it out: modified CG includes go into a folder named Resources, that way, they take effect on any shaders present in the folder once you restart unity
     
  43. DrDecipher

    DrDecipher

    Joined:
    Dec 5, 2012
    Posts:
    54
    I'm looking for the shaders the Scene View uses. I don't believe they are included in the download.

    Is there somewhere they are posted?
     
  44. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    There aren't any scene view shaders. They're just the normal shaders.

    --Eric
     
  45. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    Presumably Dr. Decipher is referring to the Alpha, Overdraw, Mipmap, Render Paths and Lightmap Resolution views available using the drop-downs in the top-left of the scene view.
     
  46. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,607
    That's what I was guessing too. As far as I know, those are not published anywhere.
     
  47. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Also, one of those shaders are broken on my computer: I go "view mip-maps" and everything vanishes until I switch back! :eek:
     
  48. DrDecipher

    DrDecipher

    Joined:
    Dec 5, 2012
    Posts:
    54
    Yes Daniel, I'm looking for those in the drop down. They are some general all encompassing shaders that would be useful to get a hold of.
     
  49. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Well, does anyone know that Unity 4.5.0 has a broken scene viewport shader? o_O as a result, I can't view mip-maps... :(
     
  50. DrDecipher

    DrDecipher

    Joined:
    Dec 5, 2012
    Posts:
    54
    I have not noticed this. Do you have a sample scene?