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

Strumpy Shader Editor [Now Open Source]

Discussion in 'Works In Progress - Archive' started by Tim-C, Aug 2, 2010.

  1. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,221
    Hi!

    I have been a bit bored after work for the past few weeks and my Unity3 beta arrived so I decided to make a shader editor.

    I approached the task initially to see just how extensible the Editor API's were and to see if it could be done (fully featured and at a commercial standard). And after an evening or two I was knee deep in the unity3 codebase!

    There were a few things I wanted to do when making this editor:
    *High quality standard
    *Rich feedback to the user
    *Realtime previews of the current shader
    *Loading / saving of graphs
    *Shader export
    *Complete support for the unity3 materials system (That aras and co have done an amazing job of!)
    *Fits into the unity design principles. Easy to use / simple / 'just works' - this was very important to me!

    A simple shader (Updated for Beta 4.0)


    Tutorial Videos:
    Beta 4 - http://vimeo.com/20994055
    Beta 1 (Still helpful!) - http://www.vimeo.com/13825713

    FAQ Post:
    Some questions, answered with demo's: http://bit.ly/hnXhNu
    ------------
    Contributers
    Stramit
    Texel

    Releases
    5 August 2010 - Beta 1.0 - here
    6 August 2010 - Beta 1.1 - here
    1 September 2010 - Beta 2.0 - here
    6 September 2010 - Beta 2.2 - here
    11 November 2010 - Beta 3.0 - here
    27 November 2010 - Beta 3.1 - here
    9 January 2011 - Beta 3.2 - here
    10 January 2011 - Beta 3.2a - here
    19 January 2011 - Beta 3.2b - here
    11 February 2011 - Beta 3.3a - here
    12 February 2011 - Beta 3.3b - here
    14 March 2011 - Beta 4.0a - here
    24 December 2011 - Beta 4.0b (Unity 3.5) - here

    Documentation
    User Documentation - By Texel can be found here.

    Some Images users have created with SSE materials:

    Procedural Lightening Created using Vertex Shaders in SSE by BoxMan


    A scene made by warby, where the shaders were made in SSE


    A snow shader (amount of snow changes based on normal) by Svyatoslav


    A planet by Clamps, you can follow his tutorials to make this

    Open Source Link
    Here is the link to the GIT hub project. Have fun :)
    https://github.com/stramit/SSE.git
     
    Last edited: Dec 27, 2011
  2. br0kenp0ly

    br0kenp0ly

    Joined:
    Jun 3, 2008
    Posts:
    481
    Wowzer!
    Been following your development for a little while now must say I`m extremely impressed :) Really looking forward to giving it a try soon!


    Keep up the great work!
     
  3. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    Neat. Unity really needs something like this so that more people can harness the power of shaders without having to be an advanced programmer.

    What would really make this great, besides all those millions of functions you have built in, is to have `presents` or `templates` of various little pieces of typical shaders that you can just drag and plug in without having to start from scratch.
     
  4. Thomas-Pasieka

    Thomas-Pasieka

    Joined:
    Sep 19, 2005
    Posts:
    2,174
    Finally something that looks like it belongs into Unity ;) I am glad you didn't choose a weird GUI or funky colors. This blends in nicely.

    I'd love to fool around with it!

    Thomas P.
     
  5. deis

    deis

    Joined:
    Sep 17, 2009
    Posts:
    29
    Really excited for this and the possibilities.
     
  6. niosop2

    niosop2

    Joined:
    Jul 23, 2009
    Posts:
    1,059
    Excellent job, this will make tweaking simple surface shaders much easier for most users.

    Is it fairly simple to add new node types? If you're not selling this, make sure to put up a donate button somewhere, I'm sure lots of people would like to thank you.
     
  7. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,373
    this is awesome,
    they should implement this type of shader editor in unity
    well cant wait to try this,
    great work
     
  8. Veli

    Veli

    Joined:
    Mar 10, 2009
    Posts:
    301
    Not meaning to bitch but this struck me as funny:
     
  9. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    If you are successful in completing this project, you will be a very popular person here! ;)
     
  10. fallingbrickwork

    fallingbrickwork

    Joined:
    Mar 16, 2009
    Posts:
    1,072
    Brilliant work!!! Can't wait to get my hands on the Beta and take it for a test drive.

    Regards,
    Matt.
     
  11. Jonny-Ree

    Jonny-Ree

    Joined:
    Aug 15, 2009
    Posts:
    22
    Brilliant! Looking forward to trying this out
     
  12. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Looks nice

    Will be interesting to see where its going to keep shader model restrictions and alike in mind but its definitely a solid base already at least from the visual look
     
  13. GeneralGrant

    GeneralGrant

    Joined:
    Jun 10, 2010
    Posts:
    977
    These confuse me. I never bothered to learn them. But, what exactly DO these node base editors do?
     
  14. Silver

    Silver

    Joined:
    Nov 8, 2009
    Posts:
    38
    if you had the chance before to write shaders then you will understand why these node based editors are a must. Instead of worrying about syntax and hell of coding you just drag, drop and link ur nodes and ur off to go.
     
  15. rozgo

    rozgo

    Joined:
    Feb 7, 2008
    Posts:
    158
    Nice work!
     
  16. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
  17. theinfomercial

    theinfomercial

    Joined:
    Sep 9, 2008
    Posts:
    1,000
    Yes!

    The only things I would actually change are to make the linear node links turned into ease in/out links, and have a node property preview displayed on the node (like how the unreal engine mat editor does it). Can't wait for the open beta, you're saving us from shader coding hell. :D

    CC: The Unreal Engine has a mat editor that uses node based shader programming. It's because of this that games like Unreal Tournament 3 have such incredible shaders. Because they're so easy to make. I played around with the editor in Unreal and was able to edit the shaders and make new, completely different ones on my first try using it. Couldn't have done that to save my life in shaderlab.

    Needless to say, I want this in Unity. :)

    P.S. Please be sure the beta (in whatever stage it's in) actually does come out. So that way we at least have something to extend should you cease to work on it (for whatever reason). I only say this because Kurt's shader editor is stuck in development hell (like zjp points out) and he never posted a beta for us to continue. :?
     
  18. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,221
    Thanks for all the kind words everyone. It's great to hear that you think you will find this useful!

    Thanks. For the most part I've found working with the unity API's to be great, although I did encounter a few API limitations and idiosyncrasies while I was working.

    The node API is really easy to expand if you know how to program in c#. There are a few 'functions' built in that are non standard (like the UV pan, swizzle, and splat). And I intend to add more / do some tutorials on how to add custom nodes.

    Very simple to add new node types. I designed it specifically to be easily extensible. You just have to inherit off 'Node' or 'InputNode' ect and implement the interface. There is some field markup required for serialization / getting the node in the nodes lists. But it's quite trivial.

    Currently is uses the basic unity3 lighitng with a slightly modified lighting shader. I plan to add support for custom lighting shaders ect, that will probably be in beta 3 though.

    They make the creation of shaders a content / art task instead of a programming task. This isn't always so (ie some specific hand crafted shaders for post processing ect). But in general I think it's a fair statement. I have seen some amazing shaders generated in graph editors. But I have also seen some abominations. It's all dependent on the skill of the artist.

    I want to use bezier handles for the lines, it's something I still have to add in though.

    I currently don't have plans to display the default texture / color on the node. This could be added pretty easily but I think it's a bit confusing. Unlike unreal in unity shader textures / inputs are frequently overridden (via a material or the preview node in this case). I think it adds a level of complexity that I was trying to avoid. I could be convinced otherwise though.

    It think the reason that unreal's shaders look so good isn't because of the material editor per se, but by the number of people using it / it's use in AAA games.

    The code for the beta is done, unless I come across any crazy show stoppers. I haven't released it yet because there is no documentation. I don't think I will write too much, but a simple tutorial and some other simple stuff would be nice!
     
  19. Jonny-Ree

    Jonny-Ree

    Joined:
    Aug 15, 2009
    Posts:
    22
    I don't think it would confusing, and personally it would be very helpful in debugging. Once shaders become fairly complex, it may sometimes be difficult to keep track of what is going on, especially if you're making changes to an older shader. Its nice to see which texture is coming in where, as well as. Even nice would be to have small icons for representation of each node. Just for the sake of getting a quick overview of the shader. That would probably be some more work however. Simple shaders it really doesn't matter, just a thought for once they start filling up.

    Great work regardless though. Looking forward to testing it.
     
  20. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    I think optimally, also for performance, would be if you had a second (toggle) button on the node which either shows the previous as overlay or expands the node to include the preview.

    I agree that having all on preview mode can be very confusing especially as it means that you need to provide input textures too to make any sense.
     
  21. RElam

    RElam

    Joined:
    Nov 16, 2009
    Posts:
    375
    That is very nice work, especially for the time you've put into it. If you like, I have a color correction matrix constructor that could be a nice addition, basically a component that gives you a bunch of color correction options that end up just one matrix multiply in the shader. It's quite useful in conjunction with Unity's animation system.
     
  22. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,221
    That's a good approach to it if I was to implement a preview for input types. The problem I have is that I consider the generated shaders to not be 'game specific' so if you set a default texture to be 'my customtexture' what happens if you then share this shader with another developer or the resource is deleted. There is no way for the unity shader system to know about this (it will default to black) but this isn't desirable I do not want the shaders that are generated to be dependent on content.

    There has to be a comfortable mid ground on this issue and I'm still mentally trying to reconcile a few other things to support in this area as well. I do think something needs to be done, I just want to do the right thing from a usability perspective.
     
  23. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,221
    Thats really cool. What I think a better idea is then me just going and creating a node for it is that when I release this you have a go with the given API's to create the node. It will give me some valuable feedback in that area so that I can improve it! (Currently there is no matrix input node / type support, I have that planned for Beta2).
     
  24. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Thats the problem I see too.
    On the other hand, shaders are always kind of task specific so comparable textures should lead to a comparable result unless the shaders had hard color inputs so that should be of a smaller concern.

    I am looking forward to see this usability :)
     
  25. Pixelstudio_nl

    Pixelstudio_nl

    Joined:
    Jun 22, 2009
    Posts:
    179
    Like all other people i'm very excited to try this out!!

    Looks very helpful already! good job!
     
  26. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,221
    I have the beta release packaged and ready to go right now!! I just need to do some testing on a Windows PC then I will let it out of the box (I only have a mac).

    The release will be within the next 12 hours!
     
  27. Silver

    Silver

    Joined:
    Nov 8, 2009
    Posts:
    38
    cool, i am rly excited to try it!
     
  28. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    THX 8)

    Jp
     
  29. fallingbrickwork

    fallingbrickwork

    Joined:
    Mar 16, 2009
    Posts:
    1,072
    Can't wait to test it... I've set an alarm to recheck in 12 hours! :wink:
     
  30. Morc

    Morc

    Joined:
    Jul 21, 2009
    Posts:
    31
    Wow! Looks really nice! Eager to check it out :D
     
  31. HJP

    HJP

    Joined:
    Jul 8, 2009
    Posts:
    152
    Wow, awesome work.
     
  32. Nick3d

    Nick3d

    Joined:
    Jan 28, 2010
    Posts:
    100
    Amazing, this is really a life saver for an artist :D
     
  33. Yusuf-AKDAG

    Yusuf-AKDAG

    Joined:
    May 13, 2009
    Posts:
    280
  34. RElam

    RElam

    Joined:
    Nov 16, 2009
    Posts:
    375
    Yea, it'd be awesome if this could be implemented as a derived material and create the shader in the background. Would massively improve Unity's shader authoring ability.
     
  35. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,221
    There appears to be a few (minor I believe) issues on windows with regards to the generated shaders.

    I'm going to pick up a copy of windows 7 at lunch today and install bootcamp tonight. Sorry for delaying the launch. I just want to be sure that it works properly on all platforms before i release.
     
  36. Xaio Fa

    Xaio Fa

    Joined:
    Aug 2, 2010
    Posts:
    3
    Nice work!
     
  37. giyomu

    giyomu

    Joined:
    Oct 6, 2008
    Posts:
    1,094
    wonderful, you are going to make happy a lot of artist geek here ;)
     
  38. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,221
    Hi everyone. I have just put the finishing polish on beta 1.

    3 demo graphs are included (I will add more as time goes on). You should have a look at these to see how everything hooks up. There is currently:
    -A rim lighting shader
    -A normal map shader
    -A UV pan shader



    This will only work with unity3, and there are a few known issues, which I will list in a minute.

    Installation
    1)Download the unity package attached to this post
    2)Open a fresh unity3 project (it should work in a non frosh project as well, but back it up first!)
    3)Import the package into unity. Ensure you import ALL the assets (assets->import package)
    4) In the windows menu there will be a new entry: 'Shader Editor'. Click this to launch the editor
    5)I strongly recommend that you run the shader editor in docked mode with the window maximized. This gets around 1 or 2 small issues with the unity windowing system focusing the wrong window after selecting a value from a texture / color / other popup.

    What I would like from you is any bugs / feedback / feature requests. If you update / generate a shader and it turns out to be invalid (the preview will turn purple). Please save the shader graph and post it here, or PM it to me. I do not know of any cases outside of the known issues where this can currently happen.

    Before you lodge a feature request / bug please check the list of known issues and the roadmap for the editor.

    Roadmap
    Beta 2
    -Bug fixes / Missing nodes
    -UI updates / rework (Add right click to add node, remove right side bar / rework preview panel)
    -Matrix / rotation support.

    Beta 3
    -Custom lighting support

    Beta 4
    -Custom vertex shader support

    Known issues
    If you set the preview mesh to be none, the editor will throw an exception
    Workaround: Do not set the preview mesh to null. If you do; close the shader editor window and reopen it this will restore the default preview.

    If I dock / undock / maximize / minimize the editor window the preview goes back to it's defaults
    Unity windowing is a tricksy beast. Sometimes the editor window decides it needs to recreate it self (demaximizing the window is an example). This means that the preview node is lost and needs to be recreated. I am working on manually serializing the preview node on window destruction so that it can be restored and not lose state. This is scheduled as part of the beta 2 work.

    If I name a node _LightColor0 / LightColor0 / _SpecColor / SpecColor the shader will not compile / update
    Unity has internally predefined these names in it's lighing CG file. You can not use these names for an input property of a shader or it will fail to compile. Validation has been added to error the shader graph if you do this; but it did not make the beta1 release :(

    I'm sure there are lots of questions. Please watch my preview video (http://www.vimeo.com/13825713) to get an idea of how to use the shader editor. Sometime in the next week I will release some short API documentation and user documentation which will detail how to add new nodes / extend existing nodes.
     

    Attached Files:

  39. Jehuty

    Jehuty

    Joined:
    May 5, 2010
    Posts:
    7
    THNAK YOU SO MUCH, stramit. Awesome!

    This only works for Unity 3? Pro or Free?

    Is there any way to support you? Like donations or so.... I would like to make sure you like to keep working on this and make it worth your while...
     
  40. thomasmahler

    thomasmahler

    Joined:
    Mar 18, 2009
    Posts:
    181
    This is pretty amazingly awesome and should be in Unity natively by the looks of it - can't wait to try it out!
     
  41. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    Agreed. Plus I think it is a great way to help "normal folks" (like me) to learn how shaders work.
     
  42. fallingbrickwork

    fallingbrickwork

    Joined:
    Mar 16, 2009
    Posts:
    1,072
    Thank you for this... Can't wait to get home and have a play.

    Looking forward to seeing how this project develops, it is a fantastic (needed) addition to Unity.

    Regards,
    Matt.
     
  43. Morc

    Morc

    Joined:
    Jul 21, 2009
    Posts:
    31
    Awesome! Your the man! 8)

    Thanks A LOT!
     
  44. Silver

    Silver

    Joined:
    Nov 8, 2009
    Posts:
    38
    Thanks alot champ.

    vote sticky to keep it visiable to everyones and get them test it more till its polished.
     
  45. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,221
    Well as unity 3 isn't out yet I have only tested it with the beta (i.e pro version). This graph editing should work with the non pro version when it is released but the preview may need some severe wrangling as it utilizes drawmesh and rendertextures. I might lodge some support tickets to get some preview functionality exposed into the non pro API's so that I can do this without doing anything too hacky... but I'm not sure if anything will come of it.
     
  46. scottpetrovic

    scottpetrovic

    Joined:
    Dec 16, 2009
    Posts:
    7
    I am not too versed with Shader languages. What is the best resource out there to look up the API for all of these shader functions. I am guessing these are using CG?
     
  47. niosop2

    niosop2

    Joined:
    Jul 23, 2009
    Posts:
    1,059
  48. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,221
    The amazing Texel has put together some documentation on using the Shader Editor.

    You can find the documentation here. The documentation covers adding nodes and lots of other great stuff as well as a few simple shader tutorials / best practices!
     
  49. maxfax2009

    maxfax2009

    Joined:
    Feb 4, 2009
    Posts:
    410
    Great work :)
     
  50. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601