Search Unity

  1. We've closed the job boards. If you're looking for work, or looking to hire check out Unity Connect. You can see more information here.
    Dismiss Notice
  2. We're running great holiday deals on subscriptions, swag and Asset Store packages! Take a peek at this blog for more information!
    Dismiss Notice
  3. Check out our Unite Austin 2017 YouTube playlist to catch up on what you missed. More videos coming soon.
    Dismiss Notice
  4. Unity 2017.2 is now released.
    Dismiss Notice
  5. The Unity Gear Store is here to help you look great at your next meetup, user group or conference. With all new Unity apparel, stickers and more!
    Dismiss Notice
  6. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  7. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice
  8. Unity 2017.3 beta is now available for download.
    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:
    382
    Hey jesus. still wondering how you did the vector displacement. Would you mind posting a screenshot of the node tree as is ?
     
  2. mb28

    mb28

    Joined:
    Oct 7, 2012
    Posts:
    8
    Is it possible to access submeshes in Shader Forge? I've searched all over and can't seem to find the answer or which node would allow access to this. I'm trying to reduce draw calls and it would be awesome if I could do this through a shader approach.
     
  3. Mister-D

    Mister-D

    Joined:
    Dec 6, 2011
    Posts:
    1,215
    my shader clips shadow , im using unity 2017.1
    what setting do i need to change to remove this error?
    shadowclip.jpg
     
    vbs likes this.
  4. Fenixake

    Fenixake

    Joined:
    Jan 25, 2014
    Posts:
    48
    Do you guys know how to integrate the UnityChan Outline.cg file in shader forge? since shader forge does not have brightness and saturations functions! I need it for an Anime shader
     
  5. Mister-D

    Mister-D

    Joined:
    Dec 6, 2011
    Posts:
    1,215
    after some testing ive found the problem.it has to do something with shadow cascades. turning up shadow cascades to 2 or 4 removes the problem. dont know why tho
     
  6. nbg_yalta

    nbg_yalta

    Joined:
    Oct 3, 2012
    Posts:
    300
    Hi, I've found that created basic particle shader wont read color alpha from particle component, any way to fix?
     
  7. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    342
    Doesn't it just grab vertex color alpha? Or is that the problem?

    I know in some recent versions they added in custom data streams (there should be docs on those somewhere).

    Actually SF has RGB to HSV (and back) nodes. Hue, Saturation and Value (Brightness) are there.

    In the future, can you post more about what you're trying to do - some examples with textures, snippets of the code you want to replicate, etc, even MS Paint diagrams or whatever.
     
  8. nbg_yalta

    nbg_yalta

    Joined:
    Oct 3, 2012
    Posts:
    300
    There is a problem with particle presets, they are getting color from ParticleSystem component, but not alpha values, so I can't use ColorOverLifeTime fade in/out etc... I'm very new to SF and can't find solution
     
    Last edited: Sep 5, 2017
  9. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    342
    Which Unity and SF version are you on? I've previously gotten color over lifetime, etc to work fine, weird that it wouldn't be working now.

    EDIT:

    Just noticed Shader Forge is part of the sale on the Asset Store - $24 down from $40.

    On a similar note, also on sale are:

    Arcolib - used for AR stuff, track markers, and the like. Sorta like Vufloria (sp?) but at a good price and without the draconian EULA and mandated book-keeping/audit bs that put a lot of people off.

    Deepsky Haze - very good fog/haze/mist component. Really easy to use, and looks pretty nice.

    Releif Terrain Pack - sorta the de facto Terrain Shader upgrade. Can be a bit clunky, not as bad as some but not something you just get straight into, especially if you plug it into MapMagic (like me) but when the stars align and the sacrificial goat ends, it's all worth it.
     
    Last edited: Sep 6, 2017
  10. nbg_yalta

    nbg_yalta

    Joined:
    Oct 3, 2012
    Posts:
    300
    Im using the lastest ones, 2017.1 and 1.38
     
  11. jack021457

    jack021457

    Joined:
    Mar 18, 2015
    Posts:
    18
    Hi all,
    I am a newbie for SF. I encountered a problem. It was when i opened the "Lightmap & light" option. Baked lightmap will appear strange dark spots on windows standalone and mobile device. But in Unity Editor is not appear. The shader itself is simple. I do not know where the problem is. I will upload some of my parameter configuration. Please help me, thank you.
    Dark spots.png lightling.PNG scene.PNG windows.PNG
     
  12. jack021457

    jack021457

    Joined:
    Mar 18, 2015
    Posts:
    18
    Hope anyone have any ideas tell me, Thanks
     
  13. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    432
    Hi,
    does any know if SF supports Texture2DArrays?

    thank you.
     
  14. gtaharaedmonds

    gtaharaedmonds

    Joined:
    Sep 12, 2016
    Posts:
    3
    That water is amazing, and exactly the look I want for my game. Could you make a tutorial or put it on the asset store? Thanks.
     
  15. deadlycrow

    deadlycrow

    Joined:
    Feb 10, 2014
    Posts:
    101
    Hey, i've done a quite similar asset in the past :), its on the asset store, look for DCG water, PM me if you want a voucher ;)
     
  16. vivredraco

    vivredraco

    Joined:
    Jan 19, 2016
    Posts:
    13
    I've been looking at Uber & RTP, and I've been looking at ShaderForge, and I've been trying to figure out if getting SF would supplant the need for Uber/RTP. Can it create shaders with effects like POM, perlin noise, triplaner shading, height-based blending, etc.? I realize it would take some work, whereas Tomasz's shaders do all that out of the box, but basically, if I'm willing to put in the elbow grease, could I build shaders in ShaderForge to use in place of purchasing those assets?
     
  17. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    342
    While making shaders works well with SF, working with the terrain system isn't going to be something you'll enjoy. I have made shaders with SF that can be applied to the terrain in Unity, but it's not something I'd do unless I had to. Unity Terrain's only update since Unity 2.x is they changed the default material to not look so bad with PBR-ish inputs, and to be honest that was a single shader/material change, not a system change.

    The main problem you'll have to work through are:

    Getting the shader to accept textures as needed, in the right order, from the right source, with the right number of passes and names.

    Getting good normal information. This includes getting the tangent and binormals right so your normal maps don't get flipped.
     
  18. vivredraco

    vivredraco

    Joined:
    Jan 19, 2016
    Posts:
    13
    Thank you, Jesus! Sounds like RTP is definitely worthwhile just to avoid that pain. What about parallax occlusion mapping with self-shadowing on normal, non-terrain meshes? Would that be hard to do?
     
  19. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    342
    Hard yes, very, impossible, probably not, no.

    Both of those things (shadowing is basically just occlusion) rely on stepping through multiple samples from point a to point b checking itself and then choosing when to trigger occlusion/etc, neither of which shaders are great at in general, and neither of which SF was built to do.

    You might be able to get somewhere with the code node and writing a loop from there, but it's not a beginner's topic.
     
  20. vivredraco

    vivredraco

    Joined:
    Jan 19, 2016
    Posts:
    13
    Gotcha. Good to know. Thanks so much for taking the time to answer my questions.
     
  21. JackalopeConspiracy

    JackalopeConspiracy

    Joined:
    Mar 12, 2015
    Posts:
    31
    I followed a tutorial on how to make a BRDF shader in Shader Forge and it came out looking nothing like it was supposed to. Anyone know what I did wrong or maybe this has to do with changes in SF or Unity? I'm using Unity 2017 and SF 1.38.
    upload_2017-9-10_23-54-55.png
     
  22. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    342
    scroll down this page, and replicate it exactly as you see there. Remember the tip about setting the BRDF tex to clamp mode. See if that works.

    https://forum.unity3d.com/threads/shader-forge-a-visual-node-based-shader-editor.222049/page-54
     
  23. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    342
    (wouldn't allow me to edit, chrome threw an security error when I tried to hit the 'more options' button...) Website plz

    Got the tiling working better, less chance for a sharp pixelated edge occurring randomly and better control in the material for the tiling properties.

    For this I gave it a tile atlas, 2x5 grid (can support any arbitrary int grid of tiles, also have 3x2, 4x4, etc)

    Just realized that you probably want a 3x3 or 4x4 grid (or any grid with 8 or more tiles) otherwise you have a 100% chance of 2 of the same tiles being next to each other. Not that it can't happen with more tiles, but with just say 4 tiles there's no way you can arrange them to not have 2 identical tiles next to each other.

    strange_bathroom_tiles.jpg.tiff.png
     
  24. JackalopeConspiracy

    JackalopeConspiracy

    Joined:
    Mar 12, 2015
    Posts:
    31
    Thanks!

    EDIT:
    Okay so I copied the BRDF with clamped texture as suggested in the link. But I'm still not clear on some things about it.

    So first, it seems like it's impossible to get the full range of color on the sphere? I have a range from dark blue/purple to yellow and red, but I can really only get the dark colors or the light colors at a time, never the full range.

    [​IMG]

    Also it does not seem that this BRDF reacts to light attenuation like the version I posted is supposed to. Why doesn't it? I hooked the light attenuation node into the multiple at the end.

    Also while it's useful to have an alternative recipe would someone be able to explain to me why the original one I posted doesn't work? I'm trying to make sure I understand what I'm doing, not just how to do it.
     
    Last edited: Sep 11, 2017
  25. JackalopeConspiracy

    JackalopeConspiracy

    Joined:
    Mar 12, 2015
    Posts:
    31
    Also why aren't more of these recipes in this forum on the wiki? Everything on the wiki is super outdated and there's a bunch of bots overrunning it. It's actually kind of hard to find recipes and tutorials for Shader Forge. The one Udemy course I could find was from the beta. And there's not much on youtube either. For something that seems so widely used, I don't know where to get resources for it very easily.
     
    hopeful likes this.
  26. JackalopeConspiracy

    JackalopeConspiracy

    Joined:
    Mar 12, 2015
    Posts:
    31
    Sorry to triple post but I've been looking at the two side by side and I think I might have figured some of it out? It seems to me the biggest difference is that the tutorial I read said to use view direction, and the one on the forum calls for using half direction. Why use one versus the other? And how come it looks fine in the tutorial video but not in mine?
     
  27. elettrozero

    elettrozero

    Joined:
    Jun 19, 2016
    Posts:
    123
    Hi, I just downloaded SF and console says:
    Shader warning in 'Hidden/Shader Forge/SFN_Transform': Use of UNITY_MATRIX_MV is detected. To transform a vertex into view space, consider using UnityObjectToViewPos for better performance.
     
  28. JackalopeConspiracy

    JackalopeConspiracy

    Joined:
    Mar 12, 2015
    Posts:
    31
    Hey guys. I asked for some help on the Polycount forum and was able to get the BRDF shader working in Shader Forge mostly correct. Here's a picture for reference.
    [​IMG]

    The only problem is that for some reason the gradient mirrors halfway and then lightens up again. But I set the dot product to positive, so I'm not sure why that is? Anybody have any advice on that?

    Also I don't mean any criticism to Joachim when I commented on the difficulty finding current documentation. I'm more interested in seeing if there's something perhaps that I had missed, or maybe if there was something I could do to help? Is there not a singular repository for Shader Forge recipes so that people can see them and learn from them? Like I said, all the ones on the wiki are a bit old and very basic. Would love to see more stuff from people.
     
  29. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    382
    Try Normalized instead of Positive for the dot product nodes.
     
  30. JackalopeConspiracy

    JackalopeConspiracy

    Joined:
    Mar 12, 2015
    Posts:
    31
    Yeah doesn't work. It ends up looking super weird.

    But I guess it's not a problem? Because it looks weird in the preview window but when I put it in a material and look at in the viewport it works fine. Not sure why it's acting weird like that.

    Now I'm trying to figure out how to recreate the TF2 illustrative rendering shader inside Shader Forge. Woo progress!
     
  31. elettrozero

    elettrozero

    Joined:
    Jun 19, 2016
    Posts:
    123
    Pardon my ignorance, what's BRDF shader?
     
  32. DaDarkDragon

    DaDarkDragon

    Joined:
    Jun 6, 2013
    Posts:
    109
    since he included the source code, what do i need to do to compile it if i make my own nodes/changes?
     
  33. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    432
    Unity use 4 brdf channels to have different effects like reflection specular light etc. In unity you can't create eg. a clear coat shader by default. Means 2 different settings for reflection intensity and specular light intensity
    But you can hack these channels to have a pbr material that does this. Hacking theese channel can cause a lot of problems with other materials.
     
  34. gtaharaedmonds

    gtaharaedmonds

    Joined:
    Sep 12, 2016
    Posts:
    3
    Your water does look really nice, but it won't really fit my game. Mine is very dark and stormy, with huge waves, and also the only thing I'm struggling with now is the foam on the top of the waves!
     
  35. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    382
    thanks :D I used 2 panning vector displacement maps to actually swing the meshes to all sides. It's like a normal map where 1=1 and 0=-1 so the red channel swings the water mesh to left and right and blue channel swings the mesh back and front, where green channel lifts the waves up and down. And you can use the same textures for the normalmap once you invert them with one minus. So here's the water shader in different ambient lighting.

     
  36. elettrozero

    elettrozero

    Joined:
    Jun 19, 2016
    Posts:
    123
    My PBR materials are very dark when lightmap is backed. I read around is not the first time that happens...any solutions?
     
  37. vbs

    vbs

    Joined:
    Sep 8, 2014
    Posts:
    23
    Hi I'm new to shader programming and I'm still trying to figure out all the intricacies of ShaderForce, but I'm trying to make a vertex displacement shader for a terrain like surface (not water). Perhaps even combining it with tesselation based on distance to camera... that can come later. I liked the picture you posted here it looks like (i'm guessing) something very similar to what I'm trying to achieve. Do you have any suggestions or code examples of how you achieved that effect? Thanks!
     
  38. Mister-D

    Mister-D

    Joined:
    Dec 6, 2011
    Posts:
    1,215
    hi
    its just a mesh with textures and detail textures based on splatmap,nothing fancy ;)
     
  39. vbs

    vbs

    Joined:
    Sep 8, 2014
    Posts:
    23
    I've gotten something like this working by basically using this tutorial: http://acegikmo.com/shaderforge/wiki/index.php?title=Normal_Reconstruction
    2017-09-17 15_56_04-Program Manager.png

    It uses both vertex displacement on a pretty low poly mesh as well as tessellation.

    Looks pretty grungy... Could be tweaked based on heightmap texture. Would like to figure out distance based tessellation I think. Also if it's possible to have different layers of textures, perhaps what is called "splat mapping", not yet confident in my graphics vocabulary...
     
  40. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    342
    You probably want to use the 'channel blend' node for that, vbs.
     
    vbs likes this.
  41. Adam-Bailey

    Adam-Bailey

    Joined:
    Feb 17, 2015
    Posts:
    114
    I was a little worried about this given I'm using Shaderforge for a forward rendered project as well, but I'm unable to replicate the issue. Using Unity 2017.1.0f3 with the latest version of Shaderforge I'm getting almost identical results in forward rendering using both the Standard Shader and a Shaderforge shader recreated with your settings.

    [​IMG]

    [​IMG]
     
    hopeful likes this.
  42. vbs

    vbs

    Joined:
    Sep 8, 2014
    Posts:
    23
    Question about using C# to set texture "image" for Shader Forge Texture Asset input type.

    I have the following input for my shader/material. (see screenshot)

    I also have a C# script that generates texture according to some params (also in screenshot), and with regular Unity material it correctly sets the texture when game starts. But I don't know how to make it set the texture for the particular texture fields that I want in Shader Forge... help appreciated. 2017-09-17 21_50_35-texture-script-and-shader-settings.png
     
  43. vbs

    vbs

    Joined:
    Sep 8, 2014
    Posts:
    23
    NVM, found it, they were some params in the shader:

    Code (CSharp):
    1.    
    2. _Heightmap("Heightmap", 2D) = "white" {}
    3. _TextureMap("Texture Map", 2D) = "white" {}
    4.  
    Also this: https://docs.unity3d.com/ScriptReference/Material.SetTexture.html
     
  44. vbs

    vbs

    Joined:
    Sep 8, 2014
    Posts:
    23
    I'm having an issue with my shader, I expected it to be very smooth, since the noise I'm applying is very smooth... but it looks way too artifacty, around the tessellation geometry especially...

    Is there any way to make the tessellation / mesh deformation smoother?

    Here are some screenshots to illustrate the point:

    2017-09-17 22_04_45-Program Manager.png 2017-09-17 22_05_01-Program Manager.png 2017-09-17 22_08_21-Program Manager.png 2017-09-17 22_05_21-Unity 2017.2.0b10-settings-with-texture-and-heightmap.png 2017-09-17 22_12_41-proc_rpg_-SF.png
     
  45. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    342
    You're giving it a grayscale texture?

    That'll then only be 8-bits, since all channels are the same, so you've only got 256 'heights' to play with. The problem is when you've got enough tesselated verts between 2 pixels with the same value and they just decide to sit flat and level in the world.

    Usually for this I'd also suggest checking for compression (turn it off in that case) on the texture, but if you're generating it that shouldn't be a problem. Can you try generating it to a different format, with more bit depth? Are you just making a rgb888 or rgba8888 (aka rgb24 or rgba32) image?
     
    hopeful likes this.
  46. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    342
    Sort of on a continued note, you can do what Unity does and use all 3 RGB channels for different parts of depth.

    For beginners mode, this might be R + G + B, and with each having values between 0 and 255, that gets you ~750 levels. Just remap the input to the correct parts (remap (height) from (0) to (255) into (0) to (1) for red, 255-510 for green, 510-765 for blue), and clamp them (clamp, 0, 1) in the script, then in the shader multiply them all by 255 and add them together.

    That's not massively efficient, though massively easy, but if you're game you can do the same 16-bits-across 2 channels as Unity does with their normal calculations. 16 bits should get you approx 65k positive integers, or about 650m with centimeter resolution, or 64m with millimeter resolution, which I think even Bill Gates will tell you is as much if not more than you'll ever need.
     
    hopeful likes this.
  47. vbs

    vbs

    Joined:
    Sep 8, 2014
    Posts:
    23
    I'm creating my texture like this in C#, however, I can also load any texture asset, and tessellation creates the same artifacts...

    Code (CSharp):
    1.  
    2. void Start()
    3.     {
    4.         // Set up the texture and a Color array to hold pixels during processing.
    5.         noiseTex = new Texture2D(pixWidth, pixHeight, TextureFormat.RGB24, false);
    6.         pix = new Color[noiseTex.width * noiseTex.height];
    7.         rendererComp = GetComponent<Renderer>();
    8.         rendererComp.material.mainTexture = noiseTex;
    9.         rendererComp.material.SetTexture("_Heightmap", noiseTex);
    10.         rendererComp.material.SetTexture("_TextureMap", noiseTex);
    11.  
    12.         CalcNoise();
    13.     }
    14.  
    15.     void CalcNoise()
    16.     {
    17.         float nWidth = noiseTex.width;
    18.         float nHeight = noiseTex.height;
    19.         // For each pixel in the texture...
    20.         for (int y = 0; y < nHeight; y++)
    21.         {
    22.             for (int x = 0; x < nWidth; x++)
    23.             {
    24.                 // Get a sample from the corresponding position in the noise plane
    25.                 // and create a greyscale pixel from it.
    26.                 float xCoord = xOrg + (float)x / nWidth * scale;
    27.                 float yCoord = yOrg + (float)y / nHeight * scale;
    28.                 float sample = Mathf.PerlinNoise(xCoord, yCoord);
    29.                 pix[y * (int)nWidth + x] = new Color(sample, sample, sample);
    30.             }
    31.         }
    32.         // Copy the pixel data to the texture and load it into the GPU.
    33.         noiseTex.SetPixels(pix);
    34.         //noiseTex.SetPixel(50, 50, Color.white);
    35.         //noiseTex.SetPixel(310, 310, Color.white);
    36.         noiseTex.Apply();
    37.  
    Here are more screenshots, this time with a texture loaded from assets.

    I'll experiment a bit with different image textures. But I've also noticed that ShaderForge has two tesselation options, normal and Edge Length based, I've been reading https://docs.unity3d.com/Manual/SL-SurfaceShaderTessellation.html and was curious about Phong Tesselation, seems like it would be better at smoothing the surface...

    2017-09-18 09_23_25-Unity 2017.2.0b10 .png 2017-09-18 09_24_28.png
     
    Last edited: Sep 18, 2017
  48. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    65
    Hi all,

    A quick question, is it possible to disable the preview window?

    The Shader Forge preview always use a red-ish light, which AFAIK, is not possible to turn off?

    So can I just disable the preview, and adjust the shader by putting the Editor along side my Scene view and tune my shader that way?
     
  49. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    65
    One more question:

    Does Shader Forge actually support macOS Metal Editor?

    I am seeing all sorts of rendering problem like a simple diffuse texture not being applied (can reproduce it even with default Lit PBR shader).

    I am using Unity 2017.1
     
  50. chippwalters

    chippwalters

    Joined:
    Jan 25, 2017
    Posts:
    57
    Are you trying to bake textures? If not, please try and see what you get.