Search Unity

Shader Forge - A visual, node-based shader editor

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

  1. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Unity re-encodes your normal maps to use the G and A channels for the X and Y directions, and reconstructs Z on a shader level when unpacking normals. The alpha channel is dropped for this reason.

    However, if you flag your normal map as a regular texture, and in the shader, don't mark it as a normal map, and do a Remap Range node, with parameters from (0,1) to (-1,1), and then a normalize node, I think you'll be able to keep both the normals and the alpha channel. Though you would have to do this for all normal maps to be used with that shader in particular
     
  2. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    I had planned to do more tutorials today, but the neighbors have been working with loud tools, so I'll have to push it to wednesday.

    So instead of a new tutorial - here's a little preview of what's coming in 0.20!

     
  3. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    What is that, some kind of depth-buffer thing?
     
  4. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    Looks like the equivalent to the "depth biased alpha node" from UDK material editor. Does that mean we can get access to depth texture as well? Separate from the depth blend node? Would be awesome!
     
  5. MarkBenitez

    MarkBenitez

    Joined:
    Oct 5, 2013
    Posts:
    44
    In the next release can you please include the feature of having a square or custom mesh in the node preview where the sphere is

    To see how a shader looks on different meshes quickly
     
  6. Chaoss

    Chaoss

    Joined:
    Jul 8, 2011
    Posts:
    327
    Your awesome! because I came into this thread about to post a request for that EXACT feature (could be used for volume fog), does or can this work on a radial from view? the current fog shader seems like it's 'flat' and as such rotating your view reveals things in the fog that would be hidden when looking straight on.

    No, it's sorcery
     
  7. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    It's pretty much like the Depth Biased Alpha node from UDK, yes :)
    (And there is a node for scene depth now too)

    This is already possible - click the little circle above the mesh/shader preview :)

    Possibly! I haven't had a closer look at how it handles radial vs linear.
     
  8. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    AFAIK if you click above the sphere where it says `sphere` and shows a little icon next to it, it takes you to an object browser and you can choose other meshes to preview with. Not sure if it supports custom meshes or just some built-in primitives but I'm pretty sure ShaderForge comes a set.

    oop.. you already replied to this, lol
     
  9. Don-Gray

    Don-Gray

    Joined:
    Mar 18, 2009
    Posts:
    2,278
    Any mesh:

    $load_mesh.jpg

    Found a few that don't work, but most do.
    Often have to close and reopen the mesh selector to get another mesh to show.
     
    Last edited: Jan 21, 2014
  10. twoc46

    twoc46

    Joined:
    Jul 10, 2012
    Posts:
    7
    We are not worthy!
     
  11. TheRunningDafini

    TheRunningDafini

    Joined:
    Oct 24, 2013
    Posts:
    1
  12. Deathnote

    Deathnote

    Joined:
    Nov 26, 2013
    Posts:
    52
    Hi, Acegikmo

    if i buy shader forge, next updated will be free ?
     
  13. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Awesome!
    I will have a look in a bit :)
    Also, I'll still do a full tutorial series, and there will most likely be some overlap with your tutorials, just so you know!

    Yes!
     
  14. JoeW97

    JoeW97

    Joined:
    Nov 3, 2013
    Posts:
    56
    Thanks for the explanation :)

     
  15. Deathnote

    Deathnote

    Joined:
    Nov 26, 2013
    Posts:
    52
    Acegikmo, u doo realy good job, we now can sad than Unity 3d like UDK or CryEngine )) we alsou have shader AAA Clases ) its great )
     
  16. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    829
    Absolutely brilliant product, I especially like how much love the interface was given with all those curved per-channel links, snapping and whatnot. Head above UDK interface.

    Had a question, by the way. Attempted to make a triplanar shader with parallax mapping. Diffuse triplanar shader was simple enough and worked well, but I messed up something while adding parallax referenced from example parallax shader. Can someone take a look at this? Not sure how to make it work, in particular where normal maps are currently handled wrong and where should I link the UV output of the Parallax node.

     
    Last edited: Jan 22, 2014
  17. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    I think you'll want to connect the parallax outputs to both the three normals (as you've already done), and into the UV inputs of the diffuse textures.
    Then you'll need to normalize the normals after adding them all together.

    Also, you can connect more than two inputs into the Add/Multiply nodes :)
     
  18. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    829
    Oh, thanks a lot! It compiles properly now, and almost works. I think the parallax direction is wrong somewhere, though, as surfaces look like they are smeared horizontally, away from the camera, instead of being shifted up and down. Here are screenshots with Depth value set respectively to 0, 0.25, 0.5 and 1.0.






    Are those telling anything about the source of the issue?

    I guess it might have something to do which Parallax nodes I connect with which diffuse UV inputs. At the moment RG goes to X, RB goes to Y and GB goes to Z. I'll a few other configurations. Edit: Nope, not UV inputs, changing the order there makes it worse. Will look elsewhere then.

    Edit2: Couple more screenshots. It seems to be rendered differently through the Game view camera, which is a bit weird, although I've noticed it before with some other shaders. Floors still look weird, but artifacts on them are vertical as they should be, while walls have a different "whirlwind" distortion:





    Edit3: Reorganized it, much easier to read now.

     
    Last edited: Jan 22, 2014
  19. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Are you on deferred or forward rendering?
     
  20. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    829
    Forward.
     
  21. Deathnote

    Deathnote

    Joined:
    Nov 26, 2013
    Posts:
    52
    Acegikmo, can u help ?

    I cant understud, how create Shader like crystal or ice crystal
     
  22. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    829
    Transparent shader with some cubemapped reflections and/or refraction, pretty simple thing and mostly relies on well-made textures if you want it to look realistic.
     
  23. Deathnote

    Deathnote

    Joined:
    Nov 26, 2013
    Posts:
    52
    Thy, will try, if will have some trauble, can u help me ?
     
  24. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    829
    Ha. Tried another simple texture and upon closer examination, it looks like the "noise" was the heightmap that for some reason is overlayed with very small tile size. I guess I should add another multiplier to the UV output of Parallax before sending it to Diffuse texture input, or something?



    Sure.

    For crystal/diamond-like look, don't use any smoothing in geometry or normalmaps for refraction, and for ice/uneven glass use normalmaps with random distortion and smoothed geometry. 0.20 will also probably help with it's depth-related nodes as you will probably be able to get ice more opaque depending on object thickness.
     
    Last edited: Jan 22, 2014
  25. zelmund

    zelmund

    Joined:
    Mar 2, 2012
    Posts:
    437
    hello Acegikmo. Can i made a shader for post effect using shader forge ? i mean shaders like built in image effects.
     
  26. MarkBenitez

    MarkBenitez

    Joined:
    Oct 5, 2013
    Posts:
    44

    Attached Files:

  27. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    829
    I think I figured it out. Tiling is no longer a problem, turns out I reproduced a part of the sample parallax shader incorrectly, never using Texture Asset node as I should have, which led to parallax using UVs embedded in the mesh instead of ones generated for triplanar mapping. Fixed that, here's how it looks now:



    Now, I wonder how to turn it into steep parallax mapping/parallax occlusion mapping? :p

    http://udn.epicgames.com/Three/DevelopmentKitGemsParallaxOccludedMapping.html
    I guess the example from here would work but relies on depth-related nodes arriving in 0.20, correct?
     
    Last edited: Jan 22, 2014
    URocks likes this.
  28. Doddler

    Doddler

    Joined:
    Jul 12, 2011
    Posts:
    269
    I must be completely blind, but is there a way to disconnect a connection once it's been made without removing the object?
     
  29. Deathnote

    Deathnote

    Joined:
    Nov 26, 2013
    Posts:
    52
    i do it later)) cuz i cant do cool terrain shader o_O.. can u explain me how it do ...

    i try do whit myltityp

    ty a lot for help
     
  30. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    You can! But post FX usually rely quite heavily on for loops and iteration, which SF is currently not built for at all. When the custom code node makes it in though, it'll be much easier :)

    Not without altering the mesh itself. You need to have soft edges for that, hard edges are split on a vertex level, so they don't stick together.

    Three ways:
    1. Hover cursor over connector and press backspace
    2. Hover cursor over connector, hold alt and click RMB
    3. Click and drag RMB while holding alt in empty space, to start drawing a cut-line across connections
     
  31. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    829
    You most definitely can create a terrain shader with Shader Forge, with multiple maps, splats and all. Although if you want something very complex and optimized to the very limits of what DX9 can do, I recommend getting RTP3.

    And please, put some effort into spell checking your posts, - no offense, but they are painful to read.
     
    Last edited: Jan 22, 2014
  32. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    You should be able to use a single parallax height texture asset, instead of three texture assets
     
  33. Doddler

    Doddler

    Joined:
    Jul 12, 2011
    Posts:
    269
    Awesome, thanks for the tip. :)
     
  34. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    829
    Are you sure? The textures in the slots are the same only in this example, in a real situation I would use different ones for X, Y and Z, including separate normalmaps and height maps.

    Of course, in a case of texturing something like a rock with just one type of surface, it would make sense to make a separate version of a shader with just one diffuse/normal/height map, though.
     
  35. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Oh! Right, I thought you were intentionally using the same :)
     
  36. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    829
    Yeah. Ideally I'd like to add an additional check to Y and split it into two textures, as ceilings rarely have the same textures as the floors and as that will allow me to easily do nice stuff like snow.

    Probably easily done by getting Y component of a normal, clamping it from -1,1 to 0,1 and using it as an argument to lerp between two textures. Maybe modifying it a bit to make sure ceiling textures won't bleed onto e.g. 10 degree inclinations on the floor.
     
  37. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    I should really make a node to make triplanar-style combinations easier.

    A node with four inputs:

    ColA (RGB)
    ColB (RGB)
    ColC (RGB)
    Mask (RGB)

    Outputting:

    ColA * Mask.R + ColB * Mask.G + ColC * Mask.B

    Which would compress the left side of your shader tree quite substantially :)
     
  38. CarSim

    CarSim

    Joined:
    Jan 22, 2014
    Posts:
    2
    I'm working on driving simulation with night driving. I have spot lights linked to the front of my vehicle but am unable to get the shader forge materials to receive light from the spots, I only get directional lighting. Is there a setting I'm missing?

    Any help would be greatly appreciated.
     
  39. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Have you enabled multi-light on the shader?
     
  40. CarSim

    CarSim

    Joined:
    Jan 22, 2014
    Posts:
    2
    Well I'm not sure. I just started using shader forge. My Lighting panel looks like this.
    $Capture.JPG
     
  41. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Shader Forge Beta 0.20 now released:
    • Added node: Remap (Same as Remap Range, but with input connectors instead of constants)
    • Added node: Depth Blend (Requires a camera with depthTextureMode set to Depth or DepthNormals)
    • Added node: Scene Depth (Requires a camera with depthTextureMode set to Depth or DepthNormals)
    • Fixed a bug where hotkeys didn't work on Windows (Ctrl+C/V/X/D)
    • You can now use the MIP inputs of textures and cubemaps when on the OpenGL platform (note that this will disable the instruction counter)
    • The Scene Color node is now affected by Refraction
    • Fixed a bug where the multi-add/multiply/min/max nodes did invalid typecasting
    • Fixed a bug where the rotator node speed input expected a Vector2
    • Fixed a bug where the geometry normals sometimes weren't normalized, even though the quality setting told it to
    • Renamed node: "Constant Clamp" is now known as "Clamp (Simple)"
    • Renamed node: "Constant Lerp" is now known as "Lerp (Simple)"
    • Renamed node: "Remap Range" is now known as "Remap (Simple)"
    • Normal map negative values are no longer visualized as positive
    • The image on the Main node now looks better in the light Unity skin

    Click to see all changelogs

    (Don't forget to delete the old Shader Forge before updating to this one!)
     
  42. Thomas-Pasieka

    Thomas-Pasieka

    Joined:
    Sep 19, 2005
    Posts:
    2,174
    Nice update Ace! Keep it coming :)
     
  43. Thomas-Pasieka

    Thomas-Pasieka

    Joined:
    Sep 19, 2005
    Posts:
    2,174
    Now I am rather satisfied with the current looks of the shader...

    Link http://bit.ly/1musbzu

    Give it a few seconds to load.
     
  44. jc_lvngstn

    jc_lvngstn

    Joined:
    Jul 19, 2006
    Posts:
    1,508
    That is a nice looking piece of work, GJ!
     
  45. Don-Gray

    Don-Gray

    Joined:
    Mar 18, 2009
    Posts:
    2,278
    Wow, pretty cool! :D
     
  46. Deleted User

    Deleted User

    Guest

    One last question before I hit the purchase button:

    Can you do:

    > FFT ocean shaders with perlin (normal from heightmap / displacement, then append / multiply / subtract / divide / one minus, lerp nodes / power nodes / scaler and scalar3Vec / bump offset / desaturation / specular power / panner / parameter additive / time / transmission mask / transmission color / light vector / camera vector / dot product /constant clamp / vertex color /texcoord )I think you get the picture :)?
    > Parallax occlusion mapping / OBM
    > Terrain and foliage
    > Alpha glow
    > Fresnel parameters
     
  47. AGeorgy

    AGeorgy

    Joined:
    Sep 16, 2013
    Posts:
    42
    Hello, Joachim! Can I write the SSGI using SF?
     
  48. Deathnote

    Deathnote

    Joined:
    Nov 26, 2013
    Posts:
    52
    Hellou, sory for may bad english

    I tried to do

    deffuse ->Multiply -> Texture 2d and color
    normal -> Texture 2d like Normal maps

    And looks don't realistic
     
  49. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    829
    Terrain rendering is one of the most complex areas and getting it to look "realistic" is both pretty hard on shader side and depends enormously on the quality of your own content (textures and heightmaps). If you're just beginning to familiarize yourself with Unity, I don't recommend setting a "realistic terrain" as your goal, lack of it is not an issue stopping you from developing anything. It's on the same level somewhere among "cinematic cutscenes", "infinite voxel worlds", "life simulation" and other goals like those that are hard to get right and don't necessarily have to be present in every project.

    In any case, this is not quite about Shader Forge. If you're having a problem with getting some shader to work, at the very least post how you graph looks, or most likely nobody will be able to help you.
     
    Last edited: Jan 23, 2014
  50. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    SF is not yet made for post FX creation, especially since post FX usually rely on loops and iteration. It's something I want to do down the line though!


    1. FFT ocean shader might be possible, I'm not sure. It sounds like it required a RT and script support for persistent data across frames, which requires some scripting on the side to make it happen. All of the nodes you mentioned are available in SF, and more: http://acegikmo.com/shaderforge/nodes/
    2. Yes, but it's a bit of a mess to make it in a node editor, you'll be better off making that with the custom code node, which is coming later :)
    3. Yes
    4. Yes, I think so, if you mean masked emission with bloom post FX
    5. If you mean the Physically based fresnel type, it's not possible to control this at the moment. If you mean a camera/normal vector falloff (Like the fresnel node in UDK), then yes, you have control over that :)