Search Unity

  1. Unity 2020.2 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Shader Forge - A visual, node-based shader editor

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

  1. kurai

    kurai

    Joined:
    Jan 9, 2012
    Posts:
    111
    Right now I have got the world space coordinates multiplied by a sin wave. The problem is still the smae, though: expansion and contraction happen on the whole mesh rather than in waves (basically: the mesh expands and contracts as a whole, but I'd like the vertices move as they are perturbated by waves – so for example if one of the vertices is offset by one, the vertices around it are maybe offset by 0.5). Don't know if I'm explaining what I'd like to get in a good way :)
     
  2. RUBILYN

    RUBILYN

    Joined:
    Jun 22, 2013
    Posts:
    54
    HELLO AGAIN !

    I think would be important to bring Paralax Oclusion Mapping with Silhouette to SHaderforge ..
    Shader Forge Shaders right now look so dull and flat .. we really need some relief.





    There are already some shaders that do this in Dx9 in assets store ...
    https://www.assetstore.unity3d.com/en/#!/content/5705
    https://www.assetstore.unity3d.com/en/#!/content/5664

    There are Also Some other much more Easier Not so expensive ways to do Paralax Oclusion Mapping in Nodes ...









    As well Some others quite expensive and more complicate of course ....

    http://udn.epicgames.com/Three/rsrc...sParallaxOccludedMapping/MaterialNodeTree.jpg




    Thanks so much to Whoever can bring this to Unity to all us !

    Ps: Some Links About this subject :

    https://forums.unrealengine.com/showthread.php?49169-POM-material

    http://oliverm-h.blogspot.de/2013/09/udk-iterative-parallax-mapping.html

    http://udn.epicgames.com/Three/DevelopmentKitGemsParallaxOccludedMapping.html

    http://www.gamedev.net/page/resourc...oser-look-at-parallax-occlusion-mapping-r3262

    http://http.developer.nvidia.com/GPUGems3/gpugems3_ch18.html

     
    Last edited: Oct 22, 2014
  3. DMeville

    DMeville

    Joined:
    May 5, 2013
    Posts:
    403
    Was playing around with making a hair shader, really happy with how it turned out! [GIF] Screen Shot 2014-10-22 at 4.42.05 PM.png

    And here's the node graph if anyone is interested! :)

    sf_hair_10222014.png

    Man shaderforge rocks!!
     
    Last edited: Oct 23, 2014
    Deon-Cadme, Gekigengar and IFL like this.
  4. angelodelvecchio

    angelodelvecchio

    Joined:
    Nov 15, 2012
    Posts:
    170
    thank you for sharing!
     
  5. red2blue

    red2blue

    Joined:
    Feb 26, 2013
    Posts:
    200
    Thanks a lot for sharing. Could you maybe also include this into the wiki, so more people con access it? Thanks again!
     
  6. Guideborn

    Guideborn

    Joined:
    Jun 15, 2013
    Posts:
    228
    I do apologize for the lack of knowledge as I am still trying to learn the editor, but I have a question. Let's say there is a part of a texture that I don't want shadows to appear. What would be the best approach in controlling how shadows appear on certain parts of a texture?
     
  7. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    890
  8. chiapet1021

    chiapet1021

    Joined:
    Jun 5, 2013
    Posts:
    604
    I've read about example shaders being on the wiki before. Are those just the links in the columns on the main page, or is there a repository of Shader Forge examples somewhere else that I'm missing? Thanks!
     
  9. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    Do some Custom Lighting to have the most control or feed the non-shadowed parts into the Emmissive property. Is that what you mean?

    Recreate the Matcap shader on the Wiki and make sure the *Perturbed* checkbox on the Normal node is ticked. Then, link up the normalmap.

    This thread and the wiki are where I've found stuff. Also, if you know CG, just look up general shaders and find a way to create what you want. Shaders that require more than a single custom pass aren't directly able to be created in SF. That functionality will likely come along eventually though.
     
  10. HenriqueGomez

    HenriqueGomez

    Joined:
    Dec 13, 2012
    Posts:
    69
    Hey guys !
    How can I make a texture move towards the DepthFade ?
    Something like this:

    Thanks :)
     
  11. Guideborn

    Guideborn

    Joined:
    Jun 15, 2013
    Posts:
    228
    I'm assuming I must use those particular nodes. I just haven't a clue what setups I'll need to achieve control over shadows.
     
  12. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    There's an example of custom lighting on the Wiki. That said, depending on what you're wanting to use it for, emission is likely better... Does this node graph help?
    SF_Guideborn_01.jpg

    Do you mean like a flow shader that uses the depth as the direction? If so, here's a starting point...
    FlowWater.gif
    flowmap.png
    SF_HenriqueGomez_01.jpg
    (for full resolution: right-click, open in new tab)
     
    Last edited: Oct 28, 2014
  13. Guideborn

    Guideborn

    Joined:
    Jun 15, 2013
    Posts:
    228
    I actually understand it a little better. So what treatment do I need to apply to the texture going into the Emission node? Or do I just plug in the original texture untouched?
     
  14. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    The way that I set up that node graph is just using a black and white mask with the white areas being the un-shadowed parts. You can use a colored mask, but that will change the color of the surface. The downside to this way is that having a light near the surface lights up everywhere except the un-shadowed part:
    SF_Guideborn_02.jpg
    I mainly just threw that node graph together to give you an idea of how to do it. It'd be ideal to use Custom Lighting to do it so that you could have fine-control over exactly how the unlit part behaves, but it's probably a bit complex if you're new to SF & shaders.
     
  15. Guideborn

    Guideborn

    Joined:
    Jun 15, 2013
    Posts:
    228
    Oh I see. Thanks for sharing this. So by black and white mask, you mean where it says "Default", or do you mean when creating something like a B&W shadow bias map?
     
  16. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    White for the unlit areas, black for the rest. If you're comfortable working with alpha channels, you can put it in the alpha of the MainTex and just use that instead of the Emission node. That would perform better, but only if your shadow map and diffuse texture are the same size.
     
  17. Guideborn

    Guideborn

    Joined:
    Jun 15, 2013
    Posts:
    228
    Ok I can understand that. That's like making a specular map. See, I'm not completely hopeless! Many thanks for the time you took helping an old guy like me.
     
    IFL likes this.
  18. hexdump

    hexdump

    Joined:
    Dec 29, 2008
    Posts:
    439
    Hi,

    I come from UE4 great material editor and would like to know if Shader Forge supports Unity5 native PBR shaders. I mean, does this shaders created by shader forge generate unity5 builtin PBR shaders? If this is the case I will be buying this asset just now!.

    Cheers.
     
  19. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    7,242
    Is there a way to convert a vector4 into a sampler2D?
     
  20. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    Why would you do that? I'm asking out of ignorance, not judgement.
     
  21. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    7,242
    I'm stacking a lot of panning effects and various UV offsets to create a VHS style tracking error that takes into account things like chromatic aberration, vignetting, and a whole mess of other things. There are ways to do this with a whole lot of math, but this presents two problems:

    1. I am bad at math
    2. A node graph the size of kentucky

    I figure I can do it if I use the code node and do some casting, but I'm so used to visual shader editors that I can't write shader code at all.
     
  22. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,250
    Not at the moment - they've told me not to do it until they've released it :)
    SF has its own PBR implementation though
     
  23. hexdump

    hexdump

    Joined:
    Dec 29, 2008
    Posts:
    439
    I see. It is a pity. I have a friend with beta access and wanted to test GI with the built-in PBR materials. Don't know if we could check the unity 5 built-in with SF PBR implementation. Can we? Do they both play as nicely as GI+build-in PBR?

    Cheers.
     
  24. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    577
    Hello.

    I'm trying to make a shader that will apply a multiply blend to a texture where there are shadows, and an additive blend where the light hits the mesh.
    Or use two textures with lerp and use the light / shadow areas on the mesh as a lerp mask.
     
  25. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    577
    I did the lerp mask with light attenuation, but I still need the light intensity to depend on the light angle. I tried to multiply those values with Light dir. node, but it just changes the colors of the light.

    Does anyone knows how to achieve that ?



    Light attenuation inverts the ambient occlusion shadows to white so it creates some sort of fake GI. It's not that great but it might be if it acts on the light angle.
     
  26. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,250
    The light direction is a vector pointing towards the light source. If you want it to depend on the "light angle", I presume you mean the angle between the light vector and the normal vector, in which case you can use dot( normal, light), and set it to positive.
     
  27. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    577
    Hey thanks Ace, it worked ! I think I kinda achieved what I had in mind. When the sunlight hits directly to ground, it lights up the bottom of the buildings, as if the light is bouncing back from the ground. And when it hits from the side, it lights up the ground and the little detail on the roof.

     
  28. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    7,242
    Cactus, I have no idea what you're working on but I am already in love with what it could be.
     
  29. Eideren

    Eideren

    Joined:
    Aug 20, 2013
    Posts:
    295
    Here's a little thing i did a while back.

    It's a somewhat volumetric cloud shader, I am now stuck since it seems to take too much render time (I am not sure since i dont have any powerful pc at hand to test it on, a link to an exe is provided here if you want to test it).
    I had a look at raymarching a 3D textures to optimize it further but shader forge doesn't currently support it so i'll probably have to learn and write it by myself.
    So my question is, are those kind of shader styles planned for a future release in SF ?

    Also, the view direction node can't currently be used with the Vertex Offset function.
    We can't use a rotator connected to a pixel shader and vertex offset as well, one for each input is required.
    How should we get the object pivot point position if the mesh is static(Object Pos. returns 0, 0, 0 once the object is marked has static) and we need to use the same material on multiple object at the same time ?

    Bonus Pokemon fire effects.
     
  30. djweinbaum

    djweinbaum

    Joined:
    Nov 3, 2013
    Posts:
    525
    I know we're still in beta, but I was wondering if you planned on doing an update to make deferred shaders work in U5. I'm not talking about adding support for the new GI or PBR features, just making deferred work again (You're probably already aware, but SF deferred shaders are broken even in the deferred pre-pass legacy mode).
     
  31. hexdump

    hexdump

    Joined:
    Dec 29, 2008
    Posts:
    439
    Acegikmo Unity5 beta has been released :). It seems the time to start to work with it :D.

    Cheers.
     
  32. DMeville

    DMeville

    Joined:
    May 5, 2013
    Posts:
    403
    Sure, is there a section for example graphs? I'm not sure what category to put it under :p
     
  33. chiapet1021

    chiapet1021

    Joined:
    Jun 5, 2013
    Posts:
    604
    I have trouble figuring that out with the wiki, too. :p It would be nice if there was just a page or category for examples, since a shader like yours doesn't neatly fit into one of the existing categories.
     
  34. DaDarkDragon

    DaDarkDragon

    Joined:
    Jun 6, 2013
    Posts:
    115
    Guideborn likes this.
  35. DMeville

    DMeville

    Joined:
    May 5, 2013
    Posts:
    403
  36. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,250
    Possibly, it would be nice to have :)

    These should both be fixed in the rewritten version of SF.

    I don't think you would. The problem is that when they are batched, they are no longer separate meshes, they're the same.

    Strange that they are broken in the legacy deferred mode. The rewritten version should support both.

    I've had it for months, I just haven't had the time to look at the U5 specific features just yet.
     
  37. sundance

    sundance

    Joined:
    Mar 19, 2014
    Posts:
    52
    Hello! Need advice.
    Im trying to make own shader for unity terrain without splats.

    So there is problem with horizontal parts of terrain. There are no normal map applied on this parts. How can i fix this?
    Thx for answers.
     
  38. FreakForFreedom

    FreakForFreedom

    Joined:
    Jan 22, 2013
    Posts:
    155
    So, I've been giving a shot to a pbr shader for the last few days... but I gotta admit, I still have some difficulties wrapping my head around the whole theory.This is why I wanted to share with you what I have 'till now.
    Metals are fine so far, but I don't seem to be able to archive the plastic look. It looks more like glass pearls (see the screenshots).
    Also it seems I don't really get the diffuse ambient light part in pbr and the fresnel stuff is baffling me (the nodes documentation is not really complete for it unfortunately).
    Anyway, here's the node tree... and if someone should figure the remaining problems out, I would be glad to hear them. :)
    (Oh, and the editor screenshot should be 4k, so you can really zoom in to see the fx)


     
  39. zelmund

    zelmund

    Joined:
    Mar 2, 2012
    Posts:
    417
    hi there. i got strange iisue. we are building some kind of custom terrain. terrain is many custom created in runtime meshes. this meshes has unknown uv set and we for sure need triplanar mapping. first step was using triplanar example from this topic. but nothing works. its work on unity simple objects, like plane or sphere, it work on meshes from outside, but it not work on meshes that we create in runtime.
    in additional, in dx9 mode normal maps disappear in 2+ meters away, in close view i see very low normal maps. in dx11 mode it give us a wierd result. will add screenshots.
    it doestn matter deffered or forward options. same it doesnt matter if i create deff/forw shader.
    it happens with normal maps only. diffuse channel work fine.

    i missed text in console "shader wants tangents, but mesh (x;x;x) doesnt have them"
    how to fix that? im total noob ((
     
    Last edited: Oct 29, 2014
  40. irwit

    irwit

    Joined:
    Sep 30, 2014
    Posts:
    55
    Hi all,

    Is there a way in Shaderforge to decide which UV set a shader uses? I'm making a leather seat with stitching and have UVs for the repeating leather in one UV set and the UVs for the stitching on a separate UV set. Its a great way of creating stitching for a leather seat in 3dsmax and Vray and I am trying to repeat this method in Unity but I cant seam to access that second UV channel.

    Any help would be hugely appreciated :)
     
  41. gurayg

    gurayg

    Joined:
    Nov 28, 2013
    Posts:
    241
    Hi!
    I believe you can do this by using the UV coord. node

    UV Scale on the wiki
    UV rotation on the wiki

    Hope that helps.
     
  42. irwit

    irwit

    Joined:
    Sep 30, 2014
    Posts:
    55
    Ah thats awesome, thanks for the quick reply, works perfectly!

    Thanks

    Will.
     
  43. MaT227

    MaT227

    Joined:
    Jul 3, 2012
    Posts:
    628
    Hey everyone,

    I am trying to create a transmittance shader and I am wondering if I could use Shader Forge to create it. I already saw some kind of Transmittance in this article about Color Elimination.
    But I would like to apply this kind of effect on a volume object and get a result like in this example.



    Thank you !
     
  44. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    597
    For this to work in SF and without additional passes (that SF cannot create in its current state of development) you'd need to have a "thickness" map of your object. XNormal is capable of creating such maps.
    They are an approximation but they should give you the possibility to mimic that effect.
     
  45. MaT227

    MaT227

    Joined:
    Jul 3, 2012
    Posts:
    628
    Thank you for your answer !
    So, there's no possibility of calculating thickness dynamically ?
     
  46. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    597
    There is. But not with ShaderForge alone. You would have to create additional passes - one for rendering the backfaces into a rendertexture/depthbuffer, one for rendering the frontfaces and comparing the depth of each frontfacing fragment with the depth of a backfacing fragment to extract the length of a ray marching through the object.
    I would consider this too much hassle to even start this shader in SF. Instead I would use the thickness map approach.

    Maybe someone has got another idea. Don't take my word for it that these are your only options. :)
     
  47. bigSky

    bigSky

    Joined:
    Jan 31, 2011
    Posts:
    114
    Hi - I'm having a lot of fun with the vertex offset attr, but was wondering how I can get my specular term to react to the motion of the surface - right now, all I get is "flat" highlights. I can more or less "fake it", but is there a recommended way though?
     
  48. DMeville

    DMeville

    Joined:
    May 5, 2013
    Posts:
    403
    Back again! I'm trying to create a shader with a few maps for specular. Specifically Spec Intensity, Spec Exp, and Tint Spec By Diffuse. I've got the first two working, but the tint by diffuse is giving me a hard time. Here's what I've got so far.




    Right now the node graph above assumes ALL spec should be tinted by diffuse (as per the diffuse x spec before adding them). Removing this multiply and plugging in the sepc to the add assumes all spec is NOT tinted. All that makese sense to me, however I can't get it working with the Spec Tint texture.

    I've tried something like this:

    And while it seems to be working for the most part, the closer a value gets to being NOT tinted by spec, the spec highlight becomes wrong, like there is a hole in the middle of it.



    Any ideas shader masters? :)
     
  49. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    @DMelville I can't test it out right now, but you might try to clamp the T input on your lerp. It doesn't play nice with values outside of 0-1 because of the underlying cg function. When the T is outside of that range, it adds in a negative of the parameter that would otherwise be at zero.
     
  50. DMeville

    DMeville

    Joined:
    May 5, 2013
    Posts:
    403
    Good idea! Just tested it out and it doesn't fix it though. Darn!
    Gif of the problem: http://i.imgur.com/B1j5YWs.gif
     
unityunity