Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. 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,183

    It's just multiplying the given vector by the view transform (I believe). We don't currently expose the view matrix in SSE I'll add it to the todo.
     
  2. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,183
    This is a post process. Best to look into the image effect examples that are included in the unity pro shader packages.
     
  3. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,183
    The best way to do this is to use the 'time' node. A simple example of a light fading on and off would look like this:
    $Screen shot 2011-06-14 at 8.33.03 PM.png

    You could make what you are turning on and off a texture sample or whatever you wanted!
     
  4. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,183
    Can you pm me this in a simple scene? I can't see exactly whats wrong, I have some ideas but would need to play with the graph to figure it out.
     
  5. bb0x

    bb0x

    Joined:
    May 16, 2011
    Posts:
    70
    Thanks.

    What do the Splat and Saturate nodes do exactly?
    I'm guessing Splat makes the Sine go from 1 to 0 to 1 instead of -1 to 0 to 1.
    Not sure about Saturate.

    Also if I wanted to use 2 colours instead of just 1 flickering colour. I'm guessing id use a Lerp and put the output of saturate into the 3rd slot of Lerp right?

    And for swaying textures like water, is it the same setup, but instead of connecting to multiply I'd connect it to UVpan?

    Some explanation on UV manipulation would be awesome btw. I know UDK has special nodes and what not for this.
     
  6. wallen

    wallen

    Joined:
    Jul 29, 2010
    Posts:
    14
    GREAT job stramit.

    And how to make "Tex2D0=Tex2D0*((IN.uv_MainTexture.xyxy).x<_Range)" with nodes?




    Haha...I have solved ....
     
    Last edited: Jun 17, 2011
  7. Mingo

    Mingo

    Joined:
    Nov 14, 2010
    Posts:
    39
    Loving this shader editor, couldn't live without it.

    I have a question though: has anybody tried making a replacement shader for the Terrain with this? I need some help setting up and understanding the inputs that the Terrain shader uses. I can get my replacement shader to display the "base map" texture that Unity uses for distant terrain by feeding a texture input called _MainTex into the diffuse, so the shader itself is working correctly on the terrain, and I think I've got the vertex shader calculating the tangents that the system needs, but I can't figure out how to access the splatmat/control texture channels.

    Has anybody tried this? I would really appreciate some help here. This is the source for the built-in shader I'm trying to replicate with nodes:

    Code (csharp):
    1.  
    2. Shader "Hidden/TerrainEngine/Splatmap/Lightmap-FirstPass" {
    3. Properties {
    4.     _Control ("Control (RGBA)", 2D) = "red" {}
    5.     _Splat3 ("Layer 3 (A)", 2D) = "white" {}
    6.     _Splat2 ("Layer 2 (B)", 2D) = "white" {}
    7.     _Splat1 ("Layer 1 (G)", 2D) = "white" {}
    8.     _Splat0 ("Layer 0 (R)", 2D) = "white" {}
    9.     // used in fallback on old cards
    10.     _MainTex ("BaseMap (RGB)", 2D) = "white" {}
    11.     _Color ("Main Color", Color) = (1,1,1,1)
    12. }
    13.    
    14. SubShader {
    15.     Tags {
    16.         "SplatCount" = "4"
    17.         "Queue" = "Geometry-100"
    18.         "RenderType" = "Opaque"
    19.     }
    20. CGPROGRAM
    21. #pragma surface surf Lambert
    22. struct Input {
    23.     float2 uv_Control : TEXCOORD0;
    24.     float2 uv_Splat0 : TEXCOORD1;
    25.     float2 uv_Splat1 : TEXCOORD2;
    26.     float2 uv_Splat2 : TEXCOORD3;
    27.     float2 uv_Splat3 : TEXCOORD4;
    28. };
    29.  
    30. sampler2D _Control;
    31. sampler2D _Splat0,_Splat1,_Splat2,_Splat3;
    32.  
    33. void surf (Input IN, inout SurfaceOutput o) {
    34.     half4 splat_control = tex2D (_Control, IN.uv_Control);
    35.     half3 col;
    36.     col  = splat_control.r * tex2D (_Splat0, IN.uv_Splat0).rgb;
    37.     col += splat_control.g * tex2D (_Splat1, IN.uv_Splat1).rgb;
    38.     col += splat_control.b * tex2D (_Splat2, IN.uv_Splat2).rgb;
    39.     col += splat_control.a * tex2D (_Splat3, IN.uv_Splat3).rgb;
    40.     o.Albedo = col;
    41.     o.Alpha = 0.0;
    42. }
    43. ENDCG  
    44. }
    45.  
    46. // Fallback to Diffuse
    47. Fallback "Diffuse"
    48. }
    49.  
    I have an input called _Control, but plugging this into the diffuse for testing gives me nothing.
     
    Last edited: Jun 16, 2011
  8. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,436
    Hey stramit...quick question for you... is there a way I could replicate the built in shaders used for Foliage? I am using it now and I don't like how it looks compared to my models...
     
  9. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,002
    Hope your recovery is going fine and that you'll be healthier than ever. Take care :)
     
  10. OllyNicholson

    OllyNicholson

    Unity Technologies

    Joined:
    Jun 17, 2011
    Posts:
    142
    Hey guys - I exported a bunch of shaders and saved shader graphs on a previous version of Strumpy (around 4 months ago) and now when loading the shaders they are pink even if I rebuild them. I've narrowed down the problem to connecting to the world normal into my world reflection for emissive reflections. Once connected I get the following error:

    ! Shader error in 'ShaderEditor/EditorShaderCache':program'vert_surf',output semantic attribute "TEXCOORD" has too big of a numeric index (8) at line 150

    Any Ideas? I really want to get the collection of shaders I created working again...

    Olly
     
  11. Texel

    Texel

    Joined:
    Dec 25, 2009
    Posts:
    61
    Olly: This issue is related to the target shader model and is really a variant of the "Too many texture interpolators" issue, should be solvable by switching your shader model from two (or default) to three, however it does limit the range of hardware that the shader will run on. Ideally the solution would be to reduce the number of texture UV's your using (Say, with a simple sampler node, rather than a full sampler) or reducing the number of texture UV inputs feeding.

    Neptune_Imaging and Mingo: I suggest you download the Unity Built-in Shaders and match your input setups- Terrain in particular may be trickier, especially in the shader editor, since it doesn't appear to use the material system, bypassing properties, something we don't currently support. (That is, we don't have support for using non-property variables beyond the ones we have preconfigured as nodes)

    bb0x: Splat takes a single channel from the input, and copies it across all four channels of the input. Saturate clamps within the [0,1] range. I have fairly in depth documentation in the mouse-over text you can find in the node listing.
     
  12. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,436
     
  13. Vert

    Vert

    Joined:
    Mar 23, 2010
    Posts:
    1,099
    An outline for every 'backfacing' edge that does not have the gap error that the default toon shader has. I understand how the Unity shader works, I just can't seem to get the backfacing polygons to adjust properly to get rid of the nasty gaps that can appear.

    I found your tutorial files and will take a look. I see that SSE only does surface shading and really does not allow for toon shading? Perhaps I will have to dive into the shader language a bit then to solve this.
     
  14. bb0x

    bb0x

    Joined:
    May 16, 2011
    Posts:
    70
    Thanks Texel for the explanation. I most of the time do a mouseover of the nodes that are available. Not being a programmer i dont understand half of the stuff. The saturate node for example i'd expect it to control the amount of colour. (like in photoshop)

    Anyway Stramit, I build the exact same setup as in that image you posted. It doesnt work for me though. it just renders the material black.

    What's going on?

    edit--

    Actually never mind.. I had to hit the play button to see the effects (unity free here).
    Also how do i speed up or slow down the sinwave? I tried multiplying the sinTime node with a number but that only seems to change the intensity of the colour not the speed.
     
    Last edited: Jun 19, 2011
  15. Loa

    Loa

    Joined:
    Jan 27, 2011
    Posts:
    5
    Preview Problem

    Hello, I restartedtouse the Sahder Editorbut againI'm block cause the Peview windows does not open.

    Is there please a shortcut to have it ?

    I'm running under Windows 7 64Bits.

    Thanks for the Editor and yourhelp,
    Loa
     
  16. Texel

    Texel

    Joined:
    Dec 25, 2009
    Posts:
    61
    Firstly you need to be using Unity Pro to be able to display the preview- That said, if you for some reason close the window, there should be a preview button on the lower right of the editor (This will not show up if you are not using Unity Pro)
     
  17. Loa

    Loa

    Joined:
    Jan 27, 2011
    Posts:
    5
    Texel,

    Thank you, I missed the point about the Unity Pro point.

    Indeed my test license has expired.
    Explaining why I can't see the Preview.

    Best Regards,
    Loa
     
  18. Carwash

    Carwash

    Joined:
    Nov 12, 2009
    Posts:
    95
    Howdy,

    I'm trying to make a graph that will cycle through UV offsets to produce a shader that basically does the same thing the particle animator does. i.e, you've got a grid of images on a texture, and using the offsets you can create an animated texture. I know you can do this in scripting by just setting the offset there, but i want a shader that does it. it feels like there must be a way using SSE (the UVPan thing is nearly there after all!) anyone care to point me in the right direction? take the UV of a 2dsampler and pass it through.... what? Lerp between some offset floats? help!
     
  19. joeythepoey

    joeythepoey

    Joined:
    Jun 18, 2010
    Posts:
    12
    First off Strumpy and Texel, thank you so much for your hard work and general awesomeness; it is an amazing tool that brings custom shader creation so much closer, even for n00bs like me :)

    Speaking of n00bs; are there any more tutorials or demonstration graphs to learn how to work with this? I've managed to create a half lambert shader using the gradient example, but some admittedly I only know what I'm doing half of the time.
    Being able to see for example some of the standard unity shaders (bumped, parallax, detail textures, with light mapping etc.) as graphs would help people like myself enormously with learning this amazing tool and shaders in general.

    Is there a repository or are there more tutorials? I googled my *ss off but all I could find was a wiki that someone started (deserted now, it seems, with only 3 examples) and 1 or 2 youtube videos showing vertex animation and the basic layout of the editor?

    Anyway, thanks again for your hard work and kudos for pulling it off!!

    Joey
     
  20. Nose

    Nose

    Joined:
    Jun 21, 2011
    Posts:
    36
    please help make this a
     
  21. warby

    warby

    Joined:
    Mar 23, 2009
    Posts:
    162
    isnt that just a matter of a simple cubemap in emmisive ?
     
  22. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    663
    Yeah, I agree, it's more a matter of texturing to get this look. A nice cubemap with a spec map. Maybe a Reflective/Specular shader?
     
  23. bb0x

    bb0x

    Joined:
    May 16, 2011
    Posts:
    70
    Use a cubemap controlled by a fresnel in emisive. Should give you the reflections only on the edges of the thing.

    Do the same for diffuse. Use a lerp with a blue and a black color connected to slot 1 and 2 controlled by a fresnel node as a mask. Should give you that blue color with black outline kinda look.

    And for the glitter effect, simply use a noise texture in Specular. And control it with a range node in gloss
     
  24. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,436
    You just gave me an idea to fake the look of metal :) since I am using Unity standard :)
     
  25. noradninja

    noradninja

    Joined:
    Nov 12, 2007
    Posts:
    420
    For those of you that ask for an outline shader, my gift to you:

    $Frenel_Based_Outline.png

    And, a modified version, applied:

    $Applied.png

    It does have it's own limitations and problems, just like the included Toon shader does; You just have to decide which appearance fits your game more and which issues you will be happier settling with.
     
  26. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,436
    Nice man... I was thinking of looking to make something like this... :) and the pic, reminds me of Okami a bit :)
     
  27. noradninja

    noradninja

    Joined:
    Nov 12, 2007
    Posts:
    420
    I've had it for a month now (the basis for the line shader), just wanted to finish our custom additions before I handed this out. Will post pics when we are done.

    Thanks for the compliment; altho I had not heard of the game until after I started working on this game 6 months ago (it came out while i was at Uni), it's visuals are beautiful; we just want to take them to the next level. NPR effects advance at a weird glacial pace with sporadic bursts of mass advancement.
     
  28. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,436
    i agree man... my models look like they could be in Elder Scrolls: Skyrim :)...and i am still working on the shaders :)
     
  29. rockysam888

    rockysam888

    Joined:
    Jul 28, 2009
    Posts:
    650
    (bookmarked)
     
  30. Alhaziel

    Alhaziel

    Joined:
    Jun 15, 2011
    Posts:
    16
    hey, I am interested in the snow shader, where can I find it?
     
  31. ScienceFiction

    ScienceFiction

    Joined:
    May 28, 2008
    Posts:
    393
    from what i can tell alhaziel, it was never released. I'm working on one at the moment, should be at a release stage in the next 2 weeks. It will have the sparkle, as well as Y axis based world-space accumulation. I also hope to make it work with the terrain engine, and it will accumulate into mounds, which I'm trying to use mesh deformation to construct, which will also be used to make paths through the mounds. Here is a quick demo of where I am at right now:
    http://dl.dropbox.com/u/20454603/Snow.html

    Edit: You must wait at least 1 minute to see the snow start to pile up.
     
    Last edited: Jun 24, 2011
  32. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,436
    Hey everyone, I have a problem setting up my water shader... I am trying to do three things:

    1) I want to use a Float node, to scale up the normal map like in the simple water example in unity

    and

    2) I want to animate the water similarly to the Daytime Simple Water...

    3) and set it up so that the transparency is lessened the farther it is (Using Unity Standard)

    Does anyone have any tips? Here is a screen shot of my issue :( I just love the clear water...

    Thank you in advanced
     

    Attached Files:

  33. ehsangamer

    ehsangamer

    Joined:
    Apr 15, 2011
    Posts:
    34
    What is the difference between the shaders that support lightmapping and that does not ?

    I mean in making them with SSE . Should I do something special in my nodes ?
     
  34. Nose

    Nose

    Joined:
    Jun 21, 2011
    Posts:
    36
    Car paint shader test))

    this is good?)
     
  35. melonman

    melonman

    Joined:
    Oct 25, 2009
    Posts:
    19
    Hi Stamrit I been well busy so apologies for the late reply and really appreciate the help so thanks man.

    Here is the transparency shader with extras

    add any maps you like and test it out.

    The two main errors as I said in the last post are the wierd effect you get on the top and bottom of the sphere which im pretty sure might be down to the sphere not being uv mapped and that once an alpha is added to this material you somehow see through it?

    Don't have a clue what it could be.

    Thanks again.
     

    Attached Files:

  36. bb0x

    bb0x

    Joined:
    May 16, 2011
    Posts:
    70
    Hey Naptune,

    I'm working on a water shader myself right now. Not really familiar with the shaders supplied with Unity.
    Got a few questions myself, but I'll answer yours first.
    First of all, you dont need to colour up your gloss, It only uses black and white values to sharpen/soften your specular highlight.

    For animated water textures, use a CosTime (for swaying textures) or a Time(for panning, not sure about this one tbh) connect the CosTime node to an Add operation and for the other slot connect the UV output of your Sampler2d. The output of Add should connect with the UV input of your Tex2dNormal. You should have a swaying normal map right now. This is just the basics, experiment with it.

    Also just for fun try adding 2 normal maps and give them seperate time/speeds.


    About the transperancy thing.. I think thats limited to Pro, as you would want the z depth info which I think is a fullscreen thingy..

    Now my question:
    I made the following setup for fake reflection in my shader.
    $reflection.png
    I copy and pasted it from another scenegraph where it work just fine. But when using it in another sceengraph it make the shader pink.. it breaks it. What am I doing wrong here?
     
  37. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,436
    hey, it works... now I just gotta control with a float :) And i've had that issue too where nodes i copy stop working all of a sudden...
     
  38. Texel

    Texel

    Joined:
    Dec 25, 2009
    Posts:
    61
    bb0x, WorldReflection with a normal input requires the shader to include the "INTERNAL_DATA" block to perform additional transformations in the fragment shader. Essentially, by using the WorldReflection (Or WorldNormal with normal input for that matter) requires a fair bit of your vertex interpolators, and those shaders are going to be hard to fit within ShaderModel2. In order to compile them happily, set the Shader Target to 3.0, and it shouldn't have any more issues.
     
  39. bb0x

    bb0x

    Joined:
    May 16, 2011
    Posts:
    70
    Hey Texel,

    Thanks.. Thing is.. its already set to SM3... its basically the same shader as the other shader I created where it works just fine.. for some reason it wont work properly in this one..
     
  40. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,436
    Hey Texel, I am glad u stopped in... i did the suggestion that bb0x told me and it looks awesome but it is not the effect I am looking to do... if you open up the simple water, that is what I am trying to emulate...
     
  41. G-Rom84

    G-Rom84

    Joined:
    Feb 22, 2011
    Posts:
    7
    For my taste it would be nice to have a few minor pretty standart improvements for the preview window:

    - autoupdate preview checkbox, when turned on it will update the result during adding and connecting new nodes on the fly, without need for manualy push the update button.
    - also it would be nice to have the ability in preview window to zoom/dolly the model to closely see the results, without need for resizing the window itself because the default window size is ok in my oppinion.
    - and the last i dont`t know why i allways trying to dock my preview window at the bottom of the nodes list it seems for me the one right spot for where the preview window should be. just dont like floating windows (. would be great if it could be snapped to the columns of the interface.

    And again it`s all the matter of personal taste and habbits, and of cource i may be wrong.
     
    Last edited: Jun 29, 2011
  42. smiljan66

    smiljan66

    Joined:
    Jun 9, 2010
    Posts:
    610
    What about the video tutorial for starters in strumphy? or this has been forgoten? if you do video tutorials you iwll have more followers just a recomendation .
     
  43. G-Rom84

    G-Rom84

    Joined:
    Feb 22, 2011
    Posts:
    7
    yep the more info about how to use editor would be great with some directions on how to make such things like translucent leaves, metals, some light effects and maybe some kind of fake sss for wax,skin, plastic mats.
     
  44. bb0x

    bb0x

    Joined:
    May 16, 2011
    Posts:
    70
    I tried allot of things.. Still not succesfull getting fake reflection with the setup in my previous post.

    Is Worldreflection a Pro only thing or something?

    Also Neptune instead of using a cosTime node simply use a Time node. It will just pan your textures. Simply have 2 normal maps panning in the opposite directions and add the 2. Should give you that waving effect that the Basic water shader has.
     
    Last edited: Jun 30, 2011
  45. sawfish

    sawfish

    Joined:
    Feb 12, 2011
    Posts:
    314
    http://unity3d.com/support/documentation/ScriptReference/Camera.RenderToCubemap.html

    Rendering the camera to cubemap is a Pro only feature...
     
  46. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,436
    That is kick ass... thanks a lot man...
     
  47. Darkmonk

    Darkmonk

    Joined:
    Nov 3, 2010
    Posts:
    50
    Hi guys,
    Quick question about a Vertex lit shader.

    Im trying to make a simple shader that works in the Vertex lit Rendering path but my shader is always black, When i change my camera to be forward or deffered lighting the shader looks fine but as soon as its set to Vertex lit it stops working and goes black, not even the alpha is visable.
    is there anything specific that i need to flag to get this to work ? or does it need something setup in the custom lighting section since it will not be taking any lightin information from the scene ?

    Thanks
     
  48. ehsangamer

    ehsangamer

    Joined:
    Apr 15, 2011
    Posts:
    34
    What is the difference between the shaders that support lightmapping and that does not ?

    I mean in making them with SSE . Should I do something special in my nodes ?
     
  49. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,785
    Um...stramit...can i request _CameraDepthTexture node?. So we can create custom depth texture.
    And an option to disable preview window ( i prefer to work directly with in game view :p)
     
    Last edited: Jul 2, 2011
  50. bb0x

    bb0x

    Joined:
    May 16, 2011
    Posts:
    70