Search Unity

Strumpy Shader Editor [Now Open Source]

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

  1. womanonfire

    womanonfire

    Joined:
    May 19, 2009
    Posts:
    2
    @gfxguru i had this problem too and found that if I checked the option 'Write Depth' in the Master node options it made the shader opaque again. Don't know why this is necessary though...

     
  2. womanonfire

    womanonfire

    Joined:
    May 19, 2009
    Posts:
    2
    Could someone please help me improve my shader. I am very new to this whole shader business but trying to learn! I've upgraded to Strumpy 3.3a and I am attempting to make a shader which blends between two textures, with normal maps and specular. (you are asking why I don't just use the 'ubershader' posted a few pages back... well, I don't really understand what is going on in that one. Seems a bit more complex than what I need...I believe I will learn more if I try to build this on my own to do exactly what I want it to do.) I really just want a slider (value) that can fade between the two textures.

    Question 1) Is this the best way of setting up the Normal Map nodes? Is there a way I can get more control over the Normal map appearance.
    Question 2) Specular doesn't seem to have any visible effect would setting up an option for Gloss help? (what is Gloss for anyway, exactly?)


    not sure this will work but here is a link to my .sgraph file: http://auriea.org/data/static/blendtwotextures.sgraph
     
  3. gfxguru

    gfxguru

    Joined:
    Jun 5, 2010
    Posts:
    107
    Thanks womenonfire.....

    Does somebody help me to turn off the diffuse lighting or shading of the shader....in cubemap i dont need that....

    im too noob...
     
  4. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    If you just hook it up to the emission channel instead of the albedo you won't get any lighting just emission.
     
    Last edited: Feb 27, 2011
  5. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    I jason, I don't really know where to start, but I'll start by saying that graphics programming and by extension, shader programming is inherently a complex area of computing. Because of the this there is a required base level of understanding on how lighting systems and surface interaction occurs before you can really write a shader that does what you want it to do.

    But to address your points:
    I really disagree with this statement. I work exclusively with and FX artist who has no idea about programming and he has been using shader editors in the UDK and in Unity for quite a while. He makes some very amazing systems that I could not even attempt if I tried. There are reasons that the UDK material editor is so highly valued for UDK users. It lets you do amazing things, but you do need to learn how it all works.

    I think that's a bit extremist. If you take the time and go over some of the example graphs, do some reading on how lighting works in unity (the built in docs are good for this) then you should be able to make progress. It will take time!

    Everything (apart from sampler inputs) in SSE is a vector 4 (float4). You don't normally need to worry about the type as the nodes handle it all for you under the hood.

    Preview requires render textures which are pro only. Even with the preview each time you update there will be a pause as it needs to recompile the shader for the preview.

    We don't have any plans to make the editor more target to beginners. We think that it currently strikes the right level of abstraction between shader language and graphical interface. What we do plan on doing is rolling out more training materials that should help people become better accustomed to writing shaders in a node editor.
     
  6. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    Can you elaborate on what you mean by 'Normal map appearance'? You can do lots of things, but i'm not sure what you specifically mean.

    Both specular and gloss are required for there to be a specular effect. Internally what will happen is:
    Code (csharp):
    1.  
    2. float3 specularColor = pow (nh, s.Specular*128.0) * s.Gloss;
    3.  
    So looking at the code you can see that the specular value controls the falloff of the specular (it will use the x component of what you put in) and the gloss is the specular color and will use the xyz of the input vector. If either are zero (the default) then there won't be any specular highlight. As a side note, it is normally expected that 'gloss' is the falloff and specular color is the 'color / brightness'. But unity have them around this way internally for some reason. In beta 4 these have been renamed to be clearer.
     
  7. loken

    loken

    Joined:
    Mar 25, 2009
    Posts:
    109
    Stramit, new UI looks really slick. Much less cramped, and looks like it'll be easier to expand upon.

    Keep it up man. Always looking forward to the next beta. =)
     
  8. gfxguru

    gfxguru

    Joined:
    Jun 5, 2010
    Posts:
    107
    By default i think the shaders are for SM 2.0, when i emulated hardware, my glass shader went black when switched to SM 1.
    But a shader i got from the forum was still working...

    How to make the shader compatible with SM 1 as well?????
     
  9. mrbdrm

    mrbdrm

    Joined:
    Mar 22, 2009
    Posts:
    510
    Hello
    sorry to ask this here but could someone with experience do a character shader with specular texture , paid work of course .
     
  10. Frank Oz

    Frank Oz

    Joined:
    Oct 13, 2010
    Posts:
    1,560
    Yeah wrong place to ask this, you should ask in the paid or collaboration sections, and give more details (there, not here).
     
  11. J_P_

    J_P_

    Joined:
    Jan 9, 2010
    Posts:
    1,027
    Maybe I'm doing something wrong, but when I load the rim lighting graph it just looks like a diffuse texture. Updating shader doesn't change anything.. most of the other included graphs seem to just show a flat gray object in the previewer.

    edit: Ah -- I think it was because I had IOS graphics emulation turned on. Any way to tell what works/breaks when switching to emulate IOS graphics? Do you think this shader editor has much value for an IOS dev?

    I was seeing if something like this would be possible: http://forum.unity3d.com/threads/79957-Procedural-Texturing-how-would-I-do-this
     
    Last edited: Feb 28, 2011
  12. rahuxx

    rahuxx

    Joined:
    May 8, 2009
    Posts:
    537
    waiting for beta 4.
     
  13. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    I don't currently believe that (complex) surface shaders should be used for iOS development, and much prefer hand crafted shaders. If you want to get the best performance it's much better to lightmap everything that is static (and have no 'dynamic' lights on it) and then have a single directional light for dynamic objects. This could be done in a surface shader but it's much better to use a built in or hand crafted shader imo. Maybe in a few generations of iDevices they will be fast enough. :(
     
  14. hriswana

    hriswana

    Joined:
    Jan 21, 2011
    Posts:
    1
    I have problem to download pdf documentation from dropbox (i always get "The connection has timed out" everytime i try to reach pdf file) Is there any other mirror for this file ? Thank anyway.
     
  15. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    It's actually included with the latest release in the SturmpyShaderEditor/Documentation folder after you install the package.
     
  16. dongio

    dongio

    Joined:
    Sep 28, 2010
    Posts:
    16


    hi, here is little project with same transparency issue hope you best. doing amazing jobe :

    http://creative.ge/example/spaceman.zip
     
  17. ayanami0

    ayanami0

    Joined:
    Feb 22, 2011
    Posts:
    8
    Hi Strumpy,

    There is a couple of things that bothered me about the shading system of Unity3,

    First of all, The term Specular and Gloss is being switched. Specular Power or Gloss is functioned as Specular Brightness, yet Specular is being used as specular Power.

    Its wrong and confusing to use, and its misleading for people who are new to the concept. They might carry this misinformed habit to influence other people. I know this isn't related to your work, but just thought to rant about it... I am just foolishly hoping that the nice people who made this can see this post and fix this issue in the future release.
    from
    Code (csharp):
    1. float3 specularColor = pow (nh, s.Specular*128.0) * s.Gloss;
    to
    Code (csharp):
    1. float3 specularColor = pow (nh, s.Gloss*128.0) * s.Specular.rgb;
    Anyway, the reason that I am writing this post is wondering if you can modify the internal value from 128 to something higher like 256 or 512?

    This should allow even tighter specular high light, instead of the current broad hilight that looks plasticky. With a higher power, the specular can look better with glossy or metallic objects.
    like this:
    Code (csharp):
    1. float3 specularColor = pow (nh, s.Gloss*512.0) * s.Specular.rgb;
    I don't know if this is somthing that you can modify or not, Strumpy. Maybe you do talk to people who create the Unity system. But just thought that I should try

    Cheers
     
    Last edited: Mar 3, 2011
  18. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    Hey dongio,

    What you need to do to get this working all nicely is split the mesh into two materials. One material for the opaque section (the body and head) and one material for the transparent helmet. What you are seeing is an issue that would be evident is pretty much any real time renderer.

    To elaborate,

    Because you are rendering the whole object as transparent there is nothing being written to the depth buffer, because of this when it goes to render the whole object in one pass it is getting confused as to which triangles are in front of other triangles. Basically they just get rendered in the order they arrive at the GPU and are unsorted. To fix this you need to render the non transparent first (with depth writes turned on) and then render the transparent at a later stage with depth testing turned on but depth writes disabled. This will fix the issue. All games do this.

    Thanks for the repro file, and that little dude is very awesome.
     
  19. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    Hey ayanami0,

    I am well aware of the issue and we have had multiple discussions on it during the course of this thread. It's a very tricky one to resolve for a few reasons reasons:
    1) Going against unity's 'default' names could confuse people familiar with shader lab.
    2) Changing the underlying structure names could cause issues with beast / other middleware expecting certain channels
    3) You can't modify the light prepass specular equation per material (i.e the value of 128.0 is hardcoded, but you can change the value of s.specular... although it has a maximum for deferred that can not be avoided :( )

    But you are very right by saying is very true and was confusing for me as well when I started writing surface shaders. For beta 4 what i have done is just change the display names of the inputs (flipped them). This should fix most of the confusion.
     
  20. duncanx

    duncanx

    Joined:
    Feb 12, 2011
    Posts:
    45
    Can this tool build a fur shader?
     
  21. ayanami0

    ayanami0

    Joined:
    Feb 22, 2011
    Posts:
    8
    I know.. Its also not your problem. I am not hoping to change it per material, I am just saying this value being hard coded should be higher for everything, as lower spec power would result in the same as current lower valued. But in a hing sight.. it being set at such a low value just limits what can be done by the artists and coders..

    Yeah, certain engine called G@mebryo had exactly the same naming problem, that's why I am suspecting this naming issue is actually being inherited from that. Maybe not.. ha! But its nice to see that you are setting things right..And may Unity God bless you for this!!! Looking forward to b4!
     
    Last edited: Mar 3, 2011
  22. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225


    Could this be Beta4 so so close to being complete?!
     
  23. Frank Oz

    Frank Oz

    Joined:
    Oct 13, 2010
    Posts:
    1,560
    ooooh it's looking so much nicer! Awesome work!
     
  24. ayanami0

    ayanami0

    Joined:
    Feb 22, 2011
    Posts:
    8
    Oooo! I see the fixed gloss/specular and new performance analysis and new Awesome UI you brought us! Thanks!
     
    Last edited: Mar 3, 2011
  25. rahuxx

    rahuxx

    Joined:
    May 8, 2009
    Posts:
    537
    great work stramit.
    How fast the shaders are now?
     
  26. ayanami0

    ayanami0

    Joined:
    Feb 22, 2011
    Posts:
    8
    Hi Strumpy,

    Just thought that before you ship out the b4, I should report some annomalies to you.

    1. When a normal Map node is being created with your editor, can you please change the default color to a blank normal color (0.5, 0.5, 1.0) so the preview sphere won't look all funny with a blank Normal Map Node?

    2. When linking a float4 specMap texture output to Gloss input of Master node (or the specular in SSE b4 ;)), it turns the float4 to half3 automatically.
    But if I were to multiply the Tex2D's RGBA to anything and connect the multiplied result to the half3 Gloss input, the generated shader won't convert to half3 automatically. And Unity would report a float4 to half3 error

    3. The third one is just a feature request:
    Have you tried to use Mental Mill? There is a single feature that I love most about it is the Range Slider.
    it basically converges (un)bounded min, (un)bounded max, current value, step down, step up, and slider into a single UI. Its really elegant and compact! I don't know how difficult it would be to do something like that on the UI, but I am hoping the Range node can eventually turn into that. Its really easy to read and to modify. I don't know if anybody shares my passion to that design.. hehe.

    Heck, here is a shot of the slider UI. its on the right side for depth scale and wave speed


    And here is the quote from Mental Mill's document describing tis UI. I hope I won't get into trouble for the quote~

     
  27. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    Is that error an xbox 360 compile issue? Can you msg me your email?
     
  28. VelvetElvis

    VelvetElvis

    Joined:
    Nov 22, 2010
    Posts:
    8
    First off, this is an amazing tool. This tool has tiger blood running through it. My questions is, can you blur an image using one of the functions? I want to control the blurriness of my reflections with a slider or value, so some objects have sharp reflections like chrome and others have soft blurry reflections like leather. The slider would blur out the cubemap, so these are not real-time reflections. Right now the reflections are being added in on the diffuse slot and are controlled with a Fresnel falloff like the rim-shader.
     
  29. VelvetElvis

    VelvetElvis

    Joined:
    Nov 22, 2010
    Posts:
    8
    Never mind, I answered my own question after searching the early number of this thread. Makes sense that this would be expensive to render.
     
  30. Munku

    Munku

    Joined:
    Feb 27, 2011
    Posts:
    4
    Excellent tool! I was looking for something like that.

    However, I don't have a preview window/area at all! Any help?
     
  31. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    Unity free does not support preview. Best thing to do is set up something in the scene add your material too it then every time you want to check it click 'export'.
     
  32. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,467
    Yup...can't wait until you release ur new shader editor
     
  33. tkluysk

    tkluysk

    Joined:
    Jul 10, 2010
    Posts:
    10
    Anybody else got in trouble with their normals because of these two lines in the Strumpy Shader? :

    Code (csharp):
    1.  
    2.                 o.Normal = float3(0.0,0.0,1.0);
    3.  
    4.                 o.Normal = normalize(o.Normal);
    5.  
    6.  
    Is there any reason Strumpy does this?
     
  34. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    What issues are you seeing? The lighting needs to have the normal in a normalized state otherwise it gets all janky between forward and deferred.
     
  35. gfxguru

    gfxguru

    Joined:
    Jun 5, 2010
    Posts:
    107
    stramit...is the shaders are default SM 2.0??
    I made a glass texture and it didnt work int SM1 emulation in unity....

    But a glass i got from the forums(handcoded) was working with SM1.0 as well...
    How can this compatibility be achieved?
     
  36. tkluysk

    tkluysk

    Joined:
    Jul 10, 2010
    Posts:
    10
    The shading is very flat and specular highlights are washed out. I think the main culprit is the o.Normal = float3(0.0,0.0,1.0); statement, which (supposedly) sets all normals to the Z axis.
     
  37. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    Unity uses tangent space normals... Z is up in these cases. Can you take some screenshots showing the issues as you perceive them? What do you mean by 'specular washed out'? What are you doing in your graph? Need more info!
     
  38. tkluysk

    tkluysk

    Joined:
    Jul 10, 2010
    Posts:
    10
    EDIT: might not be a Strumpy issue - see next post
    ----

    On a standard stretched Unity sphere:

    LEFT
    Unity's Specular shader (Normal_Glossy), which I am trying to emulate as a base
    Specs handled well.

    RIGHT
    Simple Strumpy Specular shader (sgraph attached)
    As you can see, the specs are incorrect - or unexpected at least.
    Depending on the object, I get washed out, supersharp or discontinuous specs. Probably related to tangent space indeed, but it seems the Unity Specular shader is more tolerant.

    MIDDLE
    Just removed the two lines I mentioned from the shader generated by Strumpy:

    Code (csharp):
    1.  
    2. o.Normal = float3(0.0,0.0,1.0);
    3. o.Normal = normalize(o.Normal);
    4.  
    The spec is handled (what I would consider) reasonably again.




    Why the spec in the Unity Specular is so much brighter is another point of discussion. All 3 shaders have the same settings for Color, Spec and Shininess.
     

    Attached Files:

    Last edited: Mar 6, 2011
  39. tkluysk

    tkluysk

    Joined:
    Jul 10, 2010
    Posts:
    10
    Last edited: Mar 6, 2011
  40. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    I just spent a fair bit of time trying to reproduce this. One thing I noticed is that your shininess value in the shader has a minimum of 0.01, the default unity one has a value of 0.03, if you are just dragging the slider to the left this could cause some discrepancies.

    In these pictures the material with SSE is on the left (the material you attached, but with the min spec set to 0.03 to match the unity one), the material with the default unity bump/spec is on the right. They both behaved the same way with regards to specularity. In the SSE version I am renormalizing the normal still.

    I believe you are seeing an issue though I'm just trying to track down exactly what it is. I've pm'd you my email address can you package up the scene you made to demo that (include the SSE in that package as well). Its possible I have fixed that issue without realising while making Beta4.
     

    Attached Files:

  41. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    AhA! just tracked down what I think it might be. It only happens on forward rendering for me... if you have pro can you tell me if the issue goes away when you switch to deferred rendering?
     
  42. dongio

    dongio

    Joined:
    Sep 28, 2010
    Posts:
    16
    Hi, I'm having a problem with specularity on my mesh, I think is mesh problem it's made in maya, I'm getting some artifakts on some triangles my normals seams ok PS: don't pay atantion to a fliped faces, it's not an ishue.


     
  43. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    Hi, have you seen the last few posts in this thread? We have just been looking at specular issues. If you change the shader to the built in bumped specular does the issue go away? Or if you change the camera to be deferred does the issue go away?
     
  44. tkluysk

    tkluysk

    Joined:
    Jul 10, 2010
    Posts:
    10
    yes - seems to be solved in Deferred at first look!
     
  45. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    Can you msg me you email? Have a possible fix for forward you might like to try.
     
  46. dongio

    dongio

    Joined:
    Sep 28, 2010
    Posts:
    16
    thank you for fast answer
    Deferred doesn't fixes problem and it has same ardifacts with defoult bump/specular shader
     
  47. FogGobbler

    FogGobbler

    Joined:
    Mar 25, 2009
    Posts:
    147
    Could you perhaps post an example of how to use this Editor for a reflecting floor Shader? I've got nö idea of where to Start.

    Bye, oli
     
  48. Frank Oz

    Frank Oz

    Joined:
    Oct 13, 2010
    Posts:
    1,560
    So the past couple of days I've FINALLY been able to get into this properly, and having recently managed to learn a little about creating shaders, actually have some idea what I'm doing for once!

    So firstly, TOOOO much fun to play with! If someone ever makes a scripting solution like this for Unity, we're gonna be in trouble!

    Secondly, I've been trying out using Time to animate various things, within the shader editor details window, it animates correctly (as do the demo graphs). However there's no movement when the shader is used in an actual scene, either in the scene window or game window (when playing). Am I doing something wrong, or is this to be expected?

    Thirdly, I think I found a bug, which also doubles as a "well it's your own damn fault for not saving" lesson. Basically I was making a shader, nothing special. I was testing it out, running a quick setup etc. Eventually returned to the shader editor window (setup as a tab, if that makes a difference), and whoops, the whole graph had reset to how it appears after clicking new graph. Like I say, it wasn't an important shader (and the temp one remained untouched) and my fault for not saving. But thought I should mention it in case it's part of something else that might cause problems.



    Oh, and does anyone know how to successfully use the parallax node? I think the docs are outdated, and I did search on here, but it seems if you set the search to display posts instead of threads, you can't click directly to the post in question, just the beginning of the thread, so couldn't find anything about it.
     
  49. box01

    box01

    Joined:
    Apr 2, 2009
    Posts:
    62
  50. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    Hey Frank, I'm glad you are enjoying it!

    You need to Export the shader for time to be used properly (it will only work in the game view when the game is executing). The 'preview' shader is actually a special shader where we manually set the time each time the preview is rendered because the built in shader time stuff only works in a running game. That's why if you use just the 'default' updated shader you won't see movement.Use and exported shader instead.

    Yea, this happens occasionally. Unity windowing is a fickle beast and sometimes the window will be destroyed and recreated. I have caught many of the situations but there is one elusive one I have yet to track down. Most of the time this should work fine but there is definitely a bug in there somewhere still.

    I'll have a look this evening, but the last I checked it was working as intended, the doc might be out of date though.