Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Shader Forge - A visual, node-based shader editor

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

  1. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    Ace you are the best =)
     
  2. Deleted User

    Deleted User

    Guest

    Finally :D
     
  3. eddietoast

    eddietoast

    Joined:
    Mar 3, 2015
    Posts:
    2
    How do you control Specular in Metallic PBR (Specular in UE4, Reflectance FB3, Specular Level in TB2) for Non-Metals (0.00-0.16)?
     
  4. Barada

    Barada

    Joined:
    Apr 27, 2015
    Posts:
    99
    Hi guys. i`m trying to implement a Volume ray casting system in order to do some real volumes. It doesn`t seem that hard in principal. i just wanted to see if theres anybody whos had a go, has any thoughts etc. i`m hoping to use a large textures, like a sprite page, and cut up in slices that represent the texel depth. using the new texture tiler node. invert the view vector and trace it backward to the backface. hopefully with some maths jiggery i can calculate the texels it passes through, offsetting them along the volumes z axis in code and probably blending between where the intersection is off. then just adding them together to get the pixel colour and transparency. Thoughts?
     
  5. stationx

    stationx

    Joined:
    Jul 9, 2012
    Posts:
    251
    heey, is there a way to collapse nodes with a lot of parents to get a more clear overview?
     
  6. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    I'm actually not sure. It might be possible using the specular mode, since metallic is a simplification of specular. Though I'm not entirely sure how you'd set that up.

    Not at the moment
     
  7. stationx

    stationx

    Joined:
    Jul 9, 2012
    Posts:
    251
    another questions...about RGBA
    I am creating a combined texture where I store two greys to be used for displacement. (Green + Alpha)
    The alpha channel gives correct results, while the green channel doesn't It looks like the green channel is different handled? While at the end, all channels are stil gray? Am I suppose to encode textures different?
     
  8. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    It shouldn't be, though this depends on the compression you're using. Try setting the compression of the texture to Truecolor to see if it's related to that
     
  9. stationx

    stationx

    Joined:
    Jul 9, 2012
    Posts:
    251
    Done that, didn't seem to have effect. Toggling ByPass sRGB did however. Not sure why?
     
  10. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    That's related to how it handles gamma vs linear
     
  11. Studio_Akiba

    Studio_Akiba

    Joined:
    Mar 3, 2014
    Posts:
    1,421
    About a year ago, I created a shader for projecting world-based moss and snow onto models.

    As I have decided to go back to this and refine it for use with a project, I may need some help making it usable with vertical objects such as walls.

    What I Have moss1.PNG

    The Nodes
    moss2.png

    What I Want To Be Able To Do

     
  12. eddietoast

    eddietoast

    Joined:
    Mar 3, 2015
    Posts:
    2
    Reflectance in Metallic (using Specular Set Up) for Non-Metals:

    Diffuse = (1 - Metallic) * Albedo
    Specular=Lerp(Reflactance,Albedo,Metallic)

    Works great
     
  13. DaDarkDragon

    DaDarkDragon

    Joined:
    Jun 6, 2013
    Posts:
    115
  14. Seplabmikash

    Seplabmikash

    Joined:
    Sep 30, 2014
    Posts:
    12
    Hiya people. I just wanted to note that when using Override Fog Color I get these blocky apparitions with the fog. (It's no problem for now since I could just turn off the override color) But it would be nice if when using override fog color you don't get those. :)
     

    Attached Files:

  15. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    What's the blend mode of the shader?
    Additive shaders + fog doesn't work unless the fog color is pure black
     
  16. Seplabmikash

    Seplabmikash

    Joined:
    Sep 30, 2014
    Posts:
    12
    Hey, it's opaque. (it's not that big of a problem since I just turned off override fogcolor)

    In the meanwhile however I ran into a different problem, which also started from the switch to unity 5.
    Intersection fading also doesn't work anymore. I've tried several settings, both in blending mode, render type and render order. Nothing works. Did intersection fading change since the new unity / shader forge?

    Maybe important to note: I did create these shaders during unity 4 and using an older version of shader forge. However I reckon the new version of shader forge should change settings when you save the shader? I have the new Shader Forge now and did save it with this new SF. Didn't work.
    (For the record I did check the soft clipping value was high)
     

    Attached Files:

    Last edited: Oct 27, 2015
  17. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    I'm trying yo make a smooth shader that creates a softer SSS effect and the reddish color bleeling around the edges where shadows meet the light. But the light attenuation is causing these artifacts unlike the normal soft shadows the Unity lights cast.
    Is there a way to fix this ?

     
  18. led_bet

    led_bet

    Joined:
    May 5, 2015
    Posts:
    83
    I'm looking into picking up Shader Forge for my current project but, before I do, I wanted to ask how easy it is to pull off something akin to this:


    I'm using cone-shaped mesh to simulate a tornado, and I need to create a shader that gives it a cloudy, whispy look (like the water spouts in AC: Black Flag)
    Ex:


    Any insight is greatly appreciated!
     
    hopeful likes this.
  19. DaDarkDragon

    DaDarkDragon

    Joined:
    Jun 6, 2013
    Posts:
    115
    @ledbetterman Looking at that shader(it comes as an example) its doesn't seem that difficult to do. Though the only thing is that that specific shader does use DX11 in its effect(which is completely optional but won't look as good if you or your players don't have dx11 capable hardware, vertex offset can be used to replace it)

    @Acegikmo I think I might have found a bug when looking at your example scene for ledbetterman. it appears in most shaders in your example scene. this is the spinning pixel ellipse shader example.
    SuperSFBug.png
    I saw this in another place, cant remember exactly where, it was obvious but small enough to where I ignored it at the time. When I opened the shaders in sf the bottom of the toon sphere was blocking the top of most of these nodes. I moved it a little and went back to sf and it updated the position of the sphere on the nodes, I repeated this until I took this screenshot. realtime node rendering is enabled and the toon sphere is near the origin.

    Moving it out of the way causes this...
    SuperSFBug2.png
     
  20. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,288
    Is there any update on the area lights system ?

    Thanks
     
  21. Seplabmikash

    Seplabmikash

    Joined:
    Sep 30, 2014
    Posts:
    12
    Alright... So the extent of my problem is worse then I initially thought.
    When I change the Render/Sorting order I can either use softblending OR the fog. Not both.
    Look at the image to see what I mean.



    I get the idea this was changed when going to Unity 5. But more importantly, does anyone have a solution for me? Please... I need to fix this asap. Even some hacks, or other fix ideas would be great.
    For example, is there a way to tell Unity to lower or raise the depth blend testing minimum or maximum? Or the fog?
     
  22. stationx

    stationx

    Joined:
    Jul 9, 2012
    Posts:
    251
    heey,
    my shader won't compile anymore.
    Suddenly getting this error...
    Shader error in 'Shader Forge/NewShader21': incorrect number of arguments to numeric-type constructor at line 582 (on d3d11)

    Compiling Vertex program with SHADOWS_DEPTH LIGHTMAP_OFF DIRLIGHTMAP_OFF DYNAMICLIGHTMAP_OFF

    the issue came as soon as i restarted unity and tried to resume my editing in SF, before that, the shader compiled fine.

    The error seems to be here:
    float3 node_1460 = lerp(lerp(lerp(float3(node_5261,node_5261,node_5261),lerp(lerp(_node_6645.rgb,_node_6833.rgb,_blendsandrockysurface),_node_2381.rgb,node_3905),node_8039),_node_9691.rgb,node_6701),lerp(_Diffusetopmountainparts.rgb,_node_7142.rgb,node_9918),node_8412); // add top stones



    PS: I found the bug. It looks like one of those Relay Nodes didn't proper output .rgb, while it should output .rgb instead of just the nodename.
     
    Last edited: Oct 28, 2015
  23. Deleted User

    Deleted User

    Guest

    I would like to use GPU morph animations in Unity3d. Default FBX morphs (for example from Modo) are rendered in Unity3d by CPU. I thought, why not use Vertex Shaders instead ??? So, I tried to recreate proper solution in Shader Forge and finally, it is not easy. First, I have to reconstruct normals:
    http://acegikmo.com/shaderforge/wiki/index.php?title=Normal_Reconstruction
    I read that partial derivation is DDX and DDY nodes but now I don't know how to use.

    I thought about baking blendshapes in Modo using Vector Displacement Mapping to save vertex offsets between morph targets to texture, then create shader in SF using nodes like Time, Multiply, Lerp, Vertex Offset (to load data from textures and manually set time to every morph ).
    Does someone have experience in this matter ?
     
  24. stationx

    stationx

    Joined:
    Jul 9, 2012
    Posts:
    251
    hm another bug:
    Shader error in 'Shader Forge/NewShader_frustum': undeclared identifier 'sceneUVs' at line 93 (on d3d11)

    Compiling Vertex program with SHADOWS_DEPTH LIGHTMAP_OFF DIRLIGHTMAP_OFF DYNAMICLIGHTMAP_OFF

    I want to use ScreenPos node as a UV, but as soon as I map the output of that texture to another node, I am getting this error.
    So; creating a texture with screen based UV works, but not when I want to use that same texture and plug into another node. (to mask some stuff, only seems to be an issue when trying to mask for vertex displacement or tesselation)
     
    Last edited: Oct 28, 2015
  25. GlitchInTheMatrix

    GlitchInTheMatrix

    Joined:
    Apr 12, 2010
    Posts:
    285
    Hi guys, im using Shader Forge for a couple of years and I love it!

    Im having a problem right now creating a new shader,

    Im trying to use a Slide bar to control the blending between 2 lightmaps that use the second UVset that Unity create when you click generate lightmap uvset in your FBX model.

    But can make it works. so far i attack a pic of my case.

     
  26. Ga2Z

    Ga2Z

    Joined:
    Feb 16, 2012
    Posts:
    68
    Hello, I'm trying to do a very simple toon shader (I've done it before using the nodes below) I'm even looking at the Getting Cozy with Shader Forge video tutorial and I do the same and set everything the same, multi lights, custom lighting shader...

    But Still I can´t get my objects to receive light from any or multiple point lights as is shown in the tutorial videos. Don't know what I'm doing wrong here or if something changed in the last release of SF.

    Thanks.



    This is the shader:
     

    Attached Files:

  27. Barada

    Barada

    Joined:
    Apr 27, 2015
    Posts:
    99
    Trying to get some sort of volume rendering system.i seem to be getting a sphere that lerps from 1 to 0 at a point in world space. if i move the object it intersect this sphere with the below result. i thought the world pos node returned the position of the geometry under the current pixel? Any help from somebody smarter than I would be much appreciated.

     
  28. Ryirs

    Ryirs

    Joined:
    Jan 9, 2015
    Posts:
    12
    I updated to 1,22 but i now can't open my previous shader from 1,19 where i was using RGBtoHSV node.
    I get the following error:
    "Unsuccessfully tried to find connector by string ID [OUT] in node RGB to HSV"
    Any ideas or to work around that ?
    Thanks.


    How can i download an older version of ShaderForge ?
     
  29. florianveltman

    florianveltman

    Joined:
    Sep 7, 2012
    Posts:
    27
    Hi Joachim,
    Thanks for the amazing asset, it's truly incredible how much I get out of it in such a short time!
    So I'll just add another question to the long list in this thread, as I guess this seems to be the place to do so…

    I'm making a shader that's supposed to work as a "mesh-based light",where I'd have a mesh that, when intersecting with other geometry, should give the impression of having a light shining on it.

    Before getting ShaderForge, I got this to work by having a simple additive shader with a stencil buffer, and have it do a pass before drawing the "light" to remove the geometry that's supposed to be hidden.
    I'm now trying to build this same shader with ShaderForge, to be able to manipulate the results more easily.
    Here's what I have for now:
    Screenshot 2015-10-30 13.22.31.png
    Since I can't do a second pass with ShaderForge, I get the following issue:
    Screenshot 2015-10-30 13.22.48.png
    The lights go through walls etc.
    Though that's easily solved by adding a second pass in the shader manually, I was wondering if you had any better idea to achieve such an "intersecting" effect. The problem I am having is that when an object is a little further away, I get some nasty Z-Fighting going on with this shader, like what's going on on the train here:
    Screenshot 2015-10-30 23.39.20.png
    There's also some weird artefacts going on on certain parts of "light" meshes like shown here:
    Screenshot 2015-10-30 23.39.44.png
    Yeah so I was hoping I'd figure something out by trying various things in ShaderForge, but for now that's not yet the case… I'll continue to mess around while hoping for some insight you might bring to my issue, if you ever have time :)

    Again, thanks for your amazing package

    Florian
     
    Cactus_on_Fire likes this.
  30. Ga2Z

    Ga2Z

    Joined:
    Feb 16, 2012
    Posts:
    68
    Don't mean to spam but maybe my question would be lost on the end of the last page, so I repost:

    Hello, I'm trying to do a very simple toon shader (I've done it before using the nodes below) I'm even looking at the Getting Cozy with Shader Forge video tutorial and I do the same and set everything the same, multi lights, custom lighting shader...

    But Still I can´t get my objects to receive light from any or multiple point lights as is shown in the tutorial videos. Don't know what I'm doing wrong here or if something changed in the last release of SF.

    I've seen this is happening on the custom light shader example, it doesn't receive multiple point lights.

    Thanks.



    This is the shader:
     

    Attached Files:

  31. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    This is a known issue, and will be resolved at some point


    Custom lighting is run once per light source, and is additively blended in the end. You'll want that in Emission multiplied by your base texture, rather than in Custom Lighting
     
  32. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Make sure you enable multiple lights under the shader's lighting settings, and make sure your project supports multiple pixel lights under the quality settings
     
  33. Silly_Rollo

    Silly_Rollo

    Joined:
    Dec 21, 2012
    Posts:
    501
    This is really simple but is there a way to take the color result of various nodes and set the alpha directly? (just the alpha)
     
  34. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Use component mask to get the component you want, and connect it to the Opacity input of the main node
     
  35. Ga2Z

    Ga2Z

    Joined:
    Feb 16, 2012
    Posts:
    68
    Thank you very much, as always a life saver :)
     
  36. stationx

    stationx

    Joined:
    Jul 9, 2012
    Posts:
    251
    heey, how can I reuse a code block to act as a real function? E.g. different output on different parameters.

    edit: I dont want to duplicate the code block to accept different parameters, instead, I want to use the code block, use it as a global function and let it accept different parameters that gives different results.
     
    Last edited: Nov 1, 2015
  37. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    That's not possible at the moment
     
  38. florianveltman

    florianveltman

    Joined:
    Sep 7, 2012
    Posts:
    27
    Hi, I was wondering if you had any clue as to how to get the intersecting geometry to be affected by a mesh, as I was describing in my previous post? Maybe it's a bit too complicated and sorry for insisting!

     
  39. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    I'd suggest using the Scene Depth node and the Depth node to see if geometry is in front of or behind the light, though I'm not entirely sure if it will help in this case, and it also requires you to render depth with your camera, if you're on forward rendering
     
    florianveltman likes this.
  40. florianveltman

    florianveltman

    Joined:
    Sep 7, 2012
    Posts:
    27
    Thanks, I'll have a look at those!
     
  41. Designopolis

    Designopolis

    Joined:
    Mar 8, 2013
    Posts:
    2
    Just got started with this, this is great fun. I don't really know what I'm doing quite yet but the results are pretty. Here I made some cartoony looking water in an effort to make the most vivid looking animated water I could (ignore the terrain, standard issue RTP textures on a mesh for now)

    http://gfycat.com/IlliterateDelectableItalianbrownbear

    I have to ask, if presented with a situation where the Blend node can do what any other node can approximately (like Multiply and Blend's multiply), is it any sort of benefit to go for the other node? Besides the limitation to two inputs and such, I mean more processing costs and such.
     
  42. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    There's no difference really, unless you want to create an approximation of a blend mode rather than the proper version of the blend :)
    Multiply though, has the same computational cost in both the Blend node and the Multiply node.

    Your shader looks very pretty by the way!
     
  43. Ravart

    Ravart

    Joined:
    Mar 9, 2011
    Posts:
    42
    I encounter a strange bug with the new version (1.24)? :/
    It seems the render picks a random object inside my test scene and projects it.

    WrongRender2.png
     
    Rodolfo-Rubens likes this.
  44. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    It's a known issue and it will be fixed in 1.25
     
  45. Shushustorm

    Shushustorm

    Joined:
    Jan 6, 2014
    Posts:
    1,084
    I just tried to use one tile texture and a splatmap to get different rotations of the tile texture onto the mesh, but after lerp, the texture behaves as if its UVs weren't rotated. Any ideas?
    Here is a screenshot of the nodes:
    screenshot.png

    Also, is there an easier way to rotate textures by 90 degrees? I used the rotator, but it seems kind of awkward to hand-tweak the values so that the rotation is roughly 90 degrees.
     
  46. JohnyK

    JohnyK

    Joined:
    Jun 13, 2014
    Posts:
    13
    Hello, is it possible to create a shader that takes a Texture and creates a kinda soft and blur drop shadow around it (like the Unity UI shadow but softer)?
     
  47. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    501
    http://forum.unity3d.com/threads/released-utility-shaders.280098/#post-1848135
    Bottom row, second from the left the one you're after?

    It also has a few variables you can tweak as well.



    There's a free test pack on the asset store so you can check compatibility if you want (something you should probably do anyway).
     
  48. Designopolis

    Designopolis

    Joined:
    Mar 8, 2013
    Posts:
    2
    Hey thanks, appreciate it. I've cleaned it up a bit since:

    https://gfycat.com/LonelyUnfoldedErne

    The node tree looks like this:



    It's essentially one (big) voronoi pattern at two different scales and planing in two different directions, and a third for foam. Is one bigger texture reused better than several, smaller ones?
     
  49. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    This is kind of a wierd question but is there any way to mask certain objects with shader forge or by modifying the code of a shader ?



     
  50. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Read up on Unity's stencil buffers, SF has support for it :)