Search Unity

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,225
    That's really cool. Can I ask what version of the editor you are using? We fixed a whole series of bugs related to graphs disappearing in 3.1 but we might have missed an edge case (It's all to do with the way unity handles custom windows and objects when you click play and then stop). If you can repro it can you let me know the exact steps.
     
  2. Aubrey-Falconer

    Aubrey-Falconer

    Joined:
    Feb 13, 2008
    Posts:
    438
    I'll try to nail down a repro for you later today.

    Thanks so much for creating this tool - you need a donation system!

    While you're here, is a high quality water sgraph available anywhere yet? I am just about to set out to create the ultimate water system, and anything I could build upon would be splendid.
     
    Last edited: Dec 14, 2010
  3. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    I know rea has been working on a water shader, you might want contact them?

    When I say 3.1 I actually mean shader editor beta 3.1 not unity 3.1. Is that the version you are using? There should actually be a Donate button in the Shader Editor menu on the main bar. So there is a donation system in place!
     
    Last edited: Dec 14, 2010
  4. jeroll3d

    jeroll3d

    Joined:
    Nov 6, 2010
    Posts:
    249
    Hi...=]

    Shader rusty metal reflection

    I need a rusty metal shader that reflects the environment. If anyone knows how to do this by controlling the intensity of reflection?

    If it works and someone can answer this question, thank you.

    Sorry my bad English again. : D

    Greetings to all :)
     
  5. rahuxx

    rahuxx

    Joined:
    May 8, 2009
    Posts:
    537
    Hi everyone,

    i hope everyone here will be familier with the mirror reflection script on unitywiki, i want to create similar shader in SSE, is it possible?
    Please guide me as i am not so familier with SSE.
     
  6. Westmark

    Westmark

    Joined:
    Nov 1, 2009
    Posts:
    187
    @Jeroll3d: the standard unity reflective shader already does that. you can control the reflectiveness through the alpha channel :)
     
  7. JackRives

    JackRives

    Joined:
    Oct 17, 2009
    Posts:
    111
    Actually, what he needs is a specular map-based reflection. :)
     
  8. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    doesn't change much actually, just look at the source of the standard one and replace the color lookup with the alpha channel lookup on the spec map :)
     
  9. jeroll3d

    jeroll3d

    Joined:
    Nov 6, 2010
    Posts:
    249
    Ok, Thanks, but a want make it in StrumpyEditorShader. Just it. :p

    :)
     
  10. Tinfoilfez

    Tinfoilfez

    Joined:
    Dec 9, 2009
    Posts:
    14
    We just noticed that the shaders output by the editor don't work correctly on the Mac (and therefore, the iDevices). Unity says that some lines end in Windows code and some end in Mac code. Is this a known issue, and is it something we should be doing on our end?
     
  11. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    line ending clashes don't cause compile errors though. its only a warning, no error.

    code that does not work on mac (or better iOS target) is commonly more related to features just not present on the mobile OpenGL ES 2.0 target as not everything is available (ok quite some stuff isn't)
     
  12. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    The shaders work properly on mac (it's primarily developed on OSX unity ;) ) The warning you are seeing is just for line endings and can be ignored. I have never actually seen this on OSX though only windows I'll see if I can remove them for the next release but it should not stop anything.

    As for iDevices, they are currently not 'supported'. That means that they may work if you write a SM2.0 compatible shader and set the target to be OpenGL ES 2.0 they may work, but we haven't been through internal testing on iDevices yet. This is something we mean to do but we are currently working on adding more features before we do this pass.
     
  13. XRA

    XRA

    Joined:
    Aug 26, 2010
    Posts:
    265
    Is there a certain trick or setting I'm missing to get shaders made with the editor working with mesh batching? At first I thought maybe it isn't batching due to a shader having constantly updating values (like a UV pan with the time component) but even with the basics (a single color input into albedo) my meshes aren't batched, yet if I swap to a default Unity Diffuse texture they will be.
     
  14. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    are you just working with the shader or actually modifying the material? the later would cause new material clones if you did it at runtime, actively breaking batching.

    I didn't check what the generated shader would look alike but as long as the change is all within a CG it should still batch. if it ends with some c# / unity script code feeding data it will normally no longer batch
     
  15. XRA

    XRA

    Joined:
    Aug 26, 2010
    Posts:
    265
    I'm not updating anything at runtime from what I can tell, I have a material that uses a shader exported from the strumpy editor which just has Input Color going into Albedo as a test. Then that shader is in a material which is on a prefab, and only that prefab uses the material. I then create instances of the prefab at runtime but they don't end up batching. If I change the prefab's material shader to any of the default provided Unity shaders everything batches as usual (after restarting the game from the editor).

    As another test I tried the supplied NormalMap and RimLighting examples but they don't batch the meshes either. Is there something I need to modify in the *.shader file that could get it working? I have tried some other shaders that might have been written from scratch and those actually batch fine.
     
  16. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    hmm ...
    The only thing aside of skinned meshes that I know thta can kill batching normally is if there is alpha present.

    As such compare 2 things between those working and those not working:

    1. Do they write the alpha too?
    2. Do they use a colormask to kill out the alpha channel (ie colormask RGB)

    2 would be horrible cause colormask is a pretty beefy performance killer on iOS
     
  17. thellama

    thellama

    Joined:
    Mar 25, 2010
    Posts:
    360
    I think we need to add an sgraph section to the http://www.unifycommunity.com

    Sgraphs so people can learn and alter the source for there own needs.

    My team developed a snow shader that applies snow on the up world normal vector on normal maps. It can also be used for moss and dirt and sand. Really cool.
     
  18. Tinfoilfez

    Tinfoilfez

    Joined:
    Dec 9, 2009
    Posts:
    14
    Good to know. Although, this shader isn't anything particularly complex. I was just wanting something to blend two textures with an alpha map. The sgraph is below. Is this unlikely to work?
     

    Attached Files:

  19. Tinfoilfez

    Tinfoilfez

    Joined:
    Dec 9, 2009
    Posts:
    14
    Stramit, did you, by chance, have some time to look into why the grab screen was upside down on that bubble dome shader I was working on? I appreciate your time.
     
  20. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    what error do you get and what is the output shader of it? (especially the compiled one so we see if the glsl optimizer had a negative impact)

    technically I see no reason it shouldn't work, its 3 textures and a handfull of trivial operations, nothing thats outside the specs.
     
  21. Tinfoilfez

    Tinfoilfez

    Joined:
    Dec 9, 2009
    Posts:
    14
    Here's the shader file and the sgraph. The error itself is just the warning about Mac and Windows endings. However, on the Mac, the groundplane is all black when the shader is applied.
     

    Attached Files:

  22. thellama

    thellama

    Joined:
    Mar 25, 2010
    Posts:
    360
    Nevermind, I took off my moron hat and cleaned out all my 3.0 files first.

    I just downloaded 3.1 and when I update my shader it turns solid dark gray and no matter what I do it won't change. Even if it's a basic texture only shader. Anyone else had this problem?
     
    Last edited: Dec 17, 2010
  23. XRA

    XRA

    Joined:
    Aug 26, 2010
    Posts:
    265
    I'm new to shaders but for 1, I have Transparency set to off and Queue as Geometry in the shader editor when clicking on the master node in the pixel graph, so that would make me think alpha wouldn't be used, as for 2 I'm not sure.

    As another test I just used a default blank shader graph, and without adding any nodes it still stops batching from working, but then if I edit the exported shader file and remove the code in CG program, the batching will work. I'm assuming now it is something the shader editor does on export, maybe if I compare some basic shader files I'll be able to figure out what the difference is, it is probably something really simple that I don't quite get yet :)
     
  24. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    Had a look at this. It works for me as expected. I needed to set the graphics emulation to OpenGL ES 2.0 though. Have you done this? This is required as you need ES 2.0 support for SM2.0 shaders which is what you will be generating if you are targeting iDevices.

    Before:


    After:
     
  25. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    Thanks for bringing to our attention a potential batching issue XRA. I'll have a look into it over the weekend while I'm working on some features. If you do figure out what aspect of the exported shader is causing this issue for you let me know as it will save me time.
     
  26. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    I'll be looking at this one the weekend. It's on my list of 'slightly more complex' things to do.
     
  27. Tinfoilfez

    Tinfoilfez

    Joined:
    Dec 9, 2009
    Posts:
    14
    Nice! That was it. I had a feeling it would be something we didn't do on our end.
     
  28. noradninja

    noradninja

    Joined:
    Nov 12, 2007
    Posts:
    420
    Sample:


    Graph:


    I know it has been said there isnt iOS support yet, just wanted to confirm, at least on my iPodTouch 4th Gen, this doesnt work, everything is solid black. Is there a way to force the app to use OGLES 2 to render?

    (Well not quite black...see below)

     
    Last edited: Dec 17, 2010
  29. EmadGh

    EmadGh

    Joined:
    Jun 10, 2009
    Posts:
    147
    Hi, Thanks for the really awesome shader editor you made .
    I think there is a bug with Matrix node. When I add it cause a problem.

    NullReferenceException: Object reference not set to an instance of an object
    StrumpyShaderEditor.InputNode.IsValid (SubGraphType graphType)
    StrumpyShaderEditor.SubGraph.IsNodeValid (StrumpyShaderEditor.Node validatingNode)
    StrumpyShaderEditor.SubGraph.UpdateErrorState ()
    StrumpyShaderEditor.ShaderGraph.UpdateErrorState ()
    StrumpyShaderEditor.NodeEditor.OnGUI ()
    NodeEditorWindow.OnGUI () (at assets/Editor/ShaderEditor/NodeEditorWindow.cs:27)
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture)


    and all the things in editor will be disappear.
     
  30. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    There was, it's fixed in 3.2. I missed something when I was refactoring code for 3.1.
     
  31. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,467
    hey stramit, i have a question for you...is it possible to create a shader for like toon rendering or shading like in the game Okami using SSE?
     
  32. EmadGh

    EmadGh

    Joined:
    Jun 10, 2009
    Posts:
    147
    Ok , thanks
     
  33. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
  34. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    That's interesting. so it shows up right with emulation selected in the editor but not on the iDevice itself? I don't actually have an iDevice handy atm to test this on so I don't know if I would be able to help. You might try changing flags / nodes and seeing if it fixes anything. If you do find what the issue is let me know. We'll be doing a real iOS pass sometime in the future.
     
  35. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    It will be when 3.2 comes out. The custom lighting support currently is quite rudimentary and only supports deferred (where you don't get a light incidence vector). For toon shading you need the light incident vector to be able to do toon color banding based on light incidence angle with the surface. 3.2 will support the ability to do forward pass custom lighting.
     
  36. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,467
    You lost me on this one friend :) I haven't even messed with custom lighting yet
     
  37. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Hey Stramit, did SSE support particle shader?
     
  38. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    Probably a stupid question, but I'll ask it anyways: Can SSE be used to develop full screen image effects for Unity Pro?
     
  39. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    No to both of these. SSE is made for surface shaders... maybe in the future though ;)
     
  40. Panaroma studios

    Panaroma studios

    Joined:
    Dec 19, 2010
    Posts:
    32
  41. noradninja

    noradninja

    Joined:
    Nov 12, 2007
    Posts:
    420
    I wil do some more tests with just the included sgraphs today to see how it works out; maybe I am missing something simple.

    My bug issue now is that, things were working fine, I upgraded Unity 3, and now when I make a graph, I am unable to edit any variables for that material in the inspector (nothing shows up in the inspector when I select the material).
     
  42. noradninja

    noradninja

    Joined:
    Nov 12, 2007
    Posts:
    420
  43. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    Did you upgrade unity or the shader editor? What version of unity did you upgrade to? Can you completely remove the shader editor from the project and reimport it. Can you also test importing the shader editor into a new project and see if this issue occurs?
     
  44. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    Hey is it possible to use colored specular texture with normal map with this shader editor?
     
  45. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    Sure is. If you look at the included graph 'rimlighing' there is an input called MySpecColor. If you replace this with a texture input you can use that as specular color. Also looking at the included 'normalmap' graph will show you how to do normal maps.
     
  46. noradninja

    noradninja

    Joined:
    Nov 12, 2007
    Posts:
    420
    - I Upgraded Unity, to version 3.1.0f4 (55865)
    -If I remove the editor from the project and reimport it, it is still broken (no adjustments in Inspector for material)
    -If I make a new project and import an sgraph (included ones or mine), same problem.
    -If I make a new project and make a new shader from scratch, it works.

    I think I figured it out...when I made the new project and reimported SSE, I unchecked the temp internal files relating to the autosave graph and the temp shader...this seems to have corrected the problem, I will let oyu know.
     
  47. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    Hang on, by inspector do you mean the material inspector inside the shader editor or the unity material inspector when you change materials in the scene? We don't have any connection to the unity material inspector. If it is the unity inspector ensure that you are 'exporting' the shader with a valid name and there are no duplicate shaders with the same name.
     
  48. Deleted User

    Deleted User

    Guest

    We want iOS support! =D

    Do it! *handclap* - Do it! *handclap* - Do it! *handclap* - Do it! *handclap*

    *thousandofscreamingchildrens*
     
  49. 3Duaun

    3Duaun

    Joined:
    Dec 29, 2009
    Posts:
    600
    does the shader editor not already support iOS shader output
     
  50. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    within borders
    It does not allow you to specify it to target it explicitely and only.

    But in the end: you don't want to use the surface shaders for iOS normally anyway. Surface shaders is about light and light interaction and pixel light is one of the best ways to kill your hole performance to non-fluent low fps