Search Unity

Shader Forge - A visual, node-based shader editor

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

  1. leolodreamland

    leolodreamland

    Joined:
    Jun 15, 2015
    Posts:
    3
    i have something i need to know - how do i mix two textures with different uv maps to the same shader? one is spherical and one is shrinkwrap... do i store the two uv sets in the mesh or what?
     
    AlanMattano likes this.
  2. leolodreamland

    leolodreamland

    Joined:
    Jun 15, 2015
    Posts:
    3
    that's what i'm asking - those choices from the drop down are from the mesh?
     
  3. leolodreamland

    leolodreamland

    Joined:
    Jun 15, 2015
    Posts:
    3
    and if they are, why are there four in the dropdown? if i import most mesh types, unity preserves only two. how do i edit these maps? e.g. how do i convert a shrinkwrap uv map to a uvcoord red-green map?
     
  4. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    UV is from the mesh. Unity5 increased the number of accessible UV maps by 2. Not sure how you create those extra 2 maps, but I'd be surprised if you really needed them. You shouldn't need to convert UV maps. The red/green is simply XY of the UV map going from 0,0 (0 red, 0 green) to 1,1 (full red, full green). Hope that helps.
     
  5. oceanq

    oceanq

    Joined:
    Apr 10, 2015
    Posts:
    22
    Here's a node tree for tiling inside UV atlases (handy for terrain, for a bunch of NPR effects, etc). Posting it here in case anybody finds it useful:



    It's pretty straightforward:
    1. scale your UV's for tiling
    2. take the frac of that
    3. scale the results down by your atlas size (since I've got 4 tiles in my atlas, it's .5)
    4. offset with a vector 2 into your atlas. (0, 0.5) pushes up to the top left tile).

    I'm sure that there are tricks to mitigate seams and mip artifacts, but I haven't figured them out yet...
     
    Last edited: Aug 13, 2015
    crudeMe and KWaldt like this.
  6. oceanq

    oceanq

    Joined:
    Apr 10, 2015
    Posts:
    22
    Here's a technique I've been using for shaders that use time to animate stuff - rather than using the (fairly expensive) Sin function or the uglier triangle and sawtooth waves you get from Frac, I've been baking my time function into a texture and offsetting it to get a value:



    You can bake in whatever function you want - I've been using it for easing in and easing out, for noisier waves, for waves that change frequency, etc.
    To get extra fancy, you can vary them along V and incrementally pan upward, basically reading it like a raster pattern.
     
    Last edited: Aug 13, 2015
    crudeMe and FreakForFreedom like this.
  7. imDanOush

    imDanOush

    Joined:
    Oct 12, 2013
    Posts:
    368
    Hello. I was wondering if someone help and tell me how to make a Flip Book shader with shaderforge? Thanks in advance.
     
  8. DeadNinja

    DeadNinja

    Joined:
    Jun 3, 2013
    Posts:
    39
    Recently hack together a few chromakey shaders for my current project and want to share the most usefull one with community in case someone needed it )
    sf_chromakeyhsv_8132015.png
     
  9. neroziros

    neroziros

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

    I was wondering, anyone knows if forward rendering + HDR isn't working anymore in Unity5? I have been trying to do a simple glow effect but it only works in deferred rendering + HDR :(

    Cheers
     
  10. Sinaz20

    Sinaz20

    Joined:
    Nov 16, 2009
    Posts:
    53
    Hey guys... I have a couple questions... I'll try to break them down as specifically as possible.

    1. We are using Candela SSRR, and we've got it working great with Shader Forge built PBR shaders. However, I am having trouble developing a water shader. We have most of our environment assets rendering in deferred. As such, we have to use screen color to create refractions. For the most part, this works great, except that it seems that plugging screen color into the either the albedo or emissive blows out the reflection rendering from Candela.

    I don't expect Candela support here, but I was hoping someone might be able to ELI5 as to any caveats I should know about using screen color and how it may effect SSRR so that I can try to engineer shaders around that.

    We currently either get nice watery perturbed reflections -OR- nice watery perturbed refractions. But not both. I also lose any sense of specularity when I use screen color.

    2. Has anybody made any water shaders in Shader Forge they would like to share the graph for? I am designing an indoor fountain. I'd like to compare my approach to others.

    3. What's the best way to blend normal maps. I've been referencing a UDK guide on water shaders, and they do a lot of multiplying of different normal maps... which seems to really dull the results. I haven't been able to come up with a better solution yet. Any ideas?

    Using this:
    ( http://www.hourences.com/ue3-water-indoors/ )
     
  11. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    433
    Last edited: Aug 14, 2015
  12. KWaldt

    KWaldt

    Joined:
    Nov 1, 2013
    Posts:
    127
  13. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    433
    Solved lol. What a shame. Thank you :D
     
    Last edited: Aug 14, 2015
  14. DeadNinja

    DeadNinja

    Joined:
    Jun 3, 2013
    Posts:
    39
    Sinaz20 likes this.
  15. DeadNinja

    DeadNinja

    Joined:
    Jun 3, 2013
    Posts:
    39
    bariscigal, ZJP and Marco-Sperling like this.
  16. DeadNinja

    DeadNinja

    Joined:
    Jun 3, 2013
    Posts:
    39
    Same here, SF is great for quick hack some shader, but begin show many limits to me as i advance deep to render pipe from day to day. Im currently developing designer tool (in my spare time so not so fast) for all type of shaders (compute, multipass, geometric, render chains etc.) and soon will open wip thread.
     
  17. Studio_Akiba

    Studio_Akiba

    Joined:
    Mar 3, 2014
    Posts:
    1,421
    Anyone worked with Triplanar here before? I have read the documentation and example found here:
    http://acegikmo.com/shaderforge/wiki/index.php?title=Triplanar_Mapping

    But it doesn't seem to work very well.
    I am looking for a way to apply a wood texture to a desk without UV unwrapping it (VERY complex geometry) as it would take a long time to do.

    Does anyone know how to use the PBR setting with a triplanar shader (with diffuse and normal)?
     
  18. RogueCode

    RogueCode

    Joined:
    Apr 3, 2013
    Posts:
    230
    I'm trying to create the standard Unity Skybox Cubemap shader in SF but can't figure it out. Could anyone possible help me out?

    I first tried creating nodes to replicate it, but got stuck figuring out the float2x2 in RotateAroundYInDegrees. Then I tried just copying the whole RotateAroundYInDegrees method into a code node, but can't figure out where to get v.vertex from, or how to use the output.

    (You may have gathered, shaders are not in my skillset ;-) )

    Code (CSharp):
    1. Shader "Skybox/Cubemap" {
    2. Properties {
    3.     _Tint ("Tint Color", Color) = (.5, .5, .5, .5)
    4.     [Gamma] _Exposure ("Exposure", Range(0, 8)) = 1.0
    5.     _Rotation ("Rotation", Range(0, 360)) = 0
    6.     [NoScaleOffset] _Tex ("Cubemap   (HDR)", Cube) = "grey" {}
    7. }
    8.  
    9. SubShader {
    10.     Tags { "Queue"="Background" "RenderType"="Background" "PreviewType"="Skybox" }
    11.     Cull Off ZWrite Off
    12.  
    13.     Pass {
    14.        
    15.         CGPROGRAM
    16.         #pragma vertex vert
    17.         #pragma fragment frag
    18.  
    19.         #include "UnityCG.cginc"
    20.  
    21.         samplerCUBE _Tex;
    22.         half4 _Tex_HDR;
    23.         half4 _Tint;
    24.         half _Exposure;
    25.         float _Rotation;
    26.  
    27.         float4 RotateAroundYInDegrees (float4 vertex, float degrees)
    28.         {
    29.             float alpha = degrees * UNITY_PI / 180.0;
    30.             float sina, cosa;
    31.             sincos(alpha, sina, cosa);
    32.             float2x2 m = float2x2(cosa, -sina, sina, cosa);
    33.             return float4(mul(m, vertex.xz), vertex.yw).xzyw;
    34.         }
    35.        
    36.         struct appdata_t {
    37.             float4 vertex : POSITION;
    38.         };
    39.  
    40.         struct v2f {
    41.             float4 vertex : SV_POSITION;
    42.             float3 texcoord : TEXCOORD0;
    43.         };
    44.  
    45.         v2f vert (appdata_t v)
    46.         {
    47.             v2f o;
    48.             o.vertex = mul(UNITY_MATRIX_MVP, RotateAroundYInDegrees(v.vertex, _Rotation));
    49.             o.texcoord = v.vertex;
    50.             return o;
    51.         }
    52.  
    53.         fixed4 frag (v2f i) : SV_Target
    54.         {
    55.             half4 tex = texCUBE (_Tex, i.texcoord);
    56.             half3 c = DecodeHDR (tex, _Tex_HDR);
    57.             c = c * _Tint.rgb * unity_ColorSpaceDouble;
    58.             c *= _Exposure;
    59.             return half4(c, 1);
    60.         }
    61.         ENDCG
    62.     }
    63. }    
    64.  
    65.  
    66. Fallback Off
    67.  
    68. }
    69.  
     
  19. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    @RogueCode
    I'd say the code above does not translate very well into a SF shader since there is no user controlled separation of vertex, fragment or geometry shaders available in SF. It tries to figure out what you want when you connect certain Inputs to the main node and automatically builds appropriate vertex and fragment functions.
    You could try to push some of the code above into the automatically built vertex function by mimicing the RotateAroundYInDegrees code and letting it flow into the vertex offset Input of the main node. But since you don't want it to be an offset to the original skybox vertex you Need to switch the SF shader to absolute mode when dealing with vertex modifications (somewhere on the Panel beneath the shader preview).
     
  20. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    I'd use Alpha clipping with dithering in this case, to avoid the sorting issues
     
  21. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Yeah it's CPU based, which is terrible. I should look into making them on the GPU instead
     
    IFL likes this.
  22. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    You can specify if you want roughness or gloss (Inverted roughness) in the lighting settings
     
  23. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Apologies for my lack of response lately, I've been all wrapped up in projects. We're still a tiny company of two at Neat Corp, currently running 5 projects at once, having just finished the sixth one last week!
    I'm going to have to find a good way to schedule the time for SF and the other projects, especially when one of the other projects is so exciting I want to work on it all the time!

    Today I'll work on SF anyhow, possibly releasing 1.18 as well, here are some of the coming features:
    • Added node: HSV to RGB
    • Added node: RGB to HSV
    • Color fields can now be tagged as HDR, making the inspector use a HDR color picker instead

    I'll also squeeze in a node for getting a part / sub UVs of an atlased texture :)
    I may have time to add support for stenciling and Unity GUI shaders as well, but we'll see!

    Also, a big thanks to all of you who are helping others in this thread! I couldn't keep up with it all on my own!
     
    IFL likes this.
  24. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    @Acegikmo - did you ever decide one way or the other if you were going to open up the api for custom nodes, or even a partial amount of the source to let us help with SF development? I know you've somewhat addressed it before, but I was wondering if anything had been decided (or if I missed/forgot anything you said about it).
     
  25. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    I'm currently leaning towards making it open-source for select developers. The "API" for custom nodes is quite bad, so it can't really be made public to just about everyone, since it will cause more issues than it will solve.
     
    IFL likes this.
  26. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    433
    Hi, I'm trying to make a sprite looks like build-in Sprites/Diffuse. But there's only 1 light can affect the sprite at the same time. How to fix that? Please help, thanks :)
    Node:
    sf_node.png

    Result:
    sf_result.png
     
  27. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    There shouldn't be issues with PBR and triplanar... What are you seeing that's wrong?

    I think this could look great for a really stylized approach, but in other cases I think it would look strange if the fur only exists on the edge of the mesh instead of fading into it. But for a painted/inked look, it would be awesome.

    In your project's Quality Settings, is your PixelLightCount set to higher that 1? I couldn't reproduce what you're showing.
     
    zhuchun likes this.
  28. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    433
    Indeed! I forget that unity is using currently select quality level as editor quality, oops :p Thank you!
     
  29. petey

    petey

    Joined:
    May 20, 2009
    Posts:
    1,824
    Hi there,

    Just wondering if anyone could help me out, I'm getting a Shader Unsupported: error on iOS9 with this super simple shader. Works on iOS8 devices so it could just be a beta thing, but if anyone knows a way to get it working it'd be great.

    Screen Shot 2015-08-18 at 2.20.40 pm.png


    Thanks,
    Pete
     
  30. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Strange - what errors are you getting?
     
  31. petey

    petey

    Joined:
    May 20, 2009
    Posts:
    1,824
    WARNING: Shader Unsupported: 'Shader Forge/SolidColourFade' - All passes removed
     
  32. petey

    petey

    Joined:
    May 20, 2009
    Posts:
    1,824
    Hey thanks for the quick response!,
    It's been that way since I switched over to the iOS9 beta.
    I'm using Shader Forge 1.16, Forward rendering, Unity 5.1 and building through Xcode 6 or 7 (same result).
    I uploaded the shader incase you have a chance to look at it.
    Thanks
    Pete
     

    Attached Files:

  33. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Looks like you're excluding renderers that you may need. Add gles3 and metal under the shader settings
     
  34. petey

    petey

    Joined:
    May 20, 2009
    Posts:
    1,824
    Awesome! That looks like it, thanks :)
     
  35. VirtusH

    VirtusH

    Joined:
    Aug 18, 2015
    Posts:
    95
    I'm having a strange issue where certain faces are black whenever the Normal input is used.

    Issue:
    https://gyazo.com/6964ab81d8cca423deaf28c28f6f815d

    The standard shader has no issues, but my wip shader does only if I connect something to the normal input. Out of curiosity, I restarted Unity and tried using one of the shader examples. Any example shader that uses the normal input has the same issue.

    Aside from this, thank you for this fantastic asset, I love Shader Forge!
     
  36. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Shader Forge 1.18 is now out!



    • Added node: HSV to RGB
    • Added node: RGB to HSV
    • Added node: Inverse Lerp
    • Added node: UV Tile - useful for getting sub-UVs for spritesheets/tilemaps)
    • Added node: Face Sign
    • You can now use the stencil buffer
    • You can now select ArcTan2 range: [-Pi to Pi], [-1 to 1], [0 to 1] and [0 to 1 Wrapped]
    • You can now tag Color fields as HDR, making the inspector use a HDR color picker instead
    • The shader inspector now contains all info from Unity's default shader inspector
    • Double-sided shaders no longer have false-positive facing artifacts along edges
    • Fixed a bug where lights weren't masked by fog
    • Fixed a bug where you couldn't undo the dot product type setting

    Odd! Not sure why that would happen. Does Unity's built-in shaders have the same issue, if you assign a normal map, for instance? If other shaders give the same odd behavior on the mesh, I would guess the issue is in the mesh rather than the shader
     
    Last edited: Aug 18, 2015
  37. VirtusH

    VirtusH

    Joined:
    Aug 18, 2015
    Posts:
    95
    Unity's built-in 'Standard' shader was what I meant when I said "standard shader", so yes it works fine using the built-in shaders.
     
  38. Vicnent

    Vicnent

    Joined:
    Mar 21, 2013
    Posts:
    4
    UV Tile seem to be cool.
    Does it possible to use UV Tile to make Tiles with a part of a Atlas ?

    PrtScr capture.jpg
     
  39. Deleted User

    Deleted User

    Guest

    I can now confirm that shader forge is becoming really something of greatest.

    Now missing only the chimera of shading art......the multiple pass :-/
     
    Acegikmo likes this.
  40. Studio_Akiba

    Studio_Akiba

    Joined:
    Mar 3, 2014
    Posts:
    1,421
    My main issue is the normal maps, they don't appear on the model or material.
    I have attached the shader to this post, I think I have done it right, but I don't use any advanced node shaders very much so dont have that much experience with it.
     

    Attached Files:

  41. CleverNickname

    CleverNickname

    Joined:
    Aug 18, 2015
    Posts:
    16
    I'm considering purchasing Shader Forge, but I have a question. I'm trying to implement a specific effect (http://forum.unity3d.com/threads/tr...-between-materials-depending-on-light.348446/), but in order for it to work properly I need to make blending calculations based on the total amount of lighting on a surface, rather than making the calculations per-light and then blending them together after. Does Shader Forge have a way of making calculations based on the sum of all lights together?

    Alternately, does Shader Forge support doing grab passes? A few Google searches seem to imply that it does but I can't find any details on the specifics of what it can do beyond that. Could I render a lighting-only pass, grab it into a texture, and use that as a lookup map for blending textures together?
     
  42. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    Quickly tested your shader. The normals show up fine for me, though there might be an issue of normal-directions on the negative axes.
     
  43. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    It hasn't been possible in the past, but it might be possible now with the stencil buffer support

    It does support that, yes!
     
  44. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    sf_newshader_8182015.png
     
    kilik128, Vicnent and zyzyx like this.
  45. Deleted User

    Deleted User

    Guest

    @Acegikmo

    I never had the opportunity to ask if you have a public roadmap for future implementations of SF (like those of Unity)
     
  46. Studio_Akiba

    Studio_Akiba

    Joined:
    Mar 3, 2014
    Posts:
    1,421
    I would like to second this, if you do have one in place, I would love to take a look.
    A slightly off-topic suggestion/request: Could you make more examples/tutorials for Shader Forge for doing some more advanced things that are useful in games such as particle refraction for fire particle systems?
     
    Deleted User likes this.
  47. Deleted User

    Deleted User

    Guest

    Exactly, a bit more of openness on the world of SF.
     
  48. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    Labyrith Studios - Did you figure out the normals issue you were having with your triplanar shader above?

    H92 & Labyrith Studios - Aside from multi-pass support and more examples, what are you wanting in SF that isn't there? I've got my own list of things I'd like to see, but I'm curious as to what others are thinking.
     
    Deleted User likes this.
  49. CleverNickname

    CleverNickname

    Joined:
    Aug 18, 2015
    Posts:
    16
    Awesome! I went ahead and got Shader Forge, and I was able to setup pretty much everything I need quickly, except for how to do the grab pass itself. Could you point me to some documentation on this or post an explanation here? I can't find anything through searching.
     
  50. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    http://acegikmo.com/shaderforge/nodes/?search=scenecolor