Search Unity

Shader Forge - A visual, node-based shader editor

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

  1. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    Shaderforge is not without bugs. The first place to check for Errors is the console log in your Editor.
    It tells you at what line of the shader code the error appears. If there are multiple Errors your best bet is the first line the log mentions - everything thereafter are most likely subsequent Errors.
    In case of your shader I have a suspicion that it might be the ScreenPos node. I haven't tried your graph but I suspect Shaderforge to generate that variable inside the Fragment shader whereas you Need it in the vertex shader to make use of it for vertex offset.
    What can you do? Fix the code manually and move the screenpos calculation into the vertex shader (actually: there already should be the nessecarry code inside the vertex shader - you just have to use it).
     
  2. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    Without seeing your graph and your shader settings (left panel) it is nearly impossible to tell what went wrong.
     
  3. imDanOush

    imDanOush

    Joined:
    Oct 12, 2013
    Posts:
    368


    To make everything simple, I didn't use normal and specular maps for each diffuse and instead I used one specular and one normal map for this material. (As you've noticed, there are 2 diffuse maps).
     
    Last edited: May 15, 2015
  4. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    You are comparing your shading to the standart Unity shading which as of Unity 5 is based on a Metallness PBR lighting whereas your shader seems to be based on blinn/phong lighting. That's default for a newly created shader in SF.
    To get similar results to the standart shader you should switch your [Lighting...] to physically based lighting (left panel).
    Else you will have a hard time getting anywhere near Unity's look.
     
  5. Hoop22

    Hoop22

    Joined:
    Jul 3, 2014
    Posts:
    3
    Hello, everyone,
    I am just wondering how to forge a shader which is applied to a transparent plane, and still keep shadows casted from other object.

    I guess for achieving it, 3 steps have to be done, such as
    1) Get the shadow and keep it (RGG)
    2) Get the plane layer and make it transparent
    3) Merge the two layers above tegother.

    I don't really know if my idea is ok.. If it is ok, I still don't know how to start it.....
    Pretty new to shader forge..

    Could anybody give me any ideas please?
    Thanks a lot!
     
  6. AkiLap

    AkiLap

    Joined:
    Sep 14, 2014
    Posts:
    24
    @D4N005H, try adding Multiply node between Specular mask( your texture2d node 1296) and specular end point. Input A = rgb from specular texture, input B = slider with range 0 ... X. So you can change specularity.
    You should probably add a Gloss texture aswell with similar setup and link it to Gloss end point.
     
  7. imDanOush

    imDanOush

    Joined:
    Oct 12, 2013
    Posts:
    368
    Yep, thanks. But it reflects a lot of light from the sunlight (please have a look at the right road, the road reflects way less light than the left road - the left road is SF and the other one is using the standard Unity3D shader) , How would I change the strength of Normal map and specular map? should I change the strength of other parameters to achieve a realistic look for the road? how?

    Sorry for asking too much,though.
     
    Last edited: May 15, 2015
  8. imDanOush

    imDanOush

    Joined:
    Oct 12, 2013
    Posts:
    368
    Thanks for your reply, I just tried what you said and set max=10 and set slider to max, in the shader preview I noticed that sliding the spectacular map to max caused the object to look like a chrome ball but in the scene nothing changed:
    However I have no idea how to make a gloss texture and assign it to the material, would anyone help and say what should I do to make and add the texture to the material?

     
  9. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    909
    thank's Marco you right it's look that's

    she look for i on vertextInput
    float2 node_1182 = (float2(i.screenPos.x*(_ScreenParams.r/_ScreenParams.g), i.screenPos.y).rg*0.5+0.5);

    Shader error in 'Shader Forge/Examples/Animated Vegetation': undeclared identifier 'i' at line 51 (on d3d11)
    Compiling Vertex program with DIRECTIONAL SHADOWS_OFF LIGHTMAP_OFF DIRLIGHTMAP_OFF DYNAMICLIGHTMAP_OFF

    but for fix that's at my level it's can be hard for exemple i have try line on VertexOutput
    and now she requiert VertexInput
     
  10. AkiLap

    AkiLap

    Joined:
    Sep 14, 2014
    Posts:
    24
    You have to change the slider value in inspector, because sometimes when setting it in shaderforge it doesnt update to the real material shader you got.

    As you see in your image, that slider value is sitting at 0.
     
    IFL and imDanOush like this.
  11. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    @D4N005H please read up on physically based lighting in Unity to better understand what is required in ShaderForge - because both are using the same concepts.
    A fully functional PBL material that mimicks Unity's standart shader requires at least an albedo/base color (diffuse in deprecated terminology) term, a metalness term and a gloss term.
    So when you switched your lighting over to PBL the main node in SF changed to reflect these needs. To get the same results as with the standart shader all you have to do now is to plug in the same textures into the correct main node inputs.
    Please keep in mind though that the textures you are showing indicate to me, that you have not fully grasped the concept of the standart shader. So I rephrase my initial sentence: please take a look at the manual to understand physically based shading and rethink your textures. You will probably Need an Albedo map, a normal map, and a metallness map (of which the last one can also contain your glossiness for example inside its Alpha channel).
     
    IFL likes this.
  12. imDanOush

    imDanOush

    Joined:
    Oct 12, 2013
    Posts:
    368
    Very big thanks guys, I've almost got every thing to know. It's sooooooooooo interesting I love it. Thanks guys. Here is a screen shot! Unity's standard shader and Shader Forge's shader is impossible to be distinguished from each other now! Download link of the material is here.
     
    Last edited: May 15, 2015
    Ga2Z, IFL and AkiLap like this.
  13. imDanOush

    imDanOush

    Joined:
    Oct 12, 2013
    Posts:
    368
    Okay I will read it. Thanks for your reply. I am very new to this technology, so I don't know lots of the related concepts exactly.
     
  14. jjason08

    jjason08

    Joined:
    May 13, 2015
    Posts:
    15
    That is exactly what I needed, I knew I was over thinking the whole process thank you for the advice and the amazing shader. I look forward with learning a lot from you and the rest of the community. Ill try and keep up to date on the forum, and i appreciate you allowing me to talk more about shaders in the future.
    Thank you
     
    IFL likes this.
  15. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    I think edge-length-based tessellation is inverted, so the closer to 0 (or 1...?), the more dense the tessellation becomes. It has a limit though, which I despise and makes it pointless in some situations means you can't have a large, low-poly mesh with a decent amount of detail close to the camera.

    Having looked into Ori, I think you just have to set the emission and add bloom to the camera. If it's more complicated than that, you can set up an additional camera to render the glowing areas (have a "glow" layer and use layer masking on the camera), and then create a custom post-effect to combine that with the main camera. That method requires some scripting though.
     
  16. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    909
    sure :)
    any tutorial or info about global variable somewhere's please
     
  17. djweinbaum

    djweinbaum

    Joined:
    Nov 3, 2013
    Posts:
    533
    Does anyone noticed a conflict between alpha cutout, transmission/light wrapping, and SSAO? The default SSAO, Sonic Ether's SSAO, and SSAO pro all do this same weird see-through business, so I suspect the issue is with Shader Forge:

    artifact.jpg
     
  18. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    Does it work if you turn off Auto-sorting and set the Order to anything >=2501?
     
  19. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    909
    i try use light pos. and object scale for value setting and this not working i must use math convertion ?
     
  20. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    I don't have any issues when using LightPosition and/or ObjectScale. I'm not sure what you're asking.
     
  21. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    909
    yes after retry it's look when got more one object maybie must instanciate shader for fix that's
    light pos result more play on light rotation for exemple when i try
    distance obj and light http://puu.sh/hPwSr/3f4c472e3e.png

    with deep is too strong http://puu.sh/hPx8q/50182616be.png
    i try divide or multiplie value for fix that's this look return math.floor or not same value
    in faq i just play and search for see what's it's can do
     
  22. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    Oh! Okay. I think you're experiencing batching. Static and dynamic batching combines objects so that less has to be sent to the graphics processor. When it combines the objects, the ObjectPosition node in Shader Forge becomes almost useless. Alternatively, you can use WorldPosition to get the position of each batch's fragments or just turn off the static and dynamic batching in the Player Settings.
     
  23. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    This. Unity creates a new mesh from all your static meshes that share the same material. You cannot rely on object position or object scale anymore if you need these variables per object. Only chance is as IFL said to make them dynamic (which in return breaks batching - you'll have to consider what's best for your game in terms of performance).
     
    IFL likes this.
  24. Ga2Z

    Ga2Z

    Joined:
    Feb 16, 2012
    Posts:
    68
    Hey, that's really cool but I think you meant to share the .shader not the material because it has no info without a shader hehe.
     
  25. djweinbaum

    djweinbaum

    Joined:
    Nov 3, 2013
    Posts:
    533
    No luck but thanks for the suggestion I hadn't tried that. It looks like the bug might be on Unity's end. @xenius pointed out in another thread that forward shaders (maybe just ones with cutout?) may not be writing to CameraDepthNormals texture properly.
     
  26. imDanOush

    imDanOush

    Joined:
    Oct 12, 2013
    Posts:
    368
    Hmm LOL, I modified ".shader" file several times and it's not worth sharing. but I think you can see what's going on in the material by opening it with the button which is shown below,though:
     
  27. jermaineatl

    jermaineatl

    Joined:
    May 4, 2014
    Posts:
    9
    Still was wondering if anyone knew how to tackle this. While i was looking for tips i came across people using matcaps. I was wondering if this could be achieved through the shader they used?
     
  28. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    Shader Forge stores almost everything in the Shader. The Material is just a set of properties and settings.

    Can I get the name of the source of that image? I don't recognize it.
    [EDIT::] Never mind. It's Killer is Dead.
     
    Last edited: May 17, 2015
  29. Chaosgod_Esper

    Chaosgod_Esper

    Joined:
    Oct 25, 2012
    Posts:
    295
    Hi there.. got a small problem..

    I want to create a shader with the following specs:
    • Texture
    • Normalmap
    • Specular Map
    • UV shift/panning
    • Dissolve
    • Glow

    And got the following problems:
    1.) SOLVED
    The Normalmapping isn´t working nice - or not at all.
    The Texture: Directlink
    The Normalmap: Directlink

    Now the result looks like this: Directlink
    As you can see, the Ground has the normal Bumped Specular Shader from unity attached. The Plate Object has my own. And even if i rotate the Object, light or Change material settings during runtime - there´s no normalmapping or glossiness visible.

    2.)
    The Dissolve behaves strange. Currently, it´s working from -1 (transparent) to 1 (full visible). Problem is, that the Object starts appearing at -0.6. Which means, that between -1 and -0.6 nothing happens.
    So my Question is:
    Has SF problems with pure black color or such a thing? Ot why isn´t it starting to make the object visible right at -0.99?

    3.) is a not implemented Feature yet.
    How can i make a Smooth glowing? Cause the abstract Area on my Plate (shown on the Result screenshot in 1.) should glow a bit.
    I know theres a "Outline Width" Field in SF. But the Edges of the outlines are hard, not smooth like glowing light...
    If that´s not possible with SF, can you guys guide me a solution that works with this Shader?


    heres my Node tree:
    Directlink

    I hope you guys can help me out here, cause i really need that shader to work :)
     
    Last edited: May 17, 2015
  30. Morfeuskiev

    Morfeuskiev

    Joined:
    Oct 10, 2013
    Posts:
    122
    @Chaosgod_Espér
    1) If you want to use normal map - you must to enable in texture sampler - so that is normal map!!!
    2) For disolve you can use Step a<=b
     
  31. Chaosgod_Esper

    Chaosgod_Esper

    Joined:
    Oct 25, 2012
    Posts:
    295
    But step only returns valies of 0 or 1 and nothing inbetween, isn't it?
    So for a dissolve effect based on a dissolve map, it's not working...
     
  32. DMeville

    DMeville

    Joined:
    May 5, 2013
    Posts:
    418
  33. Ga2Z

    Ga2Z

    Joined:
    Feb 16, 2012
    Posts:
    68
    Yes, as IFL said, the shader info is really in the .shader file and the material doesn't have any interesting info on its own :p

    In other topic, I've been following this thread and I don't think I've seen anything about using light probes in shader forge. I'd like to ask how could I get the light probes info in my shader? or maybe if somebody can point me in the right direction for a node that allows me to work with light probes. I looked into the Shadowgun shaders and the BDRF for the character but it goes beyond my shader knowledge by far :(
     
  34. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    You simply use the R channel for glossiness along the Tangent, and the G channel for glossiness along the Bitangent.

    Saw this at GDC - I heavily recommend watching the entire talk, but the relevant bits are around 42:00 and onward:
    http://www.gdcvault.com/play/1021771/Advanced-VR :)
     
  35. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    There's a checkbox in the lighting settings for enabling it, though there's no specific node for accessing the probe data
     
  36. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    Interesting talk, thx for sharing, Ace.
     
    DMeville likes this.
  37. Ga2Z

    Ga2Z

    Joined:
    Feb 16, 2012
    Posts:
    68
    Yes thanks. But I already knew it, so if I have an Specular-Normal shader I only get a plastic-matte look on my object, there's where the magic happens on Shadowgun shaders but I don't know where to start to replicate such effect with shader forge :( sorry if didn't elaborate more. The real question would be: how could I make a shader that uses light probes and keep the specular and normal mapping looking good (or at least correct) using shader forge nodes? Thanks for your early replies :)
     
  38. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    Nice find Ace !
     
  39. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    It should be fine as long as it's set to PBR and you're giving it correct data
     
  40. Deleted User

    Deleted User

    Guest

    How can i expand/contract a mask, i want to get the in-between value between a contracted and non contracted mask, so i can put a transitional texture in the space there would usually be blur.

    I have tried rounding, but that makes the edges of the mask to hard.
    If only there were something similar to Gaussian blur...
     
    Last edited by a moderator: May 25, 2015
  41. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    I presume you want to mask out the part of another mask that have grayscale values, ie, non-white and non-black.

    Try this:

    ( mask - 0.5 ) * 2.01 -> Abs -> Floor -> OneMinus
     
    Deleted User likes this.
  42. gfunk

    gfunk

    Joined:
    Mar 17, 2015
    Posts:
    23
    Hey guys - how do you correctly plug in the AO map? It seems it only takes the alpha output to the main shader node (why not RGB?) and it doesn't seem to make any difference when plugged in like that? Should I multiply with Diffuse and plug it into the albedo socket? I'm a bit confused - thanks for any input!
     
  43. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    AO is currently grayscale, which means you need to connect a value with a single component. Usually, you use the red channel or the alpha channel of an AO texture. AO will automatically handle the diffuse color :)
     
  44. gfunk

    gfunk

    Joined:
    Mar 17, 2015
    Posts:
    23
    Thanks, works fine! The only thing I would like to do now is to control the intensity of the AO... How would I go about that? Thanks!!
     
  45. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Make a lerp node, plug your AO map into A, then plug a value node of 1 into B, and a slider into T, then use the lerp output as AO
     
    Last edited: May 26, 2015
  46. gfunk

    gfunk

    Joined:
    Mar 17, 2015
    Posts:
    23
    Thanks so much, works great!
     
    Acegikmo likes this.
  47. Sinaz20

    Sinaz20

    Joined:
    Nov 16, 2009
    Posts:
    53
    I'm tried searching the forum thread-- but I'm having trouble discovering if there is any documentation on recreating the stock Unity shaders in Shader Forge.

    I know-- "why recreate them?" Well, because we have a few assets that are using some of the more complicated unity shaders (like Bumped Specular) and I need to add some custom tweaks into them-- however, I can't seem to get my scratch version to look the same as the stock version (even with lights doubled.) I can't quite figure out where I'm going wrong.

    Simply, if I could have some documentation on this, it would go a long way, especially for new users.
     
  48. AkiLap

    AkiLap

    Joined:
    Sep 14, 2014
    Posts:
    24
    Planet shader I made up yesterday for my upcoming game

    I cannot share the node view, but it mainly consist of:
    - One texture for planet diffuse, I create other textures like specular and sea detailing with nodes in shader, sea expecially is desaturated from main tex and then modified to enchance only sea color
    - Light dir/View ref specularity set (dot with positive range, and power)
    - Custom NdotL which multiplies with land and seas diffuses.
    - Edge is quite basic fresnel approach

    Short gfy (random naming ftw):
    http://gfycat.com/PeacefulDefiantAss

    Fullsize png:


    Next in my shader work list are better atmosphere effect on edge, and a cloudlayer. :)


    Got to say I'm in love with this sweet tool, thanks Ace!
     
    Acegikmo likes this.
  49. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    It's fairly trivial to do this. If you're in Unity 5, do this in SF:

    Enable PBL in lighting settings
    Enable baked lighting/light probes/lightmapping
    Make sure it's set to metallic or specular, depending on which workflow you want to use

    The rest is pretty self-explanatory. Plug in the features you need in the node tree :)
     
  50. Sinaz20

    Sinaz20

    Joined:
    Nov 16, 2009
    Posts:
    53
    Heh-- you say this... and yet, I cannot figure out how to remake the bumped spec shader. My problem is that I don't know specifically how the properties are interacting. The shader code is too dense and full of generic variable names to plot manually.

    When I look at my results in the engine, it looks entirely different, and in no obvious way as to help me discern what I have mis-connected.

    At least... I was able to get the appropriate property names and limits for ranges from the shader code... but the rest... whoosh.