Search Unity

Shader Forge - A visual, node-based shader editor

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

  1. ronan-thibaudau

    ronan-thibaudau

    Joined:
    Jun 29, 2012
    Posts:
    1,722
    Haven't made the plunge yet but about too, last question before i do, this just gens shaderlab shaders right nothing special? (can just generate one and hand edit it if i so wish?)

    Are they human readable or compressed piles of junk to the human eye? Could you post a very simple sample shader here for the example (just 2-3 nodes, any of them, as well as the shader output?)

    Thanks!
     
  2. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    Yes it generates shaderlab surface shader cg code. It's not commented much, but you can edit as you wish. It's normal code.
     
  3. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    Very cool, I like it.
     
  4. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    I've tried to make it as readable as possible, but it's not always ideally constructed. Here's an example anyhow :)



    http://pastebin.com/hqWp7Pp2


    A little correction - it doesn't generate surface shader code, it generates CG code
     
  5. donzen

    donzen

    Joined:
    Oct 24, 2009
    Posts:
    54
    Thanks for sharing it!
     
  6. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Another new node coming in 0.24 :)

     
  7. donzen

    donzen

    Joined:
    Oct 24, 2009
    Posts:
    54
  8. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,142
    I'm super tired, so I can't quite interpret this. What exactly am I seeing here?
     
  9. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    It's a triplanar shader, where textures are mapped to the surface with world coordinates, blended by the normal direction per-axis :)
    The "Channel Blend" nodes to the left of the pillar of textures are the new ones
     
  10. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Shader Forge Beta 0.24 now released:
    • Added node: Channel Blend. This has a mask input, and outputs the sum of each mask component multiplied by the corresponding color input. Useful for triplanar blending
    • Added node: Noise. This will generate a pseudorandom number based on a Vector2 input as a seed
    • Specular Ambient Lighting now uses the fresnel term when PBL is on
    • The physically based lighting mode is now more accurate. Increasing specularity will now decrease diffuse
    • The 3D preview will now use the scene skybox as a background by default
    • The 3D preview will now rotate the camera around the mesh, instead of rotating the mesh itself
    • Comments on nodes will now be displayed in the shader code when a node is used multiple times
    • You can now set the ScreenPos to SceneUVs, to use as Scene Color UVs, which is useful for chromatic aberration, and other effects
    • The settings panel expanders now move smoothly and has cleaner code
    • Checking the Normal map checkbox on Texture 2D nodes will now switch the default value to Bump
    • Fixed a bug where only the first mesh you select for the 3D preview is applied
    • Fixed a bug where sliders didn't save their default value in the shader
    • Fixed a bug where Texture2D nodes marked as normal maps had an alpha output (This is due to how Unity decodes their normal maps)
    • Fixed a bug where you couldn't use object position in vertex offset
    • Fixed a bug where labels sometimes got the wrong horizontal alignment
    • Fixed a bug where you could right-click on nodes through the side-panels
    • Fixed a bug where the drag cursor in the settings panel appeared when hovering properties, when only a single property was present
    • Fixed a bug where normals weren't normalized in some cases when using a normal map

    Click to see all changelogs

    (Don't forget to delete the old Shader Forge before updating to this one!)
     
  11. aegget_

    aegget_

    Joined:
    Oct 30, 2012
    Posts:
    33
    Hello! I'm trying to create a flat surface shader in shader forge but I don't really know where to start. I have no experience creating custom lighting and I have searched all over and can't find any info on how to go about creating that effect. Does anyone know how to do this or where I can find a tutorial or some sort of instructions to get this working? Thanks!
     
  12. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    If by "flat surface shader" you mean, the low-poly faceted look, then that's not done on a shader level, that's usually done in the model itself. Make sure each face has hard edges all over, to get that look :)
     
  13. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Here's how the new Channel Blend node works:

     
  14. ForceX

    ForceX

    Joined:
    Jun 22, 2010
    Posts:
    1,102
    Ok Shader Forge is the most amazing thing scenes sliced bread! Unity team needs to hire you and make this part of Unity ASAP. These updates and new nodes are phenomenal.
     
  15. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    Can you add an RGBA output from the texture2d so that rgb and alpha dont have to separately be appended?
     
  16. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    I suppose, but I don't think it's worth it, given how rarely RGBA is used and the added interface clutter/added complexity for the majority who won't use it
     
    Last edited: Feb 16, 2014
  17. aegget_

    aegget_

    Joined:
    Oct 30, 2012
    Posts:
    33
    Haha well now I feel stupid :D I always though it was done in the shader. That actually makes more sense.

    Well I have another question. I'm trying to recreate this shader.
    I can't seem to get it looking right and I bet its because I'm probably getting the light and reflection vectors wrong.
    What is the shader forge equivalent of these nodes?
     
  18. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    The only thing you need to change, is the vector 0,1,0, that is marked as NormalMap, to the Normal Direction node in SF. (I think)
     
  19. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,142
    Maybe you could add a checkbox to the Texture2D node that says "Append Alpha" or something similar? That'd probably be a decent compromise.
     
  20. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    If I were to implement it, it would probably be RMB on the RGB output connector, to open a menu where you can pick if you want RGB or RGBA. Adding another checkbox would make the Texture2D node even taller, which I want to avoid, since it's already tall as it is
     
  21. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,142
    Yeah, I completely forgot it has the default colour drop down on top of the normal map checkbox for some reason.
     
  22. Cynicat

    Cynicat

    Joined:
    Jun 12, 2013
    Posts:
    290
    Hey i have a question. i'm thinking of a cool method to make volumetric smoke similar to Unreal Engine 4. but in order to do it i need to do things like custom lighting with transparency and getting the view depth of pixels. i've been trying to make it and i have been running into problems. i tried to make a custom lighting model with it only paying attention to light falloff and shadows(giving that depth smoke effect) and i keep running into lighting issues. like it staying really dark and such. couldn't find a node that gave me the pixels position on the z buffer. which i want to fade the smoke when you get closer to it. also good for sun shafts. not sure if its possible but if it is i would love to share the shader when i'm done. thanks ahead of time. : )
     
  23. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    You can check the distance between the view position and the world position of the pixel, using the two nodes with the same name, and the distance node
     
  24. Cynicat

    Cynicat

    Joined:
    Jun 12, 2013
    Posts:
    290
    Awesome your a life saver thanks. also turns out the lighting problem i was having with the particles is related to the particles being tweaky with surface shaders.
     
    Last edited: Feb 17, 2014
  25. Lockestone

    Lockestone

    Joined:
    Feb 8, 2014
    Posts:
    3
    Sorry for the late response, thanks for looking into this. Being able to manipulate the lightmap through shaderforge would be cool too! :)

    Keep up the awesome work!
     
  26. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Someone at Polycount asked how to do gradient mapping with multiple gradients, so, thought I could post the node tree here as well :)

     
  27. Airborn-Studios

    Airborn-Studios

    Joined:
    Oct 31, 2012
    Posts:
    30
    awesome!
     
  28. kaz2057

    kaz2057

    Joined:
    Jan 18, 2011
    Posts:
    326
    I see that Shader Forge support IBL map from Kyshop.

    But it is possibile modify Marmoset Skyshop default shader to add for example a dissolve node?

    Thanks
     
  29. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    You can make a SF shader that works like the Skyshop built-in shaders, and then add dissolve functionality to them if you like.
    You can't modify their shader with SF though.
     
  30. kaz2057

    kaz2057

    Joined:
    Jan 18, 2011
    Posts:
    326
    In the future with SF will be possile modify existing shader like Skyshop?
     
  31. mostafahafez

    mostafahafez

    Joined:
    Jan 13, 2014
    Posts:
    4
    Are you going to support deferred lighting in the near future?
     
  32. Airborn-Studios

    Airborn-Studios

    Joined:
    Oct 31, 2012
    Posts:
    30
    if marmoset would rewrite their shaders so they are readable for shaderforge, possible. But otherwise i don't see how this is supposed to work - that would mean reading any shader and rearranging it to a system that follows the ruleset of shaderforge - too much work to be honest.
     
  33. Monkee

    Monkee

    Joined:
    Sep 3, 2012
    Posts:
    8
    I tried this in strumpy shader editor a while back, and was so terrified by the fps drop I havent tried in since.

    I haven't even tried Shader Forge yet for this purpose but there is different ways to do it I believe? One way is direct into the refraction component of the master node, the other is using a render to texture, both using R and G values to offset the pixels. Has anyone made just a simple refration shader that works well on mobile?

    If someone could point me in the right direction id be really happy and thankful,

    eitherwise a great tool Shader Forge is and its awesome to meet fellow node shader artists :D
     
  34. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Yes, but I don't know when! The thing is, I've heard rumors that the deferred system in Unity will change soon, so I'm waiting for that, to avoid having to do twice the amount of work. Deferred is a huge topic, so, I wouldn't want to do it twice :)
     
  35. ronan-thibaudau

    ronan-thibaudau

    Joined:
    Jun 29, 2012
    Posts:
    1,722
    Just purchased, definately fits my need, however small nitpick, you should reallllyyyy add a camera to the sample scene (even if just a static camera object that shows the whole scene from perspective), when i load an example project hit run i kinda expect to see something :)
     
  36. mostafahafez

    mostafahafez

    Joined:
    Jan 13, 2014
    Posts:
    4
    Thanks for the quick reply.

    Currently I'm creating a triplannar shader for voxel terrain and I'm using PBL, The problem is that the shader wants tangents and the voxel mesh generator doesn't output uvs nor tangents, is there a work around for that?
     
  37. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Disable lightmaps, or add tangents to the mesh. There are scripts for that on the net, Google should help :)
     
  38. ronan-thibaudau

    ronan-thibaudau

    Joined:
    Jun 29, 2012
    Posts:
    1,722
    Actually i see in the sample the smoke is very diferent from the one in the first page of the thread, any chance you could share that sample? (the one included is some dx tess shader on a single object, not smoke running within a torus but more like dispersing on the surface, not quite the sample i'm looking for, i really like the 1st page effect!)
     
  39. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    It's the same shader, there shouldn't be any difference, apart from the lighting in the scene
     
  40. ronan-thibaudau

    ronan-thibaudau

    Joined:
    Jun 29, 2012
    Posts:
    1,722
  41. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Looks correct to me, apart from the lighting
     
  42. ronan-thibaudau

    ronan-thibaudau

    Joined:
    Jun 29, 2012
    Posts:
    1,722
    Actually you're right, since the colors (smoke vs rest) are much more diferent in the original shot i didn't realise it was smoke sliding over the object (and not running Inside a semi-empty torus), my bad!
     
  43. ronan-thibaudau

    ronan-thibaudau

    Joined:
    Jun 29, 2012
    Posts:
    1,722
    Any chance we could "flip" the node graph? i'd feel a lot more comfortable left to right than right to left when composing going from what i start with to the left flowing into the final result to the right?
     
  44. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Not at the moment no
     
  45. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,521
    Can you clarify what deferred mode not begin supported actually means?

    Does it simply not work at all in deferred? Does it work, but with artefacts? Are only specific features incompatible with deferred while other features work fine?
     
  46. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    http://acegikmo.com/shaderforge/faq/?Q=deferred#deferred
     
  47. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,521
  48. Cronos000

    Cronos000

    Joined:
    Nov 27, 2012
    Posts:
    3
    Hey is there any way of getting the Projection matrix from Projectors into Shader forge Shaders?
     
  49. metlapig

    metlapig

    Joined:
    Sep 24, 2013
    Posts:
    3
    I did want it per particle to I can increase the random patterns in my smoke, which is created by a noise perturb and noise alpha, which can be animated. The unfortunate part is that all particles will move and look the same (although scaling helps). I guess I'll just have to modify the offset in a component script on the particle system.

    Thanks for the ideas!
     
  50. Deathnote

    Deathnote

    Joined:
    Nov 26, 2013
    Posts:
    52
    Acegikmo, Can I write to you, what a tutorial I need, and you could have told me how to do it

    thnks
     
    Last edited: Feb 18, 2014