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. Frank Oz

    Frank Oz

    Joined:
    Oct 13, 2010
    Posts:
    1,560
    Oooh Oooh Oooh! Details! :D *jumps around excitedly*
     
  2. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,221
    Very small release, mostly just small bug fixes. Nothing exciting like the Beta3.x -> 4 jump.
     
  3. chkkll

    chkkll

    Joined:
    Jul 20, 2010
    Posts:
    40
    oh g.. sorry for the annoyment lol.. thanks a billion u r the man..
     
  4. Frank Oz

    Frank Oz

    Joined:
    Oct 13, 2010
    Posts:
    1,560
    Every update is exciting! Except the one where it stops being free, that will make kittens cry.

     
  5. 2dfxman1

    2dfxman1

    Joined:
    Oct 6, 2010
    Posts:
    1,065
    Why would this become paid? We already got shaderfusion. We don't need 2 paid plugins that do the same thing. Really.
     
  6. Mayamuppen

    Mayamuppen

    Joined:
    Mar 24, 2011
    Posts:
    2
    Hi Everyone

    First, big thanks for the effort you guys put in to develop this tool for Unity. As an artists, tools are extremely important if you don't know your way around code.

    I've tested the editor and my ambition was to translate the TF2 look a like shader from this UDK guide ( http://www.moddb.com/games/unreal-tournament-3/tutorials/tf2-shading-in-ut3 ). I've managed to get the base color the way I want but the rim light and specular eludes me. From the guide it uses a node called Reflection Vector, is there at similar one in SSE?

    Another question, when previewing the shader it looks nice but when applying it to a object in my scene it blows out. I figure it has to do with my light setup because in a empty scene it looks good.

    Right now I've connected everything to Lightning out master, will that override all incoming lights in the scene? Then how come the preview window works where here are two point lights present?

    $shaderTest.png
    In preview
    $brightLight.png
    In scene

    View attachment $TF2_shader.zip The Shader as of now


    I hope someone can help me with this, at least with the light over exposure.

    Thanks in advance
    /Eric
     
  7. yahodahan

    yahodahan

    Joined:
    Apr 26, 2009
    Posts:
    1,380
    Such a great addition to Unity, so sad that it's apparently WAY over my head. I used the Unreal node-based shader editor, loved it, and figured this would work for me...no such luck. I must be getting old already :(
     
  8. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,221
    So, when you are doing blending in a deferred (or any single pass) system you are trying to 'mimic' the builtin blend features that you normally have with multipass rendering. In a normal 3d engine everything that is rendered transparently uses blending, the most common is probably Alpha blending.

    How does blending work
    Blending uses the following equation:
    Code (csharp):
    1.  
    2. Source BlendMode * The texel you are writing to the screen + Destination BlendMode * The last texel that was rendered at this location
    3.  
    So an example of normal rendering (just rendering a normal color), can be written as:
    Code (csharp):
    1.  
    2. One * Current Texel + Zero * Destination Texel
    3.  
    This means you are taking only the current texels color, and ignoring (writing over) what already exists!

    The blend modes that exist in SSE (from the unity docs) are:
    Code (csharp):
    1.  
    2. One             The value of one - use this to let either the source or the destination color come through fully.
    3. Zero                The value zero - use this to remove either the source or the destination values.
    4. SrcColor            The value of this stage is multiplied by the source color value.
    5. SrcAlpha            The value of this stage is multiplied by the source alpha value.
    6. DstColor            The value of this stage is multiplied by frame buffer source color value.
    7. DstAlpha            The value of this stage is multiplied by frame buffer source alpha value.
    8. OneMinusSrcColor    The value of this stage is multiplied by (1 - source color).
    9. OneMinusSrcAlpha    The value of this stage is multiplied by (1 - source alpha).
    10. OneMinusDstColor    The value of this stage is multiplied by (1 - destination color).
    11. OneMinusDstAlpha    The value of this stage is multiplied by (1 - destination alpha).
    12.  
    This will give you an overview of the possibilities. There are a great many combinations you can use, and each will render something different. The trick is to remember that there are two pixels, the source pixel and the destination pixel, and you can blend them however you want. It's also important to note that you can do blend modes like (even though I don't know how I would use this):
    Code (csharp):
    1.  
    2. OneMinusDstAlpha * CurrentTexel + DstAlpha * DestinationTexel
    3.  
    This means you can do a lot of crazy stuff!

    How do I simulate this in a single pass
    In a single pass renderer you would normally use blending to simulate a multipass effect, but in a single pass. This means that in your shader you need to evaluate both texel values (both current texel and destination texel).

    What this means is that in an overlay effect, the destination texel will be the 'base', and the current texel will be the overlay.

    A good example of how this can be done is by looking at an alpha blending which uses the equation:
    Code (csharp):
    1.  
    2. SrcAlpha * current texel + OneMinusSrcAlpha * destination texel
    3.  
    What this means is that the alpha value of the overlay determines just how much of the overlay, and the underlay are exposed.

    To do this manually we can do the following (click to make bigger):


    As you can see we sample two textures (main tex and alpha blend tex). To determine just how much of the src texture we should display we multiply it by it's alpha (srcalpha), and to determine just how much of the main texture we should display we multiply it by one minus the alpha of the first texture.

    Another simple blend mode is Additive blending, this equates to:
    Code (csharp):
    1.  
    2. One * current texel + One * destination texel
    3.  
    This is a simpler mode where you are just adding both texels together.


    By knowing what the blend modes are it's quite simple to manually build up overlays ect within a single deferred shader. As a note, at some stage in the future we will be developing some nodes to make this easier, but until that time, you should be able to put together your own manual blending.


    Notice how the additive blending is brighter, this is due adding two colors together. The alpha blended is not as bright due to the maximum value output being tempered by the alpha channel of the blend texture
     
  9. bigSky

    bigSky

    Joined:
    Jan 31, 2011
    Posts:
    114
    Thanks stramit for such a great tool.

    Opens up a whole big world to the artists in the house.

    Here's what I knocked up.
     

    Attached Files:

  10. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    @BigSky - Why not post it in the repository in the Wiki?
     
  11. bigSky

    bigSky

    Joined:
    Jan 31, 2011
    Posts:
    114
  12. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,458
    Wow, this is pretty damn awesome... so i can do this for all of the textures I will be using like my diffuse/normal/spec, etc... could I also use a float value to determine the strength of the blend?
     
  13. GlitchInTheMatrix

    GlitchInTheMatrix

    Joined:
    Apr 12, 2010
    Posts:
    285
    Hi Stramit, Strumpy Shader Editor looks amazing!

    Im 3d modeler and make shading in maya and started with unity3D like 1 year ago. This tool make easy make shadings, you are making a great job! you rock!

    But it need more documentation. Im trying to make a shading with Vertex Color, Diffuse, Normal Map, Specular and Glossary but i don't understand how make work all together.

    I made a single shading Diffuse and Normal map but i don't understand how add the vertex colors that i have in my actual model.

    thanks for advance
     
    Last edited: Mar 30, 2011
  14. Darcy P World

    Darcy P World

    Joined:
    Dec 3, 2010
    Posts:
    15
    is this for pro only? I can't figure out how to use it?
     
  15. Frank Oz

    Frank Oz

    Joined:
    Oct 13, 2010
    Posts:
    1,560
    Works fine in Unity Free, except you don't get the Preview (but place an object in the scene to use the temp SSE shader for it's material and you'll get the same updating when you preview the results.
     
  16. 2dfxman1

    2dfxman1

    Joined:
    Oct 6, 2010
    Posts:
    1,065
    Rimlight is called fresnel.
     
  17. zeldafan_mimo

    zeldafan_mimo

    Joined:
    Jan 27, 2010
    Posts:
    23
    Ummm I am jsut new to this.. Uhhh Beta 4.0a , I cnat seem to see the separate Preview WIndow like in Your Video ... any problem i am experienceing ?
     
  18. Frank Oz

    Frank Oz

    Joined:
    Oct 13, 2010
    Posts:
    1,560
    You using the Free or Pro version?
     
  19. 2dfxman1

    2dfxman1

    Joined:
    Oct 6, 2010
    Posts:
    1,065
    So will there be a zoom function for graphs?
     
  20. Bruell

    Bruell

    Joined:
    Jan 12, 2011
    Posts:
    13
    So do I need to donate first then download? I don't seem to be able to download this?????
     
  21. Frank Oz

    Frank Oz

    Joined:
    Oct 13, 2010
    Posts:
    1,560
    No donation required to download it, but he certainly deserves it due to it's awesomeness.

    Edit: Are you trying to download it via the Asset Store? It requires 3.3 to download from there (but works fine in 3.2).
     
  22. Bruell

    Bruell

    Joined:
    Jan 12, 2011
    Posts:
    13
    Yes, I am trying to download it through the asset store. I Can't find the download option. I'm on Unity 3.2 Pro and am hesitant to update due to past issues with updates.

    If this tool turns out to be helpful creating a reflective architectural glass shader I will be very generous in my donation. :)
     
  23. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    @Bruell - You can always install Unity 3.3 in a separate folder and just use it for the Asset Store. That's what I did as I'm also using 3.2 until 3.4 is released.
     
  24. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,458
    Hey Stramit,

    Well, after trying out the manual blending, it worked as planned...but what if I wanted to do this for three additional textures? I am using Lerp nodes to set up the layers and I only see one of textures i set...and the 3 additional textures all have alphas...

    But I only have one showing up... how could i fix it so that they will all blend together...like I want all of the damage to show up at once if i like... here is a pic of the graph...


    thanks dude

    Edit: I had to use multiply nodes to fix it...
     

    Attached Files:

    Last edited: Mar 30, 2011
  25. Frank Oz

    Frank Oz

    Joined:
    Oct 13, 2010
    Posts:
    1,560
    You'll be donating quite a bit then, lol. One of the first things I did with it was a fancy glass material similar to what I'd had in 2.6.1 (but broke in v3.x), and even with very little knowledge of shaders at the time, I managed to do something nice. Just wish I remembered which project folder I'd left it in, and what name I'd given it, lol.
     
  26. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    Now if you had posted it on the Wiki, you'd know where to find it! (hint, hint). ;)
     
  27. Frank Oz

    Frank Oz

    Joined:
    Oct 13, 2010
    Posts:
    1,560
    Hahaha, touché. I will once I start putting together some useful shaders, start uploading them with examples etc. Over the course of my project I'm certainly needing lots of custom ones, so I can see those being uploaded. Dunno if they'll be useful to anyone else, but hey, never know. :)
     
  28. Bruell

    Bruell

    Joined:
    Jan 12, 2011
    Posts:
    13
    That would suck big time having to buy two pro licences just to access the store. :cool:

    I'll just write a complaint to the support. :)

    Edit: Donation suspended until download issue resolved LOL
     
    Last edited: Mar 30, 2011
  29. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    No need for a second license. You can install whatever versions of Unity as you need on the same computer, no problem. I've got versions 2.6 through 3.3 on the same machine, no problem.
     
  30. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,458
    Hey Stramit...i think i have run into a problem with my shader, when I try to add the blending to it... when I go to export the shader, the model turns pink and I get this error:

    Shader error in 'NeptuneImaging/NICharacerShaderClip': Program 'vert_surf', output semantic attribute "TEXCOORD" has too big of a numeric index (8) at line 186

    What does this mean?

    Thanks dude
     
  31. Bruell

    Bruell

    Joined:
    Jan 12, 2011
    Posts:
    13
    So It is a simple straight forward process to get the downloaded assets from 3.3 to 3.2 version? Like copy from folder xxx to folder xxx ?
    Right?
     
  32. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    I've been opening the same project folder with either 3.2 or 3.3 and haven't run into any issues (yet). The safest practice, though, would be to keep 2 copies of the project in separate folders, which is what I normally do.

    Just remember, either rename the existing Unity installation directory and / or give the new Unity installation directory a different name. Otherwise Unity will install 3.3 on top of 3.2.
     
  33. HarvesteR

    HarvesteR

    Joined:
    May 22, 2009
    Posts:
    531
    Hi again,

    I've got a question...
    I'm trying to modify the Triplanar mapping example so that it will work in local space, rather than world space... This is so the object's top side is always the same, regardless of orientation...

    There is no such thing as a LocalNormal input node AFAIK, so I'm trying to somehow rotate the world normal vector...

    I've tried multiplying the worldNormal by the World2Object matrix, using the VxM node, and it did work, to an extent...
    While the side and top textures now do get applied to the local top and sides, there is a weird distortion on the textures that varies accorsing to camera orientation :p

    If the camera has zero pitch (i.e. looking straight forward), the textures look alright, but if I look down, the textures start to stretch vertically (in relation to the camera), until only a mass of multicolored lines remains...

    I'm probably missing something very basic here... but sadly, my knowledge of shader programming is, well, the less said about it the better...

    I'm still using SSE 3.3... I haven't had a chance to upgrade to Unity 3.3, so I can't go for the new version... although I wonder how much difference that would make.

    So, anyone have a clue as to what might be going on here? The only modification I did was the matrix thing to the normal input... all else is still the same as the original example.

    Thanks in advance

    Cheers
     
  34. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,458
    Hey Stramit, I've been playing with the manual blending :) (love it) and now I notice my graph is getting rather huge. I had this idea from using Softimage ICE where i can select many nodes and compact them into one, and select that compact node, which will open up to the nodes that belong to that node... such as:

    You can have 1 Compound Node called "Diffuse", and if u double click on it, you can add more nodes as normal within that node (like a crapload of nodes that create the manual blending)...and when you go back to the main graph, everything is still clean...

    just an idea...this editor is the S*** :)...
     
  35. HarvesteR

    HarvesteR

    Joined:
    May 22, 2009
    Posts:
    531
    Oohh that's a good idea!!! Collapsing a collection of nodes into a 'component' node.

    Much like collapsing code on an IDE.

    Feature request? ;)

    Cheers
     
  36. 2dfxman1

    2dfxman1

    Joined:
    Oct 6, 2010
    Posts:
    1,065
    I have a question about the alpha glow example. If you use alpha slot for glow, then how can I use transparency?
    For example if I need an 8bit transparency? Clip only offers 2 color trans unlike alpha.
     
  37. morris

    morris

    Joined:
    Mar 2, 2011
    Posts:
    7
    Hi stramit,

    here is the broken graph I mentioned. Modifying the UV with a UV pan on the top normal map works. Adding a UV pan on the bottom one results in a broken pink material. Curious to know what the problem was so let me know!

    View attachment $TwoNormalsBlendEnvMap.zip
     
    Last edited: Mar 30, 2011
  38. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,458
    yup...the perfect feature...

    And I forgot how to disconnect nodes lol
     
    Last edited: Mar 30, 2011
  39. Frank Oz

    Frank Oz

    Joined:
    Oct 13, 2010
    Posts:
    1,560
    Right click on the spline line thingy.
     
  40. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,458
    Sweet man, thanks.
     
  41. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,221
    At some stage there will be, I can't say when.
     
  42. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,221
    Hey Bruell, there is a link to the download in the thread here (you won't need asset store):
    http://forum.unity3d.com/threads/56...e-Improvements?p=522958&viewfull=1#post522958

    Beta 4 should work properly on Unity 3.2+
     
  43. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,221
    It means you are are probably using too many UV's now (You can only pass a certain amount of data between the vertex shader and the pixel shader each explicit (sampler UV) that you use is one of these. To fix this issue you will need to use MeshUV's instead of explicit UV's. Just remove all the UV ouptuts from any samplers and replace them with a mesh UV node. Unless you are modifying scaling / tiling in unity material editor this will be okay.
     
  44. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,458
    Hey Stramit, thanks for your fast reply... I really do love how the blending works...still figuring how to blend three textures... i've had to use a Lerp node to blend all of them together... but still running into issues like the other textures are not showing up all at the same time...

    EDIT: I just added the Mesh UV node to the Tex2d UV input and my model turned pink...
     
    Last edited: Mar 31, 2011
  45. GlitchInTheMatrix

    GlitchInTheMatrix

    Joined:
    Apr 12, 2010
    Posts:
    285
    How i can add vertex color to my actual shading? im using diffuse, normal map and specular maps. thanks
     
  46. Frank Oz

    Frank Oz

    Joined:
    Oct 13, 2010
    Posts:
    1,560
    Make sure you're setting it to SM3.0, just incase.
     
  47. Frank Oz

    Frank Oz

    Joined:
    Oct 13, 2010
    Posts:
    1,560
    Multiply/Add or Divide Vertex Color with the Diffuse Color and/or Texture.
     
  48. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,221
    It's frustrating and I agree. In the pipeline you have to couple alpha and glow. This is a unity limitation :(
     
  49. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,221
    Ill have a look at this tonight. Thanks for uploading the graph.
     
  50. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,221
    Email me the graph and I'll see whats up.