Search Unity

  1. Going to #UniteBerlin? Bring a buddy & get 25% off the 2nd ticket! More info here.
    Dismiss Notice
  2. Famed game designer and creator of The Sims, SimCIty, and Spore is looking for a 3D artist to join their team. Join the challenge.
    Dismiss Notice
  3. Unity 2017.4 has arrived! Read about it here.
    Dismiss Notice
  4. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  5. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  6. We've opened a new World Building sub-forum to faciltate all your world building discussions! Drop in and ask any ProBuilder, ProGrids, or PolyBrush questions.
    Dismiss Notice
  7. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Strumpy Shader Editor [Now Open Source]

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

  1. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,005
    Hi therobear,

    Unity free does not support render textures and drawmesh, some of the functionality required for the preview window. I'm going to try some workarounds in the next few weeks now that unity free has been released. I hope to have some form of preview for free users, even if it's not as good as the pro version.
     
  2. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,005
    Thanks :D

    Easily doable

    This is technically doable, but I'm not sure if it will enhance the user experience or not, I'll have a chat with Texel and we will see what is up.

    You should be able to slide the slider, it's why they are there :p What platform are you running? And are you seeing this in all the graphs (the demo ones that come with the editor), or just your own? UnityGUI is a bit finnaky when it comes to windowing, many of the bugs will go away in B3 as we are pretty much doing away with GUI.Window and writing a custom solution because there are so many issues that we are encountering.

    Direction is quite arbitrary. I always figured that graphs grow in the direction to the right (the base node is 'static' essentially). I didn't want to have to move the base node all the time just because the graph grew.

    ;)

    As time goes on more graphs will find their way in. Currently I prefer to spend my time getting more features in and testing them. By the time we release 1.0 I think there will be a decent selection of graphs. Beta is beta :p
     
  3. therobear

    therobear

    Joined:
    Sep 28, 2010
    Posts:
    22
    No big deal Stramit. I'll just have to wait until we get Unity Pro at work, which will be soon hopefully.
     
    Last edited: Sep 29, 2010
  4. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    4,584
    Cool, I can't wait for Beta 3 :D

    I'm on Vista x64 using Unity3 Pro. And... I tried the sliders in one of the demo graphs that came with the editor and there it seems to work properly. Weird.
     
  5. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    3,829
    hey, i just downloaded Unity 3... loving it already but i am using your shader editor to create a Diffuse/Spec/Normal/emission shader and I have no idea how to get this working... I read the manual but it still confused me... perhaps someone here could give me some insight...

    thanx
     
  6. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    3,829
    I must say this shader is extremely well done, but i have a question to using specular maps... I have a map painted and when I plug in that particular texture I get no changes on the surface, forcing me to have to use a range node to get my specular values... is there a quick way to get this working properly with just plugging in my texture...? Thanks a bunch
     
  7. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    4,584
    Plug your texture into Gloss and use a range for Specular.

    Does this do what you want?
     
  8. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    3,829
    No...i want something on the lines where I just plug into my specular map into the specular slot and it works like it is supposed to... :) I did the whole plug my texture into gloss and set the range and it doesn't look the way I want it... it is overbright
     
  9. sinok426

    sinok426

    Joined:
    Apr 3, 2010
    Posts:
    4
    Hi all,
    Stramit and Texel, i really like your shader editor. i'm a newbie with node based shaders so i have a question :) :
    How can i get smooth edges with the clip alpha test?
    To illustrate my question :

    on the left, it's in unity using your shader editor and on the right, it's in marmoset toolbag.
    Thanks!
     
    Last edited: Sep 30, 2010
  10. Vincentez

    Vincentez

    Joined:
    May 15, 2009
    Posts:
    3
    I must say I love this thing, but I'd like a couple of minor additions to it:

    - Larger workspace by default, with the ability to zoom in/out and pan the workspace when needed. Currently, it only seems to give more space to work with if you drag a node over the edge of what you currently have.

    - Selection of multiple nodes, so you wouldn't have to move them one by one, if there's need to re-arrange stuff.

    Also, duplication of selected nodes would be a great option.

    All these would make it a lot more comfortable to work on anything more complex

    EDIT:
    heh, posted before reading the thread :p seems like some of these are coming already

    EDIT2:
    This is a pretty important one.. is there anything comparable to the if-node of the unreal material editor? If there isn't, it should be added :) I couldn't find one.
     
    Last edited: Oct 1, 2010
  11. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,005
    Alpha test will clip when a value is below the given threshold. I would need to see the shader you are using to give some real advice, but it looks like you might be using a texture for the clip? If so make sure it is of a decent resolution and that it is not being point sampled. Does the marmoset toolbag use alpha test or alphablend? this could also cause the issue.
     
  12. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,596
    the one on the right looks a lot like it was done with an engine that supports transparency antialias
     
  13. sinok426

    sinok426

    Joined:
    Apr 3, 2010
    Posts:
    4
    Thanks for your answer!
    So, more precisions, here is the graph of the shader i used :


    The texture i use for the alpha is set on bilinear filtering, and when i switch on a built-in unity shader it works :


    Marmoset use alpha test. And maybe alpha to coverage but forgot about marmoset, you can get the same alpha test with built-in unity shader.

    Finally, when i switch my alpha texture from Point to Bilinear filtering, there is no big changes, (just a very little smoothing on some angles) :


    Is there a way to got a smooth alpha test shader?

    Thank you!
     
  14. Texel

    Texel

    Joined:
    Dec 25, 2009
    Posts:
    61
    Your problem is that your using Any()- Any will return (1,1,1,1) if any channel is > 0, the problem is, for the smooth area between your pixels, it's being evaluated as being fully opaque because of your Any(), and the smooth transition regions are being ignored. Further, the saturate() is unnecessary, since your value is already in the [0.1] range, aswell as the Splat, since you could just be grabbing the alpha directly. Ideally, you should be clipping by a float constant minus the A component of the alpha map. In a word, your overcomplicating it.

     
  15. sinok426

    sinok426

    Joined:
    Apr 3, 2010
    Posts:
    4
    Thanks a lot Texel for your explanation! it works! and i've learned something today.
     
  16. mca

    mca

    Joined:
    Sep 1, 2009
    Posts:
    1
    Hello,
    I have a problem with preview, when i open the editor i can't see the preview window:
    $preview.JPG
    Thx for Help.
     
  17. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,596
    Without Pro render textures don't work and as such also no realtime preview
     
  18. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,005
    This is correct, but I will be trying to figure something out after Beta 3.0 is released.
     
  19. oblivionfeet

    oblivionfeet

    Joined:
    Jul 24, 2010
    Posts:
    481
    Completely off topic, but where's your avatar from? That looks like a really cool pic!
     
  20. Wenceslao

    Wenceslao

    Joined:
    Feb 7, 2009
    Posts:
    142
    Texel helped me write an indirection shader. It will allow the application of a texture atlas to a mesh that has a continuous unwrap; such as this:

    Web Build example of a mesh using texture indirection

    The mesh:



    Why do this?

    -If your unwrap is continuous it saves on verts which is critical to iPhone and other mobile platforms.
    -It allows saving on texture space by applying the same cell of an atlas repeatedly

    How to set it up:

    You will provide a terrain atlas and your mesh.
    In making terrain I found it was best to unwrap it into a uniform grid as seen in the screenshot above.

    You set the settings in the shader as follows:
    X and Y - The dimensions of your atlas
    Z and W - the number of tiles to have across your mesh

    Add in your reference texture
    Must be a power of 2
    Turn off mip mapping and set sampling to point
    Easier to handle of it is the same resolution as Z and W above


    How does it work?
    If your atlas is 4x4 as in my example then you will use the R channel to control the X look up in your atlas and the G channel to direct the Y look up in the channel. If you think about it, your range of look up will be from 0 to 1 in your atlas. If you want the texture half way in your atlas that would be 0.5. In terms of a RGB texture, 0.5 of the R channel will be 128. So if you want a tile to to use the tile that starts at (0.5, 0.5) you would color a pixel R: 128 and G: 128. The B and Alpha are ignored in the Atlas Lookup Texture.

    Here is an example of the atlas. I've indicated the R and G values on each tile that you'd have to put into the look up texture to get that tile:


    Here is a blown up version of my Atlas Lookup Texture:


    The actual lookup texture (A 4x4 texture):
    http://www.evil-lab.com/unity/IndirectionShader/AtlasLookup.png

    The settings for my example. A 4x4 atlas spread as 4x4 tiles over my terrain:


    A shot of what the shader looks like:


    The actual Shader Graph:
    http://www.evil-lab.com/unity/IndirectionShader/IndirectionStaticJay.sgraph (Right click, save as)

    I think that's all for now. If anyone has improvements they'd like to make go right ahead and repost it. Texel, if something is wrong, feel free to correct.

    Notes:
    * If you don't use a power of 2 texture for your look up texture, you will run into issues because Unity will round it to a power of two regardless of the settings in the importer. This will cause it to be resampled and cause artifacts.
    * This shader does not work on MBXLite (iPhone or iPhone 3g) due to the fixed pipeline rendering it utilizes. 3gs, 4 and iPad only. (Or PC in web if you need it)
     
  21. yosh

    yosh

    Joined:
    Mar 13, 2009
    Posts:
    142
    Could anybody please provide a "Transparent/Reflective Specular" -shader (using a Cubemap) for simulating windows or glass-objects? I a shader noob and have no idea how to make one of my own... Think that would help a lots of board members, too...
     
  22. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,005
    It's a concept from an on again / off again game I am working on with some friends. Maybe we'll finish it one day!
     
  23. oblivionfeet

    oblivionfeet

    Joined:
    Jul 24, 2010
    Posts:
    481
    I hope so! :p
     
  24. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    645
    Hey Stramit or anyone else,

    I'm not too good with shaders, but, can someone point me to where my problem is. I've tried different ZTest modes and different Queues and none of them seem to fix my problem... I need the polys to be rendered from front to back, but, it seems to be just kind of jumble the teeth and eyes together with the face.

    The Visibility is set to 1.0 so at this point it should look as though I have a Diffuse shader on it. The reason for the Visibility value (or why I don't just use a Diffuse shader) is so I can fade the character in and out.

    Can I fix this in the graph editor, or do I need to manually edit the shader?

    Thanks for any help :)
    Nathan
     

    Attached Files:

  25. Texel

    Texel

    Joined:
    Dec 25, 2009
    Posts:
    61
    Nathan, as long as you have a value connected to the Alpha output of the shader graph, it will assume you are using sorting. In your case, since you want to fade the whole character at once, and the character is made up of multiple layers of faces, you need to render it opaque and then mix it into the background- Unity allows you to use a grab pass for this, then blend to the grab pass for transparency.Graph File

    $GrabPassTransparency.png
     
  26. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    645
    Thanks Texel,

    Is a grab pass like a screen shot, so to speak?
     
  27. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    3,829
    I have an issue with setting up my normal map... I am using your shader editor to set up my materials for my characters and here is a problem:

    No NM: in this image, everything looks like it should...nice specular, cool diffuse, the way is it supposed to be...



    With NM: And when i connect the normal map, I get this nasty looking model that is not lit right or anything...maybe my tangents are all screwed up... i've tried reimporting my model with new tangents and this is a no go...and i have also tried using a combination of nodes with no lucky. I'm using the Unpack Normals nodes to get the effect of normal as the manual suggests...i need to find a way around this since my models do use normal maps and this looks very BAD...

    And with all of the nodes connected, i get this very blown out highlight that should not display the way it does...



    And with all of the nodes connected, i get this very blown out highlight that should not display the way it does... i am not a programmer by any stretch and any help and suggestions would be awesome...thank you
     
  28. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    3,829
    Problem solved... that UnpackNormal node is not needed
     
  29. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,005
    Yep, the unpacknormal is only needed if you don't do a tex2d normal. The tex2dnormal node is just for simplification if you only have a normal map to sample.
     
  30. Vert

    Vert

    Joined:
    Mar 23, 2010
    Posts:
    1,090
    WOW, super easy tool to use. I just tried it out in Unity Free and even though there is no real time preview, this sure beats coding shaders by hand! Keep up the awesome work on this! Thank you very much for helping out us non-shader coders!
     
  31. Sprocket

    Sprocket

    Joined:
    Sep 18, 2010
    Posts:
    29
    Mad props for making this! The Unity guys definitely need to get their act together and license your work!!

    If you're looking for inspiration on how to improve the GUI I can recommend taking a look at World Machine and Filter Forge (both have free trials). They both have some very nice features for graph editing.

    I think it would help a lot if you could add a preview for the currently selected node's output - maybe as a simple 2d square mapped with uv's from (0,0) to (1,1) (or you could change the 3D preview to show the node output).

    If you're feeling really adventurous then nested modules/macros would be a great addition for complex shaders (sort of the way World Machine does macros, but would be better if the macros are stored in their own file for re-use). :)

    OMG!

    I was about to make (or at least try) *exactly* same thing - in fact the reason I was reading up on this thread was to figure out if the generated shaders are compatible with iPhone (which you answered as well).

    I'll try your shader and will let you know if I make any improvements/modifications! :)
     
    Last edited: Oct 7, 2010
  32. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    3,829
    ^^ I agree with the above poster... i am not a programmer and i love how cool it looks... :) I need to try out the alpha stuff for torn clothing :) and maybe some procedural generation of damage... for example: boxers when they get bruises and stuff...
     
  33. TheCheese

    TheCheese

    Joined:
    Nov 25, 2009
    Posts:
    82
    I'd like to second this request...

    OK...Texel's documentation gives me almost exactly what I'm looking for - I just have no idea how to do a cubemap reflection...
     
    Last edited: Oct 8, 2010
  34. Sprocket

    Sprocket

    Joined:
    Sep 18, 2010
    Posts:
    29
    I am encountering a strange mipmap bug when trying to use the frac function. I narrowed it down to the simplest possible filter with nothing but the frac function:



    The texture seams end up being gray, which is actually a lower resolution mipmap.


    Magnified view of the gray seams here:



    The texture I am using is a 2x2 pixel black/white texture. I have set filtering mode to point and compression is off (see below for other settings). Player settings are at "full res" and "per texture" filtering and anti-aliasing disabled. I tried generating my own mipmaps (setting all but mipmap 0 to purple shows the seams being purple). Turning mipmaps off makes the problem go away. In other words I am 100% sure it's a mipmap issue, not a filtering issue.

    It seems to happen whenever the frac function jumps from 0.99999 to 0.0 - whether or not its inside a triangle or the seam between triangles.

    Web Player example: http://emerganz.com/demo/buggymaps/WebPlayer.html
    Unity Package: http://emerganz.com/demo/buggymaps/BuggyMipMaps.unitypackage (includes a couple more textures that illustrate the problem)


    Here's my settings:





    (checking/unchecking the "border mipmaps" option is unrelated to this problem)


    The bug is also present in the "texture atlas" shader Hyjinx posted in this thread a few days ago.

    I am in the process of writing my own landscape engine for use on iPhone and whether or not I can squeeze in multiple tile-textures in one big texture is a pretty low-level design decision I have to make pretty soon - so any help would be appreciated! :)
     
  35. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,596
    you shouldn't use filtermode point unless you are looking for explicitely the effect you are seeing there, especially when you disable anisotropic filtering as you disable all texture filtering completely
     
  36. Texel

    Texel

    Joined:
    Dec 25, 2009
    Posts:
    61
    Sprocket, because the texture coordinates are suddenly jumping between 0-1, the card attempts to match the texel and pixel density, causing it to bounce to a very low mipmap. Try setting filter mode to Kaiser rather then Box, to avoid it blurring (Kaiser is closer to point filtering), and directly fracing the UV is of limited use, since a texture mode of repeat handles this normally (without causing the sudden jumps to throw the mipmapping). Your atlas texture really shouldn't actually have mipmapping at all, and you have to be careful to ensure it's a power-of-two to prevent Unity from blurring it inadvertently.
     
  37. Sprocket

    Sprocket

    Joined:
    Sep 18, 2010
    Posts:
    29
    Edit: I managed to find some documentation on the problem Texel describes. I added some comments at the bottom of this post about this.


    I know point filtermode gives ugly results - I'm only using it to eliminate all sources of error. I am not commenting on the ugly lack of filtering, I am pointing out the fact that there's gray low-mipmap pixels where they shouldn't be. Besides point filtering shouldn't interpolate (as far as I know) so it shouldn't be generating gray pixels.

    I really am 110% sure this is not a filtering issue - making my own purple low-detail mipmap gave me purple pixels at the seams.


    I was afraid it was something lowlevel like that. :(


    Kaiser filtering doesn't make any difference here, since it only affects the texture import - generating my own mipmaps doesn't t make any difference either - anyways the texture I am using in the example is only 2x2 pixels, so it's quite obvious that the narrow seams aren't introduced at the texture level, but must be some rendering artifact.


    I know - I was just making the simplest possible shader that would make the bug show - for a real application of it there's the texture atlas shader on the previous page.


    Texture atlas'ing uses 2 textures. One is the "index map" that tells the shader which texture-tile to use and the other is the actual tile-textures in a grid (4x4 etc.). I am not using mipmapping for the the index texture - no problems there. However if I want this to be useful for 3D textures the actual tile-textures do need to be mip-mapped (unless I am missing something fundamental here).

    And yeah - I have been super careful to make sure everything is power-of-2.


    Is there any way I can repeat a tiled texture without generating the texture "jumps" that throws the card off? The fact that even the cube in the in the shader preview shows the mipmap error makes me wonder if this is completely unavoidable.

    Is there anything else I could do when creating an object with a lot of different textures? The only other alternative I can think of would be to create a material for each texture and then make a seperate sub-mesh for each material - but that would give me 4 times as many vertices. :(


    Anyways - all advice is appreciated!


    Edit - purple seams (mipmaps higher than 0 set to purple):



    Edit2 - I found some references to the problem Texel describes:

    http://www.gamedev.net/community/forums/topic.asp?topic_id=491244
    http://www.gamedev.net/community/fo...nal.asp?jn=263350&cmonth=4&cyear=2008&cday=10
    There's also some info here: http://download.nvidia.com/developer/NVTextureSuite/Atlas_Tools/Texture_Atlas_Whitepaper.pdf


    I guess that means atlas mipmapping is completely out of the quiesting unless I want to use 4 times as many vertices or limit myself to SM3.0+ video cards..
     
    Last edited: Oct 11, 2010
  38. BenAllen

    BenAllen

    Joined:
    Sep 11, 2010
    Posts:
    13
    This looks really promising and powerful. Great work guys. I can't seem to download the documentation. Is there a trick for downloading it?

    Cheers.
     
  39. BenAllen

    BenAllen

    Joined:
    Sep 11, 2010
    Posts:
    13
    Nevermind. I have it now. It was my version of PDF that was out of date. Will get cracking on my indie deep water shader when I have read the documentation. Excited.
     
  40. duke

    duke

    Joined:
    Jan 10, 2007
    Posts:
    764
    Anyone tried recreating this gem?

    http://interiormapping.oogst3d.net/

    edit:

    Here's a quick texture I made to use if you want to give it a shot. It's got an inappropriately styled blue door on the interior left wall, and a blank red "painting" on the right.
     

    Attached Files:

    Last edited: Oct 11, 2010
  41. deram_scholzara

    deram_scholzara

    Joined:
    Aug 26, 2005
    Posts:
    1,025
    Is there a way to do an "Additive" shader with this? I'm trying to do something similar to the Additive Particle shader.

    Thanks!
     
  42. antoft

    antoft

    Joined:
    Apr 27, 2010
    Posts:
    3
    great work stramit

    one question - I'm trying to do the same as appendVector in UDK, is this possible with this version of the editor?

    nice to see that you are planing for custom light models, you are making my day more creative!

    -Antoft
     
  43. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,005
    The trick is to remember that unlike the UDK everything is already a vector 4. So instead of appending you can do a mask / add, or if you know a component is already 0, just an add.
     

    Attached Files:

  44. antoft

    antoft

    Joined:
    Apr 27, 2010
    Posts:
    3
    Hi again

    one more question, since udk is where im coming from. Is the reflectionVector in UDK, the same as the vertex reflection (simpleWorldReflection), or is there a way to recreate it.

    -Antoft
     
  45. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,005
    Hi everyone, I've been really snowed under at my job for the past few days, and I have noticed all of your questions and I will answer them in the next day or so. What time I have had I have been putting into Beta 3. Vertex Modification is working very nicely and fits in well with the architecture if you are curious.

    As an aside, I am going to the 'Game Connect Asia Pacific' conference in Queensland, Australia this weekend (no programming :( ) if anyone from here is there hit me up on PM / twitter / email.

    Oh, and here is a picture of working vertex modification:

     
    Last edited: Oct 12, 2010
  46. david_jd

    david_jd

    Joined:
    Feb 12, 2010
    Posts:
    4
    I like very much the shader node , it is very user friendly ……
    I’m trying to make a shader for movie texture , where it can subtract the black color of the movie. Like Chroma key ,
    Anyone knows how to make one , with shader node?
     
  47. jeffro11

    jeffro11

    Joined:
    Jan 7, 2010
    Posts:
    185
    The only thing this needs is direct access to each R, G, B, and A channels (just like the UDK material editor) Then this will be perfect. Thank you so much for creating this. It makes it SOOOO much easier. Artists can finally be creative again.
     
  48. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,596
    You can directly access each channel on its own to use it, the splat node allows this
     
  49. jeffro11

    jeffro11

    Joined:
    Jan 7, 2010
    Posts:
    185
    Well look at that! It would however be easier to just grab the channels off of the Tex2d. Can't argue that.
     
  50. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,596
    Easier depends on definition. the problem is that the node then couldn't provide a vector4 anymore without introducting a vector4 node to use any texture based modifier.

    the cases where you require distinct channels is normally smaller than the amount of cases where you need the whole vector4, as such at least to me it is favorable if the default output is a color vector, not distinct channels forcing me to push them through.

    that being said, it would naturally be possible to introduce redundancy by offering to tex2d nodes one with color output and one with channeled output ... but I've doubts that this would be favorable for the productivity if the node list gets clobbered by dublicates preventing you from finding the real thing