Search Unity

Shader Forge - A visual, node-based shader editor

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

  1. DigitalAdam

    DigitalAdam

    Joined:
    Jul 18, 2007
    Posts:
    1,204
    I have two gray-scale images; one for Metallic and another for Gloss. How can I use a 2D textures to input those? It seems like it only accepts numeric values or alphas.

    Thanks.
     
  2. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    829
    Connect just one channel to those slots instead of using full RGB. Alternatively, if you don't have any use for other channels and want to actually store grayscale maps in full RGB images, create an Add node, plug R, G and B outputs there, create a Divide node, plug the sum and Value of 3 there, and you'll get a grayscale conversion from RGB that will make DDS compression artifacts less noticeable. Result of that division can be plugged into Gloss, Metallic, and other nodes like that.
     
  3. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    Easiest method would be to create another uv set for your model. Planar mapped to either Z or X axis (if Y is up). Normalized to 0-1 region.
    This would be your gradient.
    This can be done in your modeling application. But it could be done in the shader/Unity, too by making use of the worldPos node - though I can't go into details as I would have to try it out myself first.
     
  4. Studio_Akiba

    Studio_Akiba

    Joined:
    Mar 3, 2014
    Posts:
    1,421
    @Acegikmo Would it be possible to create a "heating up" effect in Shader Forge for use with metal materials?
    The effect I am looking for is this found in the Reset Trailer, the effect can be seen at 2:30 where a battery power unit is activated, and slowly turns an amazing looking red hot.
    After seeing this I instantly fell in love with it, I don't mind how long it takes, and would not mind working with anyone to make this.
    Anyone with information on how to create an effect like this, please reply to this.

    Thanks.

     
  5. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    A: Do you mean world-space UV mapping or world-space object scale? Both are simple.
    B: Depth Blend node.

    Texture-based Emission... If you go to make one, use the inverse of an occlusion map with hand-painted additions.
    [EDIT::] Here's a proof of concept.
    SF_Heat.gif

    SF_HeatShader.jpg
     
    Last edited: Sep 5, 2015
    MarkusGod likes this.
  6. Studio_Akiba

    Studio_Akiba

    Joined:
    Mar 3, 2014
    Posts:
    1,421
    Thanks @IFL I'm going to give this a go when I get back onto my dev pc.

    ------------------

    Is there a way to add the following maps together:
    Basecolor (Albedo (Diffuse))
    Metallic
    Normal
    Roughness

    This is the output for the PBR maps in Substance Designer 5.
     
  7. charmandermon

    charmandermon

    Joined:
    Dec 4, 2011
    Posts:
    352
    I think I hit a wall with shader forge for the past few projects I have used it on it has been fantastic. What I am working on now is trying to make a shader that auto checks vertex normal, then textures based on local height (y) and normal ranges with blending. I can't seem to get any of the normal code to work. But it could be that when I am creating my mesh I am not setting the normals right as well. I think I may have to make this shader manually. Screen Shot 2015-09-06 at 3.21.57 PM.png
     
  8. Studio_Akiba

    Studio_Akiba

    Joined:
    Mar 3, 2014
    Posts:
    1,421
    UPDATE:
    Since exploring Substance Designer and Painter a little more, I will need a shader that supports the following maps:
    Diffuse
    Normal
    Roughness
    Height
    AO
    Metallic

    Of course my biggest issue at the moment is that the Unity shader model (very similar to the Disney GGX BRDF model) does not seem to support roughness without a little shader trickery.
     
  9. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    That's all doable in SF. Not sure what you're having issues with, but it's doable.

    Shader Forge readily handles roughness. Unity's smoothness is equivalent to 1-roughness as far as I know.
    Every single one of those channels that you listed is a direct connection to the SF main node, aside from Height, which is just a couple of extra nodes.

    Also, Substance Designer allows you to convert maps to whatever you want or create whatever maps for what you want. It's not at all limited to what you've listed. I felt like that needed clarification.
     
  10. MetalBear

    MetalBear

    Joined:
    Sep 17, 2013
    Posts:
    4
    Hi Joachim, first off, as many have stated before: thank you for creating this. I am by no means a programmer and this allows me to go nuts as an artist, without having to poke some coder :p.

    So far I have been able to create whatever I wanted but now I have reached a point where I am truly lost. I have created a lava shader which I am fairly happy with but I would really love it if I can have depth blending working so my lava edges have a stronger emission. I have (I think) no problem understanding the nodes. I can make them do what they are supposed to do. However, the depth test and shader blending options give me trouble. I have read pretty much anything I could find related to shader forge on this topic, but nothing offers any solution or insight.

    Below is how it looks at the moment, but without the glow I want at the mesh intersection.


    When I use depth test: > The result shows lava glowing around intersection edges, but the lava is rendered "inverted".



    With my limited logic I would then say that the depth test should be set to < . Which results in this:


    I would really appreciate any insight to my problem. Advice frome anyone else is ofcourse also very welcome!
     
    Last edited: Sep 7, 2015
  11. Graham-B

    Graham-B

    Joined:
    Feb 27, 2013
    Posts:
    331
    Any idea why my Shader Forge editor still flows from right-to-left? The changelog indicates that it was changed left-to-right as of v1.0. I am using SF 1.06 in Unity 4.6.0. Thanks!
     
  12. MetalBear

    MetalBear

    Joined:
    Sep 17, 2013
    Posts:
    4
    I solved my own problem. Picked alpha blended particle preset and now it works like a charm.
     
  13. FPires

    FPires

    Joined:
    Jan 5, 2012
    Posts:
    151
    Quoting. If anyone has a solution, I'd appreciate.
     
  14. DigitalAdam

    DigitalAdam

    Joined:
    Jul 18, 2007
    Posts:
    1,204
    Does Shader Forge support Phong Tessellation or PN Triangles? I'm looking for a way to smooth and round out a mesh. If not, is that I feature you'll implement at a later date? Thanks.
     
  15. CoderPro

    CoderPro

    Joined:
    Feb 21, 2014
    Posts:
    327
    Is this support for mobile platforms ?
     
  16. jjason08

    jjason08

    Joined:
    May 13, 2015
    Posts:
    15
    Has anyone encountered a problem with reflection since updating unity to 5.2?
    I noticed they had a lot of changes with shaders and reflection probes in the latest update.

    However my custom build shaders with reflection dont look right, they have more of a "baked reflection look" The reflections do not more around anymore and dont seem to be based off of viewing angle anymore.

    I have a build that needs to go out by the end of the week, and I need reflections to behave properly, if anyone has a fix, or any advice on this please let me know.

    Below I linked a little demo of the standard shader behaving properly and reflecting as expected, and next to it I have a simple shader with gloss all the way up with some metallic in it. You can rotate around and see that they do not behave the same.

    https://dl.dropboxusercontent.com/u/69985519/reflectionTest/ReflectionTest9-10.html
     
  17. jjason08

    jjason08

    Joined:
    May 13, 2015
    Posts:
    15
    _______________________

    Ok so I discovered that if i force everything into Deffered rendering it reflects as expected, however my final shader needs to have transparency. So I need to not discover a way to have deffered rendering with transparency with shader forge.
     
  18. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Don't change the depth testing, leave that as default. You're likely just missing a script on the camera that makes it render a depth texture (which is included in SF), if you're on forward rendering. Also, you probably don't want a negative value as the dist input of the Depth Blend node
     
  19. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Not at the moment, not sure if I'll support it later

    http://acegikmo.com/shaderforge/faq/?Q=mobileopt#mobileopt

    You need to use the lighting nodes in the custom lighting input. Outside of that, they're somewhat unpredictable I'm afraid.

    Odd, I'm guessing maybe you downloaded the latest update, but forgot to "install" it?
     
  20. CoderPro

    CoderPro

    Joined:
    Feb 21, 2014
    Posts:
    327
    Hi Joachim,

    I want to make a Color Mask shader with Shader Forge. I am using Unity 5 and latest version of SF. Could you make a tutorial how to make Color mask shader with SF ? Thanks in advanced !
     
  21. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    It depends on what you mean by color mask, you'll have to elaborate a bit more :)
     
    CoderPro likes this.
  22. CoderPro

    CoderPro

    Joined:
    Feb 21, 2014
    Posts:
    327
    I have a car model. I have Mask texture, Occlusion texture, Normal texture. I want to using mask texture + color to pain car with different colors that using color mask. Can you view this asset. I want to like this. And i want to make this shader for mobile that using SF. Please view this:
    https://www.assetstore.unity3d.com/en/#!/content/40952
     
  23. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    That should work fine. Basically use lerp nodes, with the mask in T and the two values in A and B
     
    CoderPro likes this.
  24. CoderPro

    CoderPro

    Joined:
    Feb 21, 2014
    Posts:
    327
    If have time. Could you make a video tutorial for this ? I think its good feature that must show for everyone.
     
  25. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    CoderPro likes this.
  26. oceanq

    oceanq

    Joined:
    Apr 10, 2015
    Posts:
    22
    Here's a little snippet of code to make your quads billboard. Open up your shader in MonoDevelop, and replace the line:

    o.pos = mul(UNITY_MATRIX_MVP, v.vertex);

    With:

    float scaleX = length(mul(_Object2World, float4(1.0, 0.0, 0.0, 0.0)));
    float scaleY = length(mul(_Object2World, float4(0.0, 1.0, 0.0, 0.0)));
    o.pos = mul(UNITY_MATRIX_P, mul(UNITY_MATRIX_MV, float4(0.0, 0.0, 0.0, 1.0)) - float4(v.vertex.x * scaleX, v.vertex.y * scaleY, 0.0, 0.0));

    And your quads will face the camera.

    edit... Hmm, gets all messed up with batching (as it requires the origin to be in the center of the quad)...
     
    Last edited: Sep 12, 2015
  27. Graham-B

    Graham-B

    Joined:
    Feb 27, 2013
    Posts:
    331
    I am certain I have installed the latest update from the Asset Store. I just created a fresh project in Unity 5, and downloaded the latest SF from the asset store. Created a new shader, and my tree still goes Right to Left... How can I be the only person to have this happen. It doesn't matter what Unity version I use it in, always the same result. Is there no option to switch the orientation?
     
  28. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    There's no way to switch it, no. Can you take a screenshot of SF while you have a shader open?
     
  29. Graham-B

    Graham-B

    Joined:
    Feb 27, 2013
    Posts:
    331
    Screenshot taken in Unity 5:
     
    Last edited: Sep 12, 2015
  30. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    The link seems broken, it's probably a private link
     
  31. Graham-B

    Graham-B

    Joined:
    Feb 27, 2013
    Posts:
    331
    Sorry, updated link.
     
  32. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Right, so, that is correct then :)
    We were just using different terminology
     
  33. Graham-B

    Graham-B

    Joined:
    Feb 27, 2013
    Posts:
    331
    Okay I understand, thanks for clarifying, I was just confused as it seems the majority of screenshots and tutorials I've tried are the other way around.
     
  34. Miltoid_

    Miltoid_

    Joined:
    Sep 13, 2015
    Posts:
    5
    Hello, I recently purchased shader forge and have a question. I maanged to create a shader that blends based on Vertex Colour. However, i am wondering if anyone is aware of a way to create a shader that would blend using height information. So that i could say blend dust in between the cracks of some rock using a heightmap and vertex colour to control the amount.

    Basically, how could i make something like what is shown in this video but using Shader Forge:


    Thank you very much. Any and all suggestions would be beyond welcome. Ta :)
     
  35. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,339
    http://acegikmo.com/shaderforge/wiki/index.php?title=Advanced_Texture_Splatting
     
  36. Miltoid_

    Miltoid_

    Joined:
    Sep 13, 2015
    Posts:
    5
    Thanks, i had seen this but I don't see any vertex blending control in there. It looks like it is all controlled by maps and isn't taking control from vertex colour. I'm still fairly new to this so excuse my ignorance here if i'm missing something or if it is easily implementable. Do you think this could be fudged to use vertex painting?
     
  37. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Just replace the splatmap/colormap by the vertex colors
     
  38. Miltoid_

    Miltoid_

    Joined:
    Sep 13, 2015
    Posts:
    5
    My issue is i would still like to use a splat map but control the the amount of influence it has via vertex colour
     
  39. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    1.19 is now out!
    • Added a post-effect preset
    • You can now switch outline extrude direction between three modes:
    - From origin (Good for convex objects with a centered pivot, bad for concave shapes)
    - Vertex normals (Good for smoothed objects, bad for hard edges)
    - Vertex colors (Good for any object, but requires certain data in the vertex colors)
    • Added a SoftNormalsToVertexColor.cs component, to generate vertex colors for the "Vertex colors" outline direction mode
    • You can now set vertex positioning mode:
    - World Space (default)
    - Clip Space (for full-screen rendering, such as post-effects)
    - Billboard (to make the object face the camera)
    • Fixed a bug where the shader inspector broke in Unity 5.2
    • Fixed a bug where the code node would cause errors and freeze SF in Unity 5.2
    • Fixed a bug where HSV to RGB didn't work properly on some render platforms
     
    Last edited: Sep 13, 2015
  40. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,683
    Happy to see new outline options! As a very low tech user, I appreciate the simple stuff. :)
     
  41. stationx

    stationx

    Joined:
    Jul 9, 2012
    Posts:
    251
    hi!
    How to setup tessellation with triplanes shading?? I have the triplanar working, but the tessellation looks not right.
    Regards! Tom
     
  42. Deleted User

    Deleted User

    Guest

    Someone know how i can make this with SF 1.18?

     
  43. neroziros

    neroziros

    Joined:
    Aug 25, 2012
    Posts:
    129
    Hi all again!

    Is there a way to add outline through shader forge? the outline width and outline color are not working.

    Cheers
     
  44. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    Asset Store doesn't offer me an update to 1.19. Is 5.2 required for it to work? We are still on 5.1.3p1.
     
  45. Deepestblue

    Deepestblue

    Joined:
    May 11, 2009
    Posts:
    48
    Not getting 1.20 either, is it still in review?

    Also, any chance for an update on when (if?) Allegorithmic Substances (as is) will be supported in Shader Forge?
     
    condition6d5489 likes this.
  46. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Yeah, it's 5.2 and above from now on
     
  47. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    Thx for clarification. I wish the Asset Store would show this valuable piece of information about update requirements automatically.
     
  48. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    It would be nice, yeah. It does show which versions I uploaded SF in though, but not at which version they're all at
     
  49. Deleted User

    Deleted User

    Guest

    @Acegikmo

    It is possible to make a preview of camera instead of a mesh? It would be very useful during the creation of the post-effect
     
    Marco-Sperling likes this.
  50. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    Though you would be limited to one call to Graphics.Blit () I guess because SF has no way to tell if you are trying to assemble a whole post effect chain.