Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Shader Forge - A visual, node-based shader editor

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

  1. Deleted User

    Deleted User

    Guest

    CastleIsGreat, I am only shader novice, but if you want really good fog then you need volumetric shaders.. and you cannot create proper volumetric stuff with shaderforge. You could try using polygon shells and depth-blend for fog. Good realistic 3d clouds would be pretty tricky in shaderforge but you can easily make some far away moving billboard clouds with a lighting mask on thinner parts of the cloud to give it that cloudy subsurface scattering effect.
    Summary: cant really say how difficult it would be but it wont be easy.
     
    IFL likes this.
  2. Deleted User

    Deleted User

    Guest

    Does any one know how i can get an exponential-ish value based on camera distance?
     
  3. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    Multiply it by a factor, raise it to the power of another. You can use a graphing calculator online to construct the formula if needed. Try something like (dist*0.05) to the power of (0.5)...
     
    Deleted User likes this.
  4. Eideren

    Eideren

    Joined:
    Aug 20, 2013
    Posts:
    308
    The clouds in my signature have been prototyped under shader forge and then I rewrote them by hand to save performances and uses certain functionality not available in shader forge (mainly related to gi, lighting and alpha) so it is possible to create them with shader forge but it will use a lot more performances than if you wrote it by hand.

    Why don't you use Unity's fog ? I thought that their implementation was alright.
     
  5. FPires

    FPires

    Joined:
    Jan 5, 2012
    Posts:
    151
    When I select the option to make a Sprite Shader the shader doesn't work with Unity UI unless the Canvas Render Mode is set to Screen Space - Camera instead of Overlay. This in turn makes the interface be affected by Image Effects.

    How do I make a new Sprite shader that is compatible with Screen Space - Overlay in the Unity UI?
     
  6. wayfray

    wayfray

    Joined:
    Oct 10, 2014
    Posts:
    6
    I've been trying to add a distortion effect to 3d models using vertex offset. It would be somewhat similar in function to the old CRT effect mentioned earlier, although with a more randomized effect. I am using vertex offset with a rotating texture plugged into UV coordinates, but that produces seams at UV splits. I am open to any solution that would produce a shimmering effect on the model within shader forge.

    Is there a way to get the distortion effect to work using screen position in Shader forge? The image shows my attempt.
     

    Attached Files:

  7. CastleIsGreat

    CastleIsGreat

    Joined:
    Nov 10, 2014
    Posts:
    176
    I'm looking for something I can use to add atmosphere to specific spots of my level, for example if you're in a damp hot cave and there should be mist like effects floating around, or for example if there's snow drift something more than just a simple particle system to show like snow drift... Idk maybe i'm thinking would be too performance intensive..
     
  8. Deleted User

    Deleted User

    Guest

    CastleIsGreat I've seen some convincing mist with shuriken particles... There are lots of tutorials and info on unity particles, here is one Specifically for fog
     
  9. elamhut

    elamhut

    Joined:
    Sep 13, 2013
    Posts:
    45
    Hey Guys, is it possible to get the Standard Shader's HDR color picker in SF?

    I really wanted this for my emissives, it gives way more controle on the color output for some stuff when using SE Natural Bloom

    ss+(2015-08-03+at+07.14.01).jpg
     
  10. Eideren

    Eideren

    Joined:
    Aug 20, 2013
    Posts:
    308
    You could use an inverse intersection fading if you want a basic fog volume
     
  11. Vladnes

    Vladnes

    Joined:
    Jul 5, 2014
    Posts:
    51
    How to create flipbook shader?
     
  12. Elzean

    Elzean

    Joined:
    Nov 25, 2011
    Posts:
    584

    Hey,

    i post a shader made with Shader forge a while ago with a dissolve effect. With the shader i shared a small tool i made with Flash that would generate a texture to control both "in" and "out" effect of the dissolve. As you can see in the example below the object appear differently than it dissolve.
    Hope it can help you achieve what you want :p

    http://forum.unity3d.com/threads/shader-level-operation-using-shader-forge.256862/#post-1700337

     
  13. blizzy

    blizzy

    Joined:
    Apr 27, 2014
    Posts:
    775
    I hope the facing node is still on the list for 1.18? I also wonder when 1.18 is going to be released :)
     
  14. Eideren

    Eideren

    Joined:
    Aug 20, 2013
    Posts:
    308
    @Acegikmo Are arrays a feature that you consider adding to SF ? It could be pretty useful for things like fake grass collision per actors, custom wind zones and stuff like that.
    Knowing when to start and stop the for loops is pretty hard so I would understand if it isn't something you would consider adding.
     
  15. Vladnes

    Vladnes

    Joined:
    Jul 5, 2014
    Posts:
    51
    I did flipbook shader, but frames do not go in order. What's wrong?

     
    Last edited: Aug 4, 2015
  16. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    Vladnes likes this.
  17. Vladnes

    Vladnes

    Joined:
    Jul 5, 2014
    Posts:
    51
  18. Deleted User

    Deleted User

    Guest

    How do you make camera facing cards/polys/billboards in shaderforge?
     
  19. ArthurClark

    ArthurClark

    Joined:
    May 12, 2013
    Posts:
    15
    Hi everyone!
    I have an interesting task. I need to make a procedural generated circle rooms for 2D game. The code for this rooms is ready. I have a Room object and the Door objects which are just make some of room walls physically transparent. Looks like this:

    Yellow sectors represents doors. The problem is... Those cut off parts of the walls is in fact was cut off in the original sprite for the room. At this point I have to draw the room sprite with doorways and then overlay my room component over it. I want to modify my component so it cut the doorways automatically. So I could just draw the entire room without doorways and then, when I set up my doors in the component, they would be automatically cut off. I think it can be done by making a shader that will "hide" a part of the wall when it overlays it. So I need two shaders: the first is a walls shader, parts of which are turned invisible when overlayed by shader 2.

    Can you recomend something? Maybe someone made something similar? Maybe you have some links for it?

    I have an idea about that. I need a shader that clips a sector from a circle. Something like this:



    Is there a way to do this?
     
    Last edited: Aug 5, 2015
  20. Eideren

    Eideren

    Joined:
    Aug 20, 2013
    Posts:
    308
    PieChart.png There you go, procedural pie chart.
     
    DMeville and blizzy like this.
  21. ArthurClark

    ArthurClark

    Joined:
    May 12, 2013
    Posts:
    15
    Thx! That's helpful! The only thing is I'm using this output as an opacity clip output, multiplied with the alpha of my room texture. The result is too low-res. I'm using 4096x4096 texture and it limits its size to 1024x1024. Here's my algorithm (I would also be thankful for some optimization recommendations):


    The reason why I'm using a texture for the initial image instead of generated circle - because in the future rooms will be drawn by an artist.
     
  22. Dan2013

    Dan2013

    Joined:
    May 24, 2013
    Posts:
    200
    @Acegikmo
    Is there any Compatibility Auto Checker for Unity5's standard Physical Based Shading process?

    When I create a new shader with SF, I find an option named "Lit (PBR)" that has some pre-configured parameters for Unity5's PBS process. I am wondering if I build my own shader on top of that Lit (PBR) pre-configuration, how would I make sure that the final result shader is still 100% compatible with Unity5's standard PBS process? I mean, even after I add, modify things on top of that pre-configuration, how would I make sure that result shader is still correctly "affected by lightmaps, light probes, reflection probes" provided by Unity5?
     
    Sinaz20 likes this.
  23. Vladnes

    Vladnes

    Joined:
    Jul 5, 2014
    Posts:
    51
    You can show the AO MAP texture?
     
  24. Deleted User

    Deleted User

    Guest

    I am am making a foliage shader, and want polygon backfaces to show the same shadows that the front faces receive.
    Is this possible? The speedtree unity shader does this, but i don't know how.

    My current solution is to have all polygon leaves doubled so there is one polygon for each side and they both receive the same shadowing, however this is very expensive.
     
    Last edited by a moderator: Aug 6, 2015
  25. edredar

    edredar

    Joined:
    Jul 26, 2012
    Posts:
    58
    Dear sirs, I ask for your help. Since Unity supports WebGL export, which is extremely nice, there is a big issue with it. It doesn't support Linear color space, and seems it wouldn't support it for years. I beg you, if there is a secret - how to make everything to look in gamma as in linear, would you kindly share this knowledge? I'm not good in actual shader coding, so I bought SF, but I can't use some good ideas as in this thread:
    http://gamedev.stackexchange.com/questions/74324/gamma-space-and-linear-space-with-shader
    I hope someone can help me with this issue. If someone has Standard Shader, made in SF with custom lighting - it would be lovely too. Many thanks to you all.
     
  26. KWaldt

    KWaldt

    Joined:
    Nov 1, 2013
    Posts:
    127
    Hello there!

    I am currently working on a character customisation system, and I created a shader that mixes multiple normal maps together, which output is rendered in a RenderTexture and the used in the actual skin shader.
    However, the normal maps inside shader forge are a weird dark blue instead of having #8080ff as basecolour.
    I checked "Normal map" on the textures and set their default to "Bump", and blend them together using "Normal Blend".
    However, even unmixed normal maps in Shader Forge are dark blue and show extreme banding (low quality?)-- does anyone have an idea how to fix it and make it look normal (no pun intended)?

    - KW
     
  27. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    494

    the "Normal Map Blue" we all know and love is RGB(0.5, 0.5, 1). What you might be seeing is RGB(0,0,1), which is just blue. If you're getting dark blue when you ABSOLUTELY KNOW you should be getting Normal Map Blue, then maybe try remapping from (-1 to 1) into (0 to 1).

    Bear in mind you may not need to do this for things that are plugged into the Normals Node, because I think they're actually supposed to accept (-1 to 1), or something. Anyway, try the remap I suggested, see if that works.
     
    crudeMe and IFL like this.
  28. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    Still fighting with this issue. When creating uv coordinates from worldspace positions both the standard pbs surface shader from Unity and any SF-created pbs shader go funky on my normals. The gif shows the deferred scene debug mode "Normal". I rotate a simple planar object (y-axis rotation) and the normals freak out. In fact they are never correct to start with - as you can see in direct comparison with the street meshes on top. Those are not relying on worldposition coordinates. They use their respective mesh uv coordinates.
    Am I missing a transform here? Do I have to transform the worldspace UVs into tangent space somehow? Shouldn't be necessary - I've done this stuff in 4.6 and before.
    SF_worldspace_uv_funky_normals.gif

    edit:
    Looks like it has to do with custom packed normal maps. On asset import we swizzle R and A channel of the texture before letting Unity do its DXT5 compression.
    In the shader I use a modified UnpackNormal function to retrieve the swizzled data:

    Code (csharp):
    1.  
    2. inline float4 Unpack_NoDXT5_Normal(fixed4 packedNormal)
    3.   {
    4.     float4 unpackedNormal = float4(0, 0, 0, 0);
    5.     unpackedNormal.xyz = packedNormal.wyz * 2 - 1;
    6.     unpackedNormal.w = packedNormal.x;
    7.  
    8.     return unpackedNormal;
    9.   }
    10.  
    11.   inline fixed4 Unpack_DXT5_Normal (fixed4 packedNormal)
    12.      {
    13.        fixed4 unpackedNormal;
    14.        unpackedNormal.xy = packedNormal.wy * 2 - 1;
    15.        unpackedNormal.z = sqrt(1 - saturate(dot(unpackedNormal.xy, unpackedNormal.xy)));
    16.        unpackedNormal.w = packedNormal.x;
    17.        return unpackedNormal;
    18.      }
    19.  
    20.      inline fixed4 UnpackCustomNormal(fixed4 packedNormal)
    21.      {
    22.        #if defined(UNITY_NO_DXT5nm)
    23.          return Unpack_NoDXT5_Normal(packedNormal);
    24.        #else
    25.          return Unpack_DXT5_Normal(packedNormal);
    26.        #endif
    27.      }
    28.  
    If I use the default UnpackNormal function coupled with a default normal map (as per Unity definition) all looks fine. Damn.

    edit:
    Confirmed. If I remove our asset importer and replace the lines that do the swizzling with
    unpackedNormal.xyz = packedNormal.xyz * 2 - 1; AND make sure bypass sRGB sampling is activated under the Advanced texture import settings all is well.
    And all this just to get a blendmask map into our normal maps' alpha channel.
    Strangely that code above worked just fine in Unity 4.

    edit:
    Ok. bypass rRGB was all that's needed to get the above code working when the texture is set to RGBA Compressed DXT5. Looks like that's one of the settings "hidden" from us by setting a regular texture to Normal map mode.
     
    Last edited: Aug 7, 2015
    IFL likes this.
  29. KWaldt

    KWaldt

    Joined:
    Nov 1, 2013
    Posts:
    127
    Thank you for the suggestion, I appreciate it!
    The idea was nice, however, it didn't work out for me--I tried remapping both Normal Maps and ordinary textures to (0 to 1) [and some different values], but I didn't get the normal map to look right.

    Do you have a different idea?

    Best Regards,
    KW
     
  30. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    Does this help?

    SF_KWaldt01.jpg
     
    KWaldt likes this.
  31. Stevepunk

    Stevepunk

    Joined:
    Oct 20, 2013
    Posts:
    205
    Just downloaded to an empty scene and received this warning:

    "MaterialEditor: Could not create custom UI from the CustomEditor: '' of the shader. Does the class name include its namespace? And does the class either derive from ShaderGUI or MaterialEditor?
    UnityEditor.AssetPreviewUpdater:CreatePreviewForAsset(Object, Object[], String)"
     
  32. KWaldt

    KWaldt

    Joined:
    Nov 1, 2013
    Posts:
    127
    Thank you!
    This looks a lot better already!
    I ran into a weird thing, however--while it looks correct in the shader forge preview window, it's way too light ingame and in the unity preview window.
    (I used the Unlit mode and plugged it into Emission, which should be right since using the normal map colour [#8080ff] instead gives off the right colour, so it's something about the map.)
    Is there something I need to do after remapping to apply the changes?

    Best Regards,
    Kristina Waldt
     

    Attached Files:

  33. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    I get the correct result in-game. I don't know where your colors get messed up. Do you mind showing your node-graph and texture-import settings?

    [EDIT::]
    Have you seen this?
     
    Last edited: Aug 8, 2015
  34. ArthurClark

    ArthurClark

    Joined:
    May 12, 2013
    Posts:
    15
    That's absolutely great! I have a question about this example. Maybe this question already was addressed but I couldn't find it. The question about multiple materials. Let's imagine that I have a character that has a material of its own and I need to apply TV distortion effect to him. This shader is cool but it uses the initial texture and modifies it. How can I modify this shader so it could be applied to a second material on a model? In other words how can I get rid of a texture in that example and take the initial image of a model instead?
     
    IFL likes this.
  35. KWaldt

    KWaldt

    Joined:
    Nov 1, 2013
    Posts:
    127
    I just tested it out in a clean project, and the shading bug appears when setting the Project to "Linear" in the player settings.
    I tried to activate "bypass sRGB sampling", but normal maps don't appear to have that option--guess it should have been done automatically.
    Is it like this for you too?

    Thank you for your help!
    - KW
     
  36. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    I think you'd have to either use a post-process (not ideal) or some method that I don't know about...
    [EDIT::] Oh, you could also offset a bunch of edge-split quads for the character, with each quad's vertex colors having the center-point of the quad's world-position, and using the color for calculating noise. If you used custom normals, you could even maintain smooth edges when the character isn't glitchy. I think that'd actually be the best approach for such an effect since it'd maintain sorting, unlike post-processing.

    You're correct. For linear, try raising the final output to a power of 2.2?
     
    Last edited: Aug 8, 2015
    KWaldt likes this.
  37. KWaldt

    KWaldt

    Joined:
    Nov 1, 2013
    Posts:
    127
    Wow, thank you, using a power node with the texture and 2.2 as value worked perfectly!
    Really appreciate your help, I couldn't have done it without you~

    Best Regards,
    KW
     
    IFL likes this.
  38. imDanOush

    imDanOush

    Joined:
    Oct 12, 2013
    Posts:
    368
    How would I be able to animate (move) normal or alpha maps?
     
  39. popupAsylum

    popupAsylum

    Joined:
    Apr 7, 2014
    Posts:
    119
    I've put together a Pseudo Procedural Terrain shader with Shader Forge that I thought might be interesting to some.
    And there's a pretty detailed blog with pics at http://popupasylum.co.uk/?p=779 that explains about how it's been put together
     
  40. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    @ArthurClark - I did something like a glitchy character, but it looks a bit off...
    SF_3DGlitchyShader.gif
    Change the UVs on the Texture2D node.
    :eek: That looks amazing. Great explanations about everything too.
     
    imDanOush likes this.
  41. Tulrath

    Tulrath

    Joined:
    Feb 1, 2015
    Posts:
    13
    Just downloaded ShaderForge 1.17, and I'm getting the following error:

    NullReferenceException
    UnityEngine.Material..ctor (UnityEngine.Shader shader) (at C:/buildslave/unity/build/artifacts/generated/common/runtime/ShaderBindings.gen.cs:168)



    I have Unity 5.1.1f1 64-bit, running Windows 7, ATI Mobility Radeon HD4200. I created a new project, imported a cube mesh (from Blender) with 1 UV channel, created a new material, applied the material to the cube, created a new shader in shader forge, set the material to use the shader forge shader.

    I get this error every time I create a new ShaderForge shader under Unity 5.1.1f1.
     
  42. Vladnes

    Vladnes

    Joined:
    Jul 5, 2014
    Posts:
    51
    Is it possible to make the glass thickness fake? I'm trying this is achieved using different values of refraction at the edge and the middle of the sphere, but using Fresnel fails.

    How to achieve the same window as in the picture?
     
  43. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    9,806
    Try plugging a normal direction node into your lowest fresnel node.
     
  44. Vladnes

    Vladnes

    Joined:
    Jul 5, 2014
    Posts:
    51
    Dont work
     
  45. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    I don't remember the exact fresnel code, but it's something like:
    Max(0, DotStandard(Normal, Normalize(ViewPos - WorldPos)))
    I'm not 100% sure about that though. I've also had trouble with the Fresnel node in refraction before, but remaking it out of nodes isn't too difficult.

    [EDIT::] A quick test... the pseudo-code I posted above is wrong, but it isn't that off:
    SF_GlassBallShader.jpg
     
    Last edited: Aug 11, 2015
  46. Vladnes

    Vladnes

    Joined:
    Jul 5, 2014
    Posts:
    51
    Cool, how did you do it?
     
  47. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    Technically, I don't think this is the right way to do it, but it's quick and does the job well enough. Modified it a bit - it didn't take normals into account before. Also, don't forget to use a reflection probe if you want believable reflections. Hope it helps!

    2 spheres, one smaller than the other, and 2 materials. The sorting is arbitrary so just make the one that renders on top the inside sphere. That could be an issue in deployment, but I'm not a full-time wizard. ;)
    SF_GlassBallShaderGraph.jpg
     
    Vladnes likes this.
  48. Deleted User

    Deleted User

    Guest

    At this point we need multiple pass :-/
     
    IFL likes this.
  49. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    Yeah, I'm very interested in a node-based multi pass shader tool (similar to uShader Engine on AS). I love SF (obviously), but it's not quite cutting it for the more complex shaders...
     
  50. Deleted User

    Deleted User

    Guest

    I more than one time i had to create more materials for combine shaders created in one model, and it's not a light technique.