Search Unity

Shader Forge - A visual, node-based shader editor

Discussion in 'Assets and Asset Store' started by Acegikmo, Jan 11, 2014.

  1. Arterius

    Arterius

    Joined:
    Jun 18, 2013
    Posts:
    14
    Hi, I have a small problem.

    Made a kind of water shader which works great it's just that when I close and open unity again the shader reverts to a simpel diffuse shader with the same color until I open shaderforge and edit a variable (and reset it to the same value), this fixes it and it goes back to normal. Anyone know why I have to do this for it to work properly? Could it be that it doesn't save properly?
     
  2. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,362
    I am not 100% sure, but i think Forge exports a text file with a Unity shader, so if it works after leaving the editor, should always work

    I would check the text file with the shader after compilation to see if the variable is set there and save the file to the desktop before closing and compare to the one when opening Unity, see if there is any difference. Closing Unity should not modify the asset in any way i suppose.

    Also falling back to Diffuse means that the main body of the shader fails, which should not be variable dependent i guess.
     
  3. Arterius

    Arterius

    Joined:
    Jun 18, 2013
    Posts:
    14
    Do you mean the .shader file? because I don't know what file you could be talking about otherwise, and I didn't see any differences in the .shader file either.
     
  4. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,362
    Yes, the shader file.

    What is the variable you change related to ?
     
  5. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,160
    I'm having a similar problem. I don't need to change any variables, but I do need to manually recompile every time I load a shader.
     
  6. Arterius

    Arterius

    Joined:
    Jun 18, 2013
    Posts:
    14
    Doesn't matter which it is as long as a variable is changed (&reset) so I don't think that really matters, also works to add a node, recompile and then remove it and compile. Both methods work the get the shader working again. Also checked the files with a difference check and they are identical.
     
  7. marggob

    marggob

    Joined:
    Feb 24, 2013
    Posts:
    65
    how can I make the cubic projection UV?
    I mean Triplanar Texturing.
     
    Last edited: Jul 17, 2014
  8. IzzySoft

    IzzySoft

    Joined:
    Feb 11, 2013
    Posts:
    376
    Small issue with shader:


    _MainTex:


    _Mask:


    _Mask2:


    Mask Import settings:


    If you use the Masks shown above.. it sort of works Ok.

    But, what you dont see is.. the Top and Right 1 pixel row/column of the masks are transparent.
    ex:



    Question: Why cant the Shader work if I fill the TOP and RIGHT pixel rows with the same color?

    Any hints, tips, Tricks.. or what not? :(

    Super Cool Plugin BTW! ;D
     
    Last edited: Jul 18, 2014
  9. GrumpyOldMan

    GrumpyOldMan

    Joined:
    Sep 29, 2011
    Posts:
    51
    Thanks for the tip!
    Took me awhile to figure it out, but after looking at the Custom Lighting example and watching the Custom Blinn-Phong video, I managed to wrap my head around it. It still blends the textures if a second light is involved, but with one light is working as intended.

    Can Shader Forge do a wireframe overlay shader with backface culling?
    So for my next material, I'd like to render the wireframe of an object, like old 80's 3D vector game graphics, Battlezone, or FOTONICA, but as an overlay over the material. I'd guess that it'd be a post processing effect to get the desired vector effect. In my research I found this, but it goes over my head: http://answers.unity3d.com/questions/198467/How-to-create-VectrexVector-look-in-games-.html

    I've been using UV outlines painted on 2d texture maps, but the lines come out blurry and aliased even with high resolution maps, so if a shader could do it that would be spectacular. I've set up shaders that do this in Max and Maya before, is there something in Shader Forge that does the same?
     
    Last edited: Jul 18, 2014
  10. bmccall1

    bmccall1

    Joined:
    Jul 28, 2013
    Posts:
    120
    I'm having two problems I could really use feedback on.

    1. I recently updated shader forge and since I've done that I can no longer open the gui. I get thousands of error messages in console and have to close unity to continue working. I tried reimporting but to no avail. The shaders appear to still work but I can't open the builder.

    2. My game runs really poorly in webplayers on macs. The user has no problems with any other unity games, just mine, and I verify that my game runs across multiple platforms except mac webplayers. The ONLY thing I can come up with is that Shader Forge is the difference between my game and other games. Is there anything you can think of that would cause this?

    Thanks
     
  11. IzzySoft

    IzzySoft

    Joined:
    Feb 11, 2013
    Posts:
    376
    I'm guessing you already tried Deleting the existing ShaderForge folder, and Imported the New Version again?
     
  12. P1st3ll1

    P1st3ll1

    Joined:
    Dec 13, 2012
    Posts:
    69
    How does Edge Based Tesselation works ?

    This is what I get from every Tesselated object... Reinstall Shader Forge maybe ?

     
    Last edited: Jul 18, 2014
  13. P1st3ll1

    P1st3ll1

    Joined:
    Dec 13, 2012
    Posts:
    69
    Reinstall didn't work...
     
  14. P1st3ll1

    P1st3ll1

    Joined:
    Dec 13, 2012
    Posts:
    69
    LOL Nevermind, Unity disabled DX11 by itself XD

    But still, how do I use Edge Based Tesselation ?

    And, when I enable Parallax, I get this error: "Shader error: undeclared identifier 'tangentTransform' at line 228"
    What does that mean ?
     
    Last edited: Jul 18, 2014
  15. bmccall1

    bmccall1

    Joined:
    Jul 28, 2013
    Posts:
    120
    Yes, I did, sadly.
     
  16. itsAditya

    itsAditya

    Joined:
    Jul 20, 2014
    Posts:
    3
    First of all this tool is like a torch in this dark world of shader development ..... and secondly it would be a great help if you can show us how to achieve a fur shader using Shader Forge
     
    Acegikmo likes this.
  17. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    You can, although it would be nice of you both for your customers and me, to mention the fact that they can edit the shader in Shader Forge if they like :)
    And yes, it will work for those with pro


    This is a tricky thing, and there's no straightforward way of making it, and I don't know if it's possible in Shader Forge yet.

    You may be able to use some sort of gradient from each UV edge, Photoshop outer glow, for instance.
    You should then be able to use a distance biased threshold, and round it, to get a somewhat controlled thickness value, without blurriness. This doesn't work well for edges at grazing angles though, but may work alright in your case.

    1. Delete SF completely from your project, reset the window layout of Unity. Close Unity, Open Unity, install latest SF version, and see if it works.

    2. It could be any number of things. Refraction is quite possibly the most expensive thing you easily can do in SF though, perhaps you're using too much of it?
     
  18. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Making a fur shader is tricky, and usually involves multi-pass shaders or some very specific DX11 features, that you can't do in SF at the moment.

    That said, if you pre-process your mesh, you can do the multi-shell approach, and use an SF shader to render it.
     
  19. itsAditya

    itsAditya

    Joined:
    Jul 20, 2014
    Posts:
    3
    Sorry to say this but i didn't understand a single word of what you said, frankly, i m not a shader developer so i m not able to understand these terminologies like multi-pass, pre-process or multi-shell approach .... basically i had to develop a fur shader for my college project and i just want to get through this anyhow .... i already tried the link you gave and i tried the CODE node to run that piece of code but no success and why that guy over that website namet XBDEV is saying that it is too easy to develop a fur shader ? .... pls show me a way to achieve this
     
  20. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,362


    Thanks :)

    I have already mentioned that i use Shader Forge in the thread :), plus i will make sure to emphasize the fact that you can preview Pro effects in Free mode, which is extremely valuable and amazing at the same time :)

    One question, i have modified the Refraction shader to assing a texture to give a blue tint, but when i assign the texture in the inspector, Unity hangs.

    I post a pic, do i do something wrong ? I have only touched on the path that goes to diffuse, nothing else
     
  21. P1st3ll1

    P1st3ll1

    Joined:
    Dec 13, 2012
    Posts:
    69
    So... Does anyone knows how to help me ?
    About the POM causing errors and how to use edge based tesselation ?
     
  22. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,160
    I think that it might be possibly without having to do too much pre-processing, depending on the level of accuracy needed. I'm simulating a shell effect for my planet shader using the panner node.



    The area in the red handles it. Incidentally, it's a pain to set up right now since I have to trick SF into taking two inputs into the panner like that.
     
  23. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Usually you use the parallax node for having layers pan based on view direction. The tricky part with fur shaders is to get the edges/silhouette to look furry

    Also, I see you have a Transform(Tangent to World) <-- Vector3(0,0,1). That should be exactly the same as just using the normal direction node :)
     
  24. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,160
    Oh, yeah, that's because the original shader was a straight adaptation of this. I ended up heavily modifying it, but a lot of its UDK base is still there, such as converting from tangent space.
     
  25. lotsofwind

    lotsofwind

    Joined:
    Jan 8, 2014
    Posts:
    3
    how do i go about doing blending 2 textures but 1 texture blends vertically across the other texture with a value of 0 to 1?
     
  26. Elzean

    Elzean

    Joined:
    Nov 25, 2011
    Posts:
    584
    Is there a way to use the sprite data like other sprite material ? It seems difficult to get things right while using sprite otherwise.
     
  27. GrumpyOldMan

    GrumpyOldMan

    Joined:
    Sep 29, 2011
    Posts:
    51
    I kinda understand what you mean, but I'm not quite sure. Which parts of this are in Photoshop and which are in Shader Forge? I follow you until distance based threshold.
     
  28. vivin

    vivin

    Joined:
    Jul 10, 2013
    Posts:
    15
    Hey guys, I know this has been asked before but I am still a bit stumped on it.

    Using the depth blend node to simulate depth at the edge of water. I got the shader doing what I want it to do, and it actually renders/looks fine in the editor, but as soon as I hit play, it doesnt look correct at all. I understand the concept that the camera needs to also render to a depth texture, Im just not sure about how to implement this? is it as simple as attaching a script to the camera (http://docs.unity3d.com/ScriptReference/Camera-depthTextureMode.html) I am currently rendering in deferred mode, while the shader in question is forward base, could that be an issue? Im pretty sure I cant untick "write to depth buffer" on a deferred shader.

    Anyone else run into this issue or has a possible solution? I have been scratching my head over this for a few hours now as this is all slightly outside of my comfort zone :)
     
  29. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    The gradient articles under Colors & Textures on the wiki should help :)
    http://acegikmo.com/shaderforge/wiki/index.php?title=Shader_Forge_Wiki

     
  30. DigitalAdam

    DigitalAdam

    Joined:
    Jul 18, 2007
    Posts:
    1,209
    Has phong and edge length tessellation been added yet?
     
  31. JohnRossitter

    JohnRossitter

    Joined:
    Dec 18, 2013
    Posts:
    1,027
    So I updated to 0.36 from 0.34 today:

    When I open Shader forge and try to make or edit a shafer, this is what I get:
     

    Attached Files:

  32. IzzySoft

    IzzySoft

    Joined:
    Feb 11, 2013
    Posts:
    376
    I'm not sure what you want, but I was thinking it might be something like this Fade In?

    or, Maybe you're looking for a Clean Wipe?
     
    Last edited: Jul 23, 2014
    Acegikmo likes this.
  33. bmccall1

    bmccall1

    Joined:
    Jul 28, 2013
    Posts:
    120
    Hey thanks for the response. As for the poor performance and crashing on macs, its mac specific.
    SImilar strength cards perfrom great, and even lesser cards perform ok. The framerate problem is specific to the webplayer, and the game will only run without crashing at all in fantastic mode in standalone.
     
  34. R041

    R041

    Joined:
    Nov 24, 2012
    Posts:
    6
    I'm trying to do a simple color overlay with an alpha and I'm not sure if I did this correctly, is there a better way?



    Sorry for the crap gif. :(
     
  35. Play_Edu

    Play_Edu

    Joined:
    Jun 10, 2012
    Posts:
    722
  36. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,362
    I transfer the question below
     
    Last edited: Jul 31, 2014
  37. magic9cube

    magic9cube

    Joined:
    Jan 30, 2014
    Posts:
    58
    Please excuse this novice question. I'd like to know if its possible to create a shader which can combine light from mesh color data (voxel fake ambient occlusion) with external light. I've not yet worked out how to create shaders like this with this tool. I really like what i've seen so far generally but my current primary requirement is a shader as described above.
     
  38. Deleted User

    Deleted User

    Guest

    Hi,

    I have a very simple shading network, just practicing with shader forge atm, I have a diffuse colour node multiplied with vertex colour, so the object I'm working with now displays the vertex colours applied to it externally, anyhow, I would like to also include the vertex alpha, so I connect the vertex alpha output to the main Alpha, which works, but I lose the ability to have shadows cast on the object, what am I doing wrong here, the shadows work without the vertex alpha connection ?

    Thanks
     
  39. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Edge length - Yes
    Phong - No, not yet

    I think this is due to a malformed install. Completely remove the old installation of SF before installing the new one again, and see if it works!

    Use the grayscale mask in the T input of a lerp, and have texture * color in the B input of the lerp, and just the texture in the A input of the lerp, and it should work as expected :)

    I don't think there's a way to do it without a texture at the moment no. (Unless you manually make a shader)

    Assuming "mesh color data" is vertex colors, then yes, definitely!

    That's due to the issues with alpha blending, there's not really any way around it apart from using alpha clipping instead of alpha blending (this is a general game engine issue)
     
  40. Deleted User

    Deleted User

    Guest

    Hi, Thanks for your reply.

    I've hooked it up to clipmap instead, but the alpha is now very harsh ( no falloff gradient ), any ideas on how to get back the soft falloff ?
     
  41. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Alpha blending is difficult for many reasons. Usually you'll want to avoid it, and only use it when you really have to. If it's a glow effect such as a lightbeam / sunshaft, you can simply make the shader additive. It it's something like dark smoke, you can use multiplicative blending.
     
  42. Deleted User

    Deleted User

    Guest

    No worries, thanks again for your reply, seems like I need to experiment further, I should mention however, the problem I was having was only with vertex alpha, a diffuse map with transparency ( i.e. png's ) applied with a clip map worked as expected with the transparency displaying correctly.

    In all honesty, vertex alpha seemed to work best when attached directly to the alpha, this gave me exactly the look I had developed externally in Maya, both alpha and alpha clip lost the ability to receive shadows once applied.
     
    Last edited by a moderator: Jul 24, 2014
  43. magic9cube

    magic9cube

    Joined:
    Jan 30, 2014
    Posts:
    58
    That sounds positive ;however, everything I've tried in shader forge just comes out black so far. A shader that does work on my voxel terrain is as follows;

    Code (CSharp):
    1. Shader "Vertex Color NTL" {
    2. Properties {
    3.     _MainTex ("Texture", 2D) = "white" {}
    4. }
    5.  
    6. Category {
    7.     Tags { "Queue"="Geometry" }
    8.    
    9.     BindChannels {
    10.         Bind "Color", color
    11.         Bind "Vertex", vertex
    12.         Bind "TexCoord", texcoord
    13.     }
    14.    
    15.    
    16.     SubShader {
    17.  
    18.         Pass {
    19.  
    20. SetTexture [_MainTex] {
    21.                 Combine texture * primary DOUBLE
    22.             }
    23.            
    24.         }
    25.     }
    26. }
    27. }
    Is anyone able to describe how i can duplicate this in shader forge and its results as a base to achieving the combination of vertex color and external light color?
     
  44. NapalmRain

    NapalmRain

    Joined:
    Mar 3, 2013
    Posts:
    29
    Good day!
    I created shader of water surface. Basically everything goes well, but I can not figure out how to do so that objects behind the plane with a shader were like in the fog. So far, so stronger.
    Just can not understand even where to start.
    Thank you in advance!
     
  45. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Looks like you simply need something like this:



    You'll most likely want Scene Color and Depth Blend, in order to make something like that.

    For instance:

     
  46. magic9cube

    magic9cube

    Joined:
    Jan 30, 2014
    Posts:
    58
    This is what i try;

    sf_nsf01_7272014.png

    This is what i get (all chunks selected, so they show as outlined in this screenshot);

    darksf.png

    This is what i get when i use the simple shader i posted earlier;

    darksf2.png

    Anything else i'm missing here?

     
  47. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Did you assign the texture in the material inspector?
     
  48. ACZ

    ACZ

    Joined:
    Feb 7, 2013
    Posts:
    3
    Hey - first off, Shaderforge is awesome! I spent a lot of time in UDK, and I'm actually liking what you have more!

    I am trying to publish a version of my game to Android, and I'm finding that really simple shaders work - but almost any complexity turns them solid black - but only in the Android build.

    The assets are definitely connected correctly, and the shaders appear to work correctly in Open GL ES 2.0 (or at least the render emulation). Fallbacks don't automatically get applied - though I started to workaround things by using the shader LOD to force my own fallbacks. Ideally though I'd like to be able to use my real shaders (assuming I've optimized correctly, etc).

    I've read the documentation on mobile optimization, but mostly I'm just looking for functionality before I dive in an optimize. I do know I am nowhere near the instruction count limit. (As per the above answer, the assets are hooked up correctly as they show perfectly in the editor and on my webplayer build)

    Forcing the experimental Shader Model 2.0 has no effect. Changing the platforms has no effect, unless I turn all platforms off at which point the shader is black even in the Shaderforge preview. Platform and quality settings have no effect either. I'm using Forward rendering, and otherwise pretty vanilla settings.

    It almost seems like any time I have any math (such as a multiply node) the shader fails in the build. I do have Unity Pro, but I do not have Android Pro - would this explain the issue?

    Really appreciate any insight into what could be going on here - thanks!

    ---

    P.S. Do you know off hand if alpha blending + depth can work on mobile? I realize that its probably absurdly expensive, but I need it for a very specific effect which only uses a small screen percentage.

    Failing this, would you know any way I could have an object (under the ground) render ontop of the the ground, but still under the player? I tried using cameras, but I also need the player to cast a shadow on the ground. Alpha blending would be my preferred approach (and it looks wonderful in webplayer and even the Open GL ES 2.0 emulation) - but if I can't come close to testing on my tablet for the above issue...

    ---

    Edit: From other searches it looks like this is instruction count limited? For my color pulse shader, I tried a very low end test: Time -> Multiply -> Sin -> Remap -> Emissive. [black and white pulse].

    Everything else turned off / as low as I can possibly go. (force model 2.0, unlit, no fog, etc). This still shows up black on Android, without automatically triggering the fallback.

    I can make this exact same shader in Strumpy and it works just fine on Android. (in Strumpy, if I blow the instruction count, the shader goes magenta inside emulation - even before hitting the tablet.)

    Is there any way to get a sense of the instructions inside Shaderforge? Is there anything I can do to reduce the instructions?
     

    Attached Files:

    Last edited: Jul 27, 2014
  49. magic9cube

    magic9cube

    Joined:
    Jan 30, 2014
    Posts:
    58
    yes, as in image below. i feel like this must be something really simple but i can't find anything obvious. i will try re-installing later tonight.


    [Edit]

    OK! This was my own stupid mistake! :) I had the wrong render path selected for the camera. It was saved to "Vertex Lit". Thanks for being patient with me :)
     

    Attached Files:

    Last edited: Jul 27, 2014
  50. Deleted User

    Deleted User

    Guest

    Hi,

    Was wondering how shader complexity will effect my scene performance ?

    I'm busy creating a bunch of shaders, kind of like a base package that I can utilise everywhere, with everyday options, and I'm wondering if adding all these extra options will effect the performance of any projects when not all options are utilised, for instance

    Let's say I have basic shader, the shader has a diffuse texture, options for vertex colour ( if present) and vertex alpha support ( if present ), also the diffuse texture has alpha clipmap support ( should there be transparency present), on top of this, I have optional U and V animation support should I require any uv animation, so, basic as this is, if I was to map this shader onto a scene object, but the scene object only requires the diffuse texture portion of the shader ( and not the vertex colour, alpha, clipmap or uv animation ), will this effect performance because the shader is always 'thinking' about the other options, or will it only think of the 'diffuse texture' ?

    Thanks