Search Unity

Shader Forge - A visual, node-based shader editor

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

  1. Indiefreaks

    Indiefreaks

    Joined:
    Nov 12, 2012
    Posts:
    89
    Oups... :confused::oops:
     
  2. Indiefreaks

    Indiefreaks

    Joined:
    Nov 12, 2012
    Posts:
    89
    I actually did what you just shared but I just don't get any gradient between the sky colors... Am I missing some shader settings? Shouldn't I make use of the view position somewhere in the shader so that the Skybox actually has some kind of gradient?

    Thanks
     
  3. Obsurveyor

    Obsurveyor

    Joined:
    Nov 22, 2012
    Posts:
    277
    If I did it right, I think your code node is equivalent to:

    Code (csharp):
    1.  
    2. return abs(fmod(floor(iValue), 2.0f) - frac(iValue));
    3.  
     
  4. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    SF uses the fragment shader for almost everything, but that's necessary to make SF easy to use. It'd be nice to have an automatic Optimize-My-Shader button, but it would have to handle tons of special cases and would likely still require some hand-tuning since it's pretty much impossible to predict what the SF user wants out of a shader. You don't have to optimize anything by hand, but I've seen first hand that it can prevent tons of calculations by just moving a lot of vertex-based calculations from the fragment to the vertex shader.

    Maybe verify that you're setting the colors in the material? As for shader settings, it should be Unlit/Custom. The view position/direction isn't necessary unless you're trying to do over-the-top effects.

    You're a wizard.
     
  5. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    Answered my own question about opening the compiled shader in Unity 5. For anyone else that wants it, here's some c# code. Put it in an Editor folder. It adds an item when you right click a shader in the Project window.

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEditor;
    3. using System.Reflection;
    4.  
    5. public class ViewCompiledShaderSource : ScriptableObject {
    6.  
    7.     [MenuItem("Assets/View Selected Shader Source")]
    8.     static void MenuGiveScenePostProcess() {
    9.         string path = AssetDatabase.GetAssetPath(Selection.objects[0]);
    10.         var shader = (Shader)AssetDatabase.LoadAssetAtPath(path, typeof(Shader));
    11.         MethodInfo openShader = typeof(ShaderUtil).GetMethod(
    12.             "OpenCompiledShader",
    13.             BindingFlags.Static | BindingFlags.NonPublic);
    14.     // Uncomment the following lines to log the parameters
    15.         //ParameterInfo[] paramss = openShader.GetParameters();
    16.         //foreach(ParameterInfo pms in paramss) {
    17.         //    Debug.Log(pms.ParameterType.ToString() + " " + pms.Name +
    18.         //        ", optional: " + pms.IsOptional);
    19.         //}
    20.         openShader.Invoke(null, new object[] { shader, 1, 0, false });
    21.     }
    22.  
    23.     [MenuItem("Assets/View Selected Shader Source", true)]
    24.     static bool ValidateMenuGiveScenePostProcess() {
    25.         return Selection.objects.Length < 2 && Selection.objects.Length > 0 &&
    26.             Selection.objects[0].GetType().Equals(typeof(Shader));
    27.     }
    28. }
     
    Acegikmo likes this.
  6. Amnoon

    Amnoon

    Joined:
    Jul 20, 2013
    Posts:
    31
    Hi guys. I am delving into some advances shader and i wonder is there is some way to reach some result similar to this (maybe with vertex offset):


    I have tried to do it by animation but i really don't know how to do this kind of animation readable by unity (I am using 3dmax).
     
    Last edited: Feb 5, 2015
  7. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    Using 3ds, export the animation to fbx or use the free fbx-converter-tool from autodesk. Then, import it as a generic animation. Look up some tutorials if you need them. I really think that type of animation is beyond the scope of real-time shaders unless you want to spend forever tweaking it to look just right. :)
     
  8. The_Least

    The_Least

    Joined:
    Jan 21, 2015
    Posts:
    27
    Hi all! I'm thinking of buying Shader Forge, but I have a question first: Can I control aspects of a custom shader with scripts?

    Eg: I have a model with a base diffuse/reflection/spec map. When the model is destroyed, I want to multiply a damage map over the base map using a script.

    Answer yes, point me towards an example, and you've got yourself a customer :D
     
  9. DaDarkDragon

    DaDarkDragon

    Joined:
    Jun 6, 2013
    Posts:
    115
  10. RockSPb

    RockSPb

    Joined:
    Feb 6, 2015
    Posts:
    112
    Hello! Have a couple questions about specular in shader forge

    1.In deffered mode specular are extremly bright and have an ugly edges unlike of forward mode
    2. When backfacing is on all faces have strange cutout of specular

    Thanks! Untitled-2.jpg Untitled-3.jpg
     
  11. The_Least

    The_Least

    Joined:
    Jan 21, 2015
    Posts:
    27
  12. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    What versions of Unity and SF are you using? Do you have all of the standard slots filled in with something?

    Yeah, regarding the difficulty of various ways to make shaders, Shader Forge is definitely The_Least difficult.
     
  13. The_Least

    The_Least

    Joined:
    Jan 21, 2015
    Posts:
    27
    My second day of Shader Forge has convinced me that this is the best buy I've made on the asset store so far.

    I've recreated a hidden object shader as described by @Murgilod in post #2420 (pg49), and while it works as intended, it has an awkward side effect: As well as highlighting the object when obscured by an object, it also highlights when obscured by its own geometry. Check out my goofy-looking Kaiju:

    hiddenGlow.jpg

    You can see that his tail is being correctly highlighted because it's behind the building, but his legs, right arm and mouth interior are also highlighted. Can this be fixed without post-processing? (I don't have Unity Pro)
     
  14. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    So, as some of you may have noticed - I've been rather busy these last few days, so development has fallen behind quite a bit. That said, there are some of you out there who are good coders, and would want to get things done as quickly as possible.

    I'm considering opening up source code access to a few select developers on GitHub - Would this be of interest to any of you?

    You could do pull requests, and I'll merge it into main and push out updates in case it's good and stable code :)
     
  15. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    That's the best idea. It'd be nice for whoever is working on it to have some guidance via a roadmap though, kind of like how Blender coders have a hierarchy and priority of tasks.
     
  16. Amnoon

    Amnoon

    Joined:
    Jul 20, 2013
    Posts:
    31
    Thanks a lot for the reply. I will try it soon! but will Unity read a no-bones animation done with modifiers in max?
     
    Last edited: Feb 8, 2015
  17. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    I have no idea. I don't use Max or keyframed vertex-animation. That said, why not use bones? That seems like the more flexible way to do it. Or even blendshapes tied to the update loop?
     
  18. donzen

    donzen

    Joined:
    Oct 24, 2009
    Posts:
    54
    Hi,
    I would to make a shader for Skyshop where I can blend beetween 2 different skies created with it.
    Using the skies as a reflection map my shader is inconsistent compared to Skyshop shaders.
    So I miss something, maybe because Skyshop blend skies with the diffuse map in some way.
    Anyone can help me to find the right way to make the shader?

    Thanks in advance for any help.
     
  19. DMeville

    DMeville

    Joined:
    May 5, 2013
    Posts:
    418
    I know another plugin considered this but decided against doing this because of some legal issues of eventually selling code written by someone else. I'd hate to see something like that happen with SF, so it might be worth getting something written up so that the select developers relinquish all rights to their code, etc. Or something, maybe this was already implied.. :)
     
  20. RockSPb

    RockSPb

    Joined:
    Feb 6, 2015
    Posts:
    112
     
  21. Owers

    Owers

    Joined:
    Jul 7, 2012
    Posts:
    39
    About the specular, I think it's because Shader Forge remaps gloss values from 0-1 to 1-2048 in forward rendering, but in deferred it's mapped to 0-128. This will create specular inconsistencies between forward and deferred modes, which can lead to problems like this. Unfortunately, because of how lighting works in deferred mode, gloss values can only be mapped between 0-128 (all of Unity's built-in shaders are like this). The best solution (if I'm right) is to either disable the deferred pre-pass and only use forward rendering for that shader, or manually remap the gloss values in your forward pass to 0-128 (Disable "Remap gloss from [0-1] to [1-2048]" and add a remap node to your gloss input, see screenshot). It won't fix the bright specular in deferred mode, but it should make it look similar in forward mode at least.
     

    Attached Files:

    IFL likes this.
  22. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    Does anyone know if there will be a replacement to unity_Scale.w in Unity 5? I've tested the new ObjectScale node in SF 1.04 under Beta 0.22 but I'd like to know what will be coming to us from UT itself. Does anyone know?
     
  23. pixelquaternion

    pixelquaternion

    Joined:
    Jun 28, 2014
    Posts:
    122
    Hi Joachim,

    We are looking at getting your shader editor and i just have a few questions before we jump in :

    I am pretty much a rookie regarding shader so i hope my questions will be clear enough,

    The game we are working on is mostly setup in a snowy environment and since we are using RTP in our pipeline i was a little disappoint that SF was not going to work in RTP to replace actual snow shader with a custom one.

    Is there any workaround or a possibility that you can support RTP in the near future?

    If i am correct i think that SF shader wont work for terrain?

    regards Peter
     
  24. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Count me in!
     
  25. KaylMyers

    KaylMyers

    Joined:
    Mar 28, 2013
    Posts:
    33
    This has been bugging me for the last couple of days. Haven't been able to figure it out and am hoping someone here can shed some light on it.

    I'm essentially trying to pan a texture across a surface in both directions at the same time, but have it masked by, in this case, the blue vertex channel. Directions would be controlled by a slider for scripting purposes.

    Wherever the blue value is 1, or 0, it works great. anything in between and I get garbage. I would expect this to blend nicely and just show a mix of both textures in motion. This is a simplified version of my shader, but I've narrowed it down to something in here: Any thoughts? badfoam.jpg sf_riverdebug_2102015.png
     
  26. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    Because you're blending the UVs, it's garbled. The proper way is one texture look-up for one direction and another for the other. Same rule for triplanar mapping. And water. Every time I see a garbled mess, I make sure I didn't do that with the UVs. Most of the time, I did. Is that the problem you're having?
     
  27. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    I've personally used SF shaders for terrain. RTP is shaders. It would be unreasonable to think that Shader Forge should dissect RTP's shaders to replace the snow shader. You might ask RTP's developer if it's even possible to replace the snow shader with any other shader. If I remember using RTP, everything is built-in and a bit difficult to customize.

    This makes sense, but it's a bit different if you're making derivatives instead of new code from scratch. That said, I'd gladly surrender all of my rights to any contribution I made to SF. There are some rare licenses out there that give the original creator complete ownership of all derivatives - might be worth having that spelled out for anyone that signs up to help.
     
    DMeville likes this.
  28. pixelquaternion

    pixelquaternion

    Joined:
    Jun 28, 2014
    Posts:
    122
    Hi IFL,

    Yes you are right and i was in doubt that it could be possible at all.

    I already ask Tom about replacing the snow shader and he told me that it would be mental madness plain and simple!

    The only thing he said that was possible is to tweak his own snow shader but yet i don't know how tweakable they are, we don't need very sophisticated snow shader since it is an online game but we would like to make it look the way we want like adding some sparkles effect and changing the hue that about it.

    I guess i will have to first install RTP and see what parameters are available to tweak it.

    Regards Peter
     
    IFL likes this.
  29. strich

    strich

    Joined:
    Aug 14, 2012
    Posts:
    374
    Would anyone able able to assists with the DDX and DDY nodes in Shader Forge?

    Apparently they can help solve the atlas border seam problem we're currently having:
     
  30. KaylMyers

    KaylMyers

    Joined:
    Mar 28, 2013
    Posts:
    33
    Looks like your texture needs to be set to Wrap Mode: Clamp. Might be that simple, but hard to tell without context.
     
  31. KaylMyers

    KaylMyers

    Joined:
    Mar 28, 2013
    Posts:
    33
    That seemed to work to work for me so far! Its an odd issue, seems like the math should work. Thanks!
     
  32. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    It works if it's either 0 or 1. If it's anything else, the coordinates will blend, for example, somewhere between -8000 and +8000, depending on how far the time variable have gotten, which could end up anywhere in the texture.

    I presume you want fluid-like blending and distortion, in which case I recommend looking into flow mapping :)
     
    IFL likes this.
  33. KaylMyers

    KaylMyers

    Joined:
    Mar 28, 2013
    Posts:
    33
    That makes sense. Thanks for the reply! Already got my flowmap shader ready for a different use, but for this one, since its specific for gameplay and a distinct look and functionality, it wont work for this application. Thanks for the suggestion though!
     
  34. jalapen0

    jalapen0

    Joined:
    Feb 20, 2013
    Posts:
    136
    Hello, just a small suggestion. Could you make a place on your wiki where people can post user created shaders created with shader forge? Be nice, especially for beginners that don't have any idea where to start.

    edit: actually if you are worried about people without shader forge accessing it, maybe some authentication where you need an invoice number to restrict access?
     
    Last edited: Feb 11, 2015
    IFL and donov like this.
  35. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    Thanks for the info. Let me know if you find out anything else.

    This page?
     
    jalapen0 likes this.
  36. jalapen0

    jalapen0

    Joined:
    Feb 20, 2013
    Posts:
    136
    Ok sure, but there is hardly anything in it. :)

    Come on people! ;)
     
  37. KaylMyers

    KaylMyers

    Joined:
    Mar 28, 2013
    Posts:
    33
  38. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    Alpha Blended, Write to Depth Buffer... Does that work?
     
  39. KaylMyers

    KaylMyers

    Joined:
    Mar 28, 2013
    Posts:
    33
    Unfortunately that wont work. Was the first thing I tried. But it hides all other transparent objects behind it in the scene. The above example doesn't write to the depth buffer, but still self-occludes.
     
  40. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    Well, I don't think that is possible with SF currently. Editing the code is the only way. If anyone knows differently, please correct me on this.
     
  41. Sonoshee

    Sonoshee

    Joined:
    Jul 8, 2014
    Posts:
    77
    Hello guys, I'd like to make a shader that imitates a shockwave on a 2D texture, similar to this :
    http://www.geeks3d.com/20091116/shader-library-2d-shockwave-post-processing-filter-glsl/
    I've been trying to figure out how to achieve the effect, but couldn't since I'm hyper new to shaders.
    Can anyone please screenshot a node tree of this shader, or better, attach the shader file ?
    Also, how can I use this shader so that it's triggered by an event ( mouse click for example) ?
     
  42. KaylMyers

    KaylMyers

    Joined:
    Mar 28, 2013
    Posts:
    33
    Well, we can get you started:) The whole give a man a fish, teach a man to fish kinda thing. The effect can be done either with refraction or vert offset, Both are on the main node in SF. Create a heightmap (2d texture node) that looks like a radial gradient going from white to black to white. Add a scaler node and scale it up over time. plug that into your refraction or your vert offset slot. You might need to do some research on how to use each of these nodes, but there is plenty of info around on that.

    As far as the mouse click thing, that will have to be done through script, and not part of the shader.

    That should at least point you in the right direction to get started. Dont give up, good luck!
     
  43. Sonoshee

    Sonoshee

    Joined:
    Jul 8, 2014
    Posts:
    77
    Ah, thanks a bunch KaylMyers!
    I've been toying with SF, I understood most of what you said, so I'll be giving it a try in the near time.
     
  44. rxmarccall

    rxmarccall

    Joined:
    Oct 13, 2011
    Posts:
    353
    Hello everyone,
    Just purchased Shader Forge, seems very powerful but the lack of tutorials is a little dissapointing. (Only 3 it appears). I'm mainly working on 2D projects at the moment and as such am trying to create shaders for 2D applications.

    I'm trying to achieve a simple drop shadow effect like seen here: http://forum.brackeys.com/thread/2d-shadowing-in-unity/

    Could anyone help point me in the right direction? Currently I've set my Texture 2D to Alpha Clip so my texture is transparent where it should be. I was then trying to use the Outline Width Node to possibly create a drop shadow but can't figure out what needs to be inputed into it.

    I'm brand new to shader forge and would be grateful for some help and direction, thanks!
     
  45. strich

    strich

    Joined:
    Aug 14, 2012
    Posts:
    374
    We have a bunch of shaders we wrote in Shader Forge and would like to upgrade to U5 deferred rendering. Can we do this with Shader Forge yet?
     
  46. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,502
    Personally I stopped doing U5 stuff with shader forge for now, after various things got changed in recent Unity 5 betas/release candidates which rather broke shader forge support (at least for me).
     
  47. ArthurClark

    ArthurClark

    Joined:
    May 12, 2013
    Posts:
    15
    I need to make a thing similar to Diablo 3 resource sphere (mana etc.). I've found an article (http://simonschreibt.de/gat/diablo-3-resource-bubbles/) on how to do this but that seams that this article is intended for more competent shader creators then me. I need to create a shader that takes a surface texture and makes it into a sphere (it will be a 2D game so using a simple 3D sphere with the texture is not an option). Can you show me the way of doing this in Shader Forge?
     
    Last edited: Feb 15, 2015
  48. reptilebeats

    reptilebeats

    Joined:
    Apr 28, 2012
    Posts:
    272
    yh shader forge is completly broke for me now to with U5, best wait till U5 is officially released for an update. One question will shader forge replicate unitys standard U5 Shaders as sort of a base starting point?
    i really like U5 standard shaders but as i have little knowledge of shader language its impossible for me to customize it.
     
  49. FreakForFreedom

    FreakForFreedom

    Joined:
    Jan 22, 2013
    Posts:
    156
    Got the same problem, am currently staying on b18 because everything higher breaks shader forge and oh now, I can't live without it ;)
     
  50. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,502
    I was trying this before too much changed in Unity 5 betas and ShaderForge stopped working. It wasnt perfect, but I was getting close without too much effort, so I am fairly confident it will be quite easy once ShaderForge is fixed for Unity 5.
     
    TechnicalArtist likes this.