Home Unity Store

[RELEASE] Shader Forge - A node-based shader editor for Unity

1121315171821

Replies

  • Acegikmo
    I have a little thing to announce - the Shader Forge userbase is growing every day, and will soon reach a point where I can't keep up, which is awesome! I hope this place can lift some weight off of my shoulders, and help you all help each other, to create, edit, refine, and polish methods of working with shaders in Shader Forge, to spread your knowledge to everyone and learn from others :)

    Feel free to start pages, edit pages, and make this brilliant!

    Shader Forge Wiki

    It's very much in its infancy, I hope we all can collaborate on this project :)
  • Jeza87
    Has someone made a terrain shader using SF? and if so how do you go about putting the material onto the terrain? Because i'm really struggling to find info on it. When i put a SF material onto the terrain it does not display properly, also an error says terrains don't support tangent data or something. Also it looks like the terrain has 2 shaders on it and a certain distance away it's just all black?....Ahhhhh!
    Thanks if someone can help :)
  • Acegikmo
    @Jeza87: Someone just put up a tutorial on the Wiki about terrain shaders: http://acegikmo.com/shaderforge/wiki/index.php?title=Basic_Terrain_Setup

    I personally would just make my own terrain mesh instead of using Unity's built-in one, as it's easier making shaders for your own stuff, but, each to their own :)

    Also, the Code node is coming soon! Hopefully tonight:

    code_node.png
  • Owers
    Offline / Send Message
    Owers polycounter lvl 10
    I just want to thank you for the hard work you're putting into Shader Forge. Creating custom shaders in Unity is essential for almost every project and it's great to see someone committing their time and effort into developing a tool that makes it so much more accessible. The only setback for me so far is the weirdness with alpha clips when using depth-based camera image effects, I hope this is something that'll be fixed eventually. Other than that, I applaud your work and look forward to every update that comes out.
  • McWild
    Acegikmo wrote: »
    1. Buy Unity Pro if you don't have it already, or activate a trial
    2. Set your camera to HDR
    3. Import the image effects standard assets
    4. Attach a bloom script to your camera, and make sure the bloom threshold is set to 1.0
    5. Make a shader that has emissive going beyond 1.0
    6. Look though the game camera and be happy!


    Ahhhhhhhhh oh my god dude. Thanks!!!
  • Skiffy
    Offline / Send Message
    Skiffy polycounter lvl 15
    Hello Joachim,

    Just popping in after seeing the Unity 5 announcment with a very obvious question... :)

    I take it you are considering porting this tool over to the new engine in the near future? Have you had a chance to talk to Unity themselves about what that would entail considering that they now have PBR materials and Realtime GI lighting with enlight? If this was ported to unity 5 I think most folks heads would explode. Otherwise its already made Unity 4 that much more powerful for us artists.

    Cheers!
  • Acegikmo
    While I haven't looked into making it support the real-time GI, SF is actually Unity 5 ready :)

    As in, there are very few changes I need to do when Unity 5 is out in order to support it, so, when Unity 5 is public, SF will work in it within the coming 24 hours, most likely.

    Also, Beta 0.28 is now out! This is possibly the last beta before SF goes 1.0 :)

    New in Shader Forge Beta 0.28:
    • Added node: Code. This allows you to run a snippet of CG shader code (Currently a bit unstable)
    • Added node: Depth. This is the distance from the camera's near plane to the object itself
    • Shader Forge has now been prepared to dynamically load two new nodes from Marmoset's Skyshop plugin
    • You can now drag Substance Materials into Shader Forge, and it will automatically hook up the Diffuse and Normals
    • Comments on properties are now placed better
    • Fixed a bug where the Min and Max nodes displayed too many color channels
    • Fixed a bug where the normal direction was always passed into double-sided shaders, even if unused
  • NexusSteve
    Glad to know Unity 5 support will pretty much be right out of the gate, thanks for keeping it consistently updated :D

    Rather quick question regarding the Outline Width. By default, Z-depth is disabled so the outline will shrink as the camera moves away. I'd like to experiment with a fixed outline width regardless of Z-depth (so the outline always appears as the same size regardless of distance). I've tried a few methods of dealing with calculations applied to view position, however it seems to not work quite right.

    Any suggestions? I know I'm missing something probably super obvious.
  • Acegikmo
    NexusSteve wrote: »
    Glad to know Unity 5 support will pretty much be right out of the gate, thanks for keeping it consistently updated :D

    Rather quick question regarding the Outline Width. By default, Z-depth is disabled so the outline will shrink as the camera moves away. I'd like to experiment with a fixed outline width regardless of Z-depth (so the outline always appears as the same size regardless of distance). I've tried a few methods of dealing with calculations applied to view position, however it seems to not work quite right.

    Any suggestions? I know I'm missing something probably super obvious.

    uniform_outline.jpg
  • NexusSteve
    Perfect, thanks very much Joachim!
  • almighty_gir
    Offline / Send Message
    almighty_gir ngon master
    Acegikmo wrote: »
    @Jeza87: Someone just put up a tutorial on the Wiki about terrain shaders: http://acegikmo.com/shaderforge/wiki/index.php?title=Basic_Terrain_Setup

    I personally would just make my own terrain mesh instead of using Unity's built-in one, as it's easier making shaders for your own stuff, but, each to their own :)

    Also, the Code node is coming soon! Hopefully tonight:

    code_node.png

    duuuude, dat code node...
  • Digitom
    First off. Love this shader plugin. Thanks for making this!

    I was playing around with vector painting, and I managed to make a 3 channel texture shader. RGB channels attached to 3 different textures. I am also trying to make the alpha channel a texture channel as well, but I can't seem to get it to work.

    Any ideas on how to do this?

    Thanks.
  • Digitom
    Thanks for this shader plugin! Great product.

    I was wondering if there was a way to make the alpha channel a texture channel?

    I managed to make the RBG channels work for doing vector paintings, but can't seem to get the alpha channel to work (using the channel blend node).

    any ideas?

    Thanks.
  • Skiffy
    Offline / Send Message
    Skiffy polycounter lvl 15
    Sweet news indeed for Unity 5 Support. This has been one of the best tool additions to unity since playmaker for me!
  • Shadownami92
    Offline / Send Message
    Shadownami92 polycounter lvl 7
    I heard that a long while ago with no real info on it in site, I think they are focusing more on their PBR Ubershader thing that will handle most common shader uses.
  • Acegikmo
    Digitom wrote: »
    Thanks for this shader plugin! Great product.

    I was wondering if there was a way to make the alpha channel a texture channel?

    I managed to make the RBG channels work for doing vector paintings, but can't seem to get the alpha channel to work (using the channel blend node).

    any ideas?

    Thanks.

    The channel blend node currently adds all results together, rather than interpolates, which means your colors needs to be balanced to each other.

    Also, don't forget to Append RGB and A together before using it in the channel blend node.
  • Shrike
    Offline / Send Message
    Shrike interpolator
    Hey Ace

    I have problems with alphas and I cannot find a solution

    I have 2 similar shaders and one uses a very simple alpha input, just a mask
    but the shader randomly dosnt display some of the polygons at all, and it ghosts some parts through even when no mask is there (on the pic the mask is 100% white, still it does that)

    https://hostr.co/wMHdgc09CI2V
    https://hostr.co/6Uv35GkOW4d1

    Blending is at alpha blended, else theres nothing special I did

    I also didnt use the alpha clip channel because it seemed to work binairy
    aka off or on, no values between for some reason, but I recall it working properly some while ago

    Using the 0.27 version

    I also have another question, you say the shaders are only rendered forward, but I dont understand what that actually means. So multiple lights affecting the surface are expensive again ? I dont get what the actual downside is
  • Neox
    Offline / Send Message
    Neox veteran polycounter
    alpha clip is only on or off, just 1 bit. you can also refer to it as alpha test. alpha blend on the other hand will use your 8bit input, however sorting soft alphas is expensive and therefore even today not really that often used on 3d assets.
  • Acegikmo
    As Neox said, there's no real solution to that problem yet, your best bet is to go for alpha clipping for now.

    Also, so see the differences between forward and deferred:
    http://docs.unity3d.com/Documentation/Manual/RenderingPaths.html

    Essentially - Deferred is perfect for lots of real-time lights, but is heavily limited when it comes to flexibility in lighting. Forward has a lot of flexibility, but per-pixel lights get expensive quickly, so light count per-object is limited to around 3 lights
  • Jeza87
    Can someone please post how to do PBR using SF? like how to use gloss maps to affect the blurriness of the reflection? I know Ace said something about multiplying gloss by like 7? then plugging it into the MIP of the cubemap but for me this isn't changing anything!
    do i still plug my gloss into the gloss slot in the material?

    If someone could please post a short tutorial :) Thanks!
  • Acegikmo
    Sounds about right. Although you'll need a One Minus node before multiplying by 7, otherwise it'll be reversed.

    Mind that your cubemap also needs Mipmaps. If it's a real-time cubemap, it probably doesn't have them.
  • RealArt
    hi
    i have problem with realtime reflection please help me

    that's work if i use texture2d and surfaceReflection script(PlanerReflection) but if i use cubemap for reflection i cant align reflection with model

    texture2d and surfaceReflection script and ShaderNode:
    11719576317793578316.jpg
    94731645263136482892.jpg
    Camera.RenderToCubemap script and ShaderNode:
    https://docs.unity3d.com/Documentation/ScriptReference/Camera.RenderToCubemap.html
    32300275856877076755.jpg
    68610925704705108413.jpg
  • Shrike
    Offline / Send Message
    Shrike interpolator
    Acegikmo wrote: »
    As Neox said, there's no real solution to that problem yet, your best bet is to go for alpha clipping for now.

    Also, so see the differences between forward and deferred:
    http://docs.unity3d.com/Documentation/Manual/RenderingPaths.html

    Essentially - Deferred is perfect for lots of real-time lights, but is heavily limited when it comes to flexibility in lighting. Forward has a lot of flexibility, but per-pixel lights get expensive quickly, so light count per-object is limited to around 3 lights

    Ah thanks, good to know I did not mess something up with the alpha : )

    I know about deferred and forward but the actual outcome of having forward shaders and deferred mode is abstract
    for me
    Since my project is in deferred, and your shaders only accept forward,
    what is the actual effect ? Having multiple dynamic lights is expensive again when they light your shaders ? Because I placed a lot of dynamic pointlights to enhance specular at places, well usual stuff, and I did not notice a difference. This half defered half forward thing confuses me and our programmers did not know how it actually works in the end aswell.

    So if all our environments only use shader forge shaders, can we just switch to forward since its effectively in forward anyways since everything catching light is SF/forward and we should cut out lights at best?

    Sorry to bother you with so many questions, but I guess its an important matter
  • Polynaught
    Offline / Send Message
    Polynaught polycounter lvl 11
    RealArt wrote: »
    hi
    i have problem with realtime reflection please help me

    that's work if i use texture2d and surfaceReflection script(PlanerReflection) but if i use cubemap for reflection i cant align reflection with model

    texture2d and surfaceReflection script and ShaderNode:

    That's how cubemaps work out of the box. You sample their fragments from infinity. If you want to have reflections that look more natural (as in physically correct) you have to do alot more than sticking a cubemap into your shader and feeding it a view-normal-reflection vector.
    Two topics that cover this area come to my mind: box projected environment mapping http://forum.unity3d.com/threads/113784-Has-any-one-experimented-with-Box-Projection-Correction-Environment-Mapping and Sphere Projected Cubemapping http://forum.unity3d.com/threads/234399-Sphere-Projected-Cubemapping-or-Parallax-Corrected-Cubemap-on-a-Sphere-Volume

    I think both methods need a system in the background that switches cubemaps in the shader on the fly while your camera translates through the scene. Cubemap swapping....

    So, sadly no - there's no easy solution to your wish. :(
  • RealArt
    Polynaught wrote: »
    That's how cubemaps work out of the box. You sample their fragments from infinity. If you want to have reflections that look more natural (as in physically correct) you have to do alot more than sticking a cubemap into your shader and feeding it a view-normal-reflection vector.
    Two topics that cover this area come to my mind: box projected environment mapping http://forum.unity3d.com/threads/113784-Has-any-one-experimented-with-Box-Projection-Correction-Environment-Mapping and Sphere Projected Cubemapping http://forum.unity3d.com/threads/234399-Sphere-Projected-Cubemapping-or-Parallax-Corrected-Cubemap-on-a-Sphere-Volume

    I think both methods need a system in the background that switches cubemaps in the shader on the fly while your camera translates through the scene. Cubemap swapping....


    So, sadly no - there's no easy solution to your wish. :(

    tank's for help Polynaught
    oh Seemed to be very hard to implement
  • Acegikmo
    Shrike wrote: »
    Ah thanks, good to know I did not mess something up with the alpha : )

    I know about deferred and forward but the actual outcome of having forward shaders and deferred mode is abstract
    for me
    Since my project is in deferred, and your shaders only accept forward,
    what is the actual effect ? Having multiple dynamic lights is expensive again when they light your shaders ? Because I placed a lot of dynamic pointlights to enhance specular at places, well usual stuff, and I did not notice a difference. This half defered half forward thing confuses me and our programmers did not know how it actually works in the end aswell.

    So if all our environments only use shader forge shaders, can we just switch to forward since its effectively in forward anyways since everything catching light is SF/forward and we should cut out lights at best?

    Sorry to bother you with so many questions, but I guess its an important matter

    You're correct on all points!

    Shaders can be lit with per-pixel lighting in two ways, either forward or deferred.
    The shaders themselves need to have two setups, one with deferred passes, and one with forward passes.

    When your project (or camera) is set to forward rendering, it will render all shaders that support forward rendering, using the forward passes, which pretty much all shaders have.

    When your project (or camera) is set to deferred rendering, it will render all shaders that support deferred, using the deferred passes, and the rest using the forward passes.

    So yes, you have the light count limitation on forward shaders, even if your project is running deferred.
  • NexusSteve
    Hey guys,

    I seem to be having a small issue with an old shader I'm revisiting. I've created a shader that utilizes two textures; one diffuse texture and a "shadow" texture that allows me to create custom textured self shadows.

    It works fine and dandy, however, with the use of a single light. Once I add a secondary light, it seems the "shadow" texture, blends on top of the lit area. The value of the light controls the intensity of the shadow texture, so if the second light is 0, everything looks normal, if it's set to 1, the overlay becomes bright. Basically, I'm trying to not have the shadow texture appear where light is.

    Here are some examples: Single light, look'n good! (Diffuse = Unity brick texture, Shadow = black and orange grid test texture)
    2rwuv5l.jpg

    Two lights, now we have issues
    2qs6wwk.jpg

    As you can see, the shadow overlays, but the small area where the two lights meet, the shadow texture disappears as normal.

    Here is my shader outline:
    30kvodu.jpg

    Any thoughts would be greatly appreciated :D
  • Acegikmo
    I don't think there's any way of solving that, other than forcing it to only read from one light.
    The reason for this is that the light passes in forward rendering are done per-light, in which case they don't know about the other light sources whatsoever.
  • NexusSteve
    Thanks for the speedy reply Joachim. I'm curious about the light intersection as seen in the second picture. The issue gets resolved by two light sources when they intersect, or is that section being rendered as a single, combined light, thus responding to it in that regard?

    EDIT: So I see what is going on, when I added a third, intersecting light, it applies the texture to the previous two lights, but not the new third light, the process repeats for every new light added. As you said, will only read one light. Really appreciate your help in the matter :)
  • Shuaws
    Offline / Send Message
    Shuaws polycounter lvl 5
    I was wondering if i would be able to do vertex blending with shader forge and use a brush in unity to paint it on, something similar to udk vertex blending. Is this possible
  • Jeza87
    Shuaws wrote: »
    I was wondering if i would be able to do vertex blending with shader forge and use a brush in unity to paint it on, something similar to udk vertex blending. Is this possible

    Absolutely! I made a good vertex blend shader with SF, all you need is the free vertex paint tool from the asset store and the udk node setup can be replicated with no probs. I found that when using the heightmap it's better to have it more "contrasted".
  • Shuaws
    Offline / Send Message
    Shuaws polycounter lvl 5
    @jeza87 alright man thanks a million getting late so im gonna try tomorrow, i just got this today and ive been playing around with it, awesome!!.
  • Acegikmo
    Vertex color blending tutorial: [ame="http://www.youtube.com/watch?v=2ZNJ_KytrE4"]Shader Forge - Vertex color blending & UV tiling - YouTube[/ame]
    Terrain blending info on the wiki: http://acegikmo.com/shaderforge/wiki/index.php?title=Texture_Splatting
  • Acegikmo
    Beta 0.29 is now out! This is (again) possibly the last beta before SF goes 1.0 :)

    New in Shader Forge Beta 0.29:
    • You can now Undo and Redo! As a result; you now need Unity 4.3.0 or later (Previous minimum was 4.2.0)
    • Added node: Posterize. This node will turn smooth gradients into stairsteps
    • Added node: Relay. Outputs its input - useful for organizing connections
    • The Code node can now read from Texture Assets using the sampler2D input type
    • Fixed a bug where the code node didn't compile properly. It's now also using the function name in the code
    • Fixed a bug where the code node's output was pending instead of typed
    • Fixed a bug where node previews sometimes displayed too many color channels
    • Fixed a bug where the Parallax node could cause the shader not to compile
    • Fixed a bug where the version checker didn't work
    • Slightly improved the look of the main node when using the light skin
  • NexusSteve
    Hmm, doesn't seem to update to 0.29 in Unity. When I import the new package, it's still says 0.28.

    The store page description says 0.29 but version number states "Version: Beta 0.28" updated today
    https://www.assetstore.unity3d.com/#/content/14147
  • Owers
    Offline / Send Message
    Owers polycounter lvl 10
    It says version 0.28 on the store page and insists on importing the asset rather than update it, but if I force it to download the asset again in the download manager it imports version 0.29. Very odd, but it seems to work.
  • Acegikmo
    Strange! But, as long as it seems to work, I suppose it's fine :)
  • Acegikmo
    Beta 0.30 is now out, this time it's more of a hotfix for 0.29, as it had a bunch of nasty issues. This is (yet again) possibly the last beta before SF goes 1.0 :)

    New in Shader Forge Beta 0.30:
    • Fixed a bug where the Channel Blend node crashed Unity
    • Fixed a bug where dragging nodes sometimes caused severe lag and memory leaks
    • Fixed a bug where properties were never removed from the property list
    • Fixed a bug where you had to connect to the MIP input when using textures in vertex offset and outline width on OpenGL
  • Acegikmo
    Shader Forge is 50% off today!
    Tell your friends and help make Unity a better place for Shader creation :D

    http://u3d.as/6cc
  • uncle
    Hell, about time to get it...
  • maxivz
    Offline / Send Message
    maxivz interpolator
    Will this be integrated/updated to work with physically based shaders in unity 5 once they come out?
    I am no doubts going to get this!
  • Acegikmo
    Yes, although it already has physically based lighting support :)
  • Shadownami92
    Offline / Send Message
    Shadownami92 polycounter lvl 7
    Fantastic! I just got this, after getting Skyshop on the last big sale I'm feeling pretty lucky with these amazing plugins!
  • NeatWolf
    Offline / Send Message
    NeatWolf polycounter lvl 3
    NexusSteve wrote: »
    Hey guys,

    I seem to be having a small issue with an old shader I'm revisiting.

    [...]
    Two lights, now we have issues
    2qs6wwk.jpg

    Any thoughts would be greatly appreciated :D

    I still haven't checked the whole SF package to know if it is possible (I think it is) but you could also try changing and playing with the blending modes of each single forward add pass to at least get closer to the result you need (in this case they're added one on top of the other, e.g.: Blend One One).

    You may want to tinker with the light pass blending mode to maybe:
    Blend SrcAlpha OneMinusSrcAlpha // Alpha blending
    Blend One One // Additive - current
    Blend OneMinusDstColor One // Soft Additive
    Blend DstColor Zero // Multiplicative
    Blend DstColor SrcColor // 2x Multiplicative

    or setting
    BlendOp Max

    but you of course shouldn't expect the lighting to behave as usual, it is very specific for your use. Maybe you could alpha mask the light or multiply it.

    Another approach would be to have BlendOp set to Max and an extra add pass to draw the wireframe fx, once multi pass shaders will be supported :)

    In case it's not possible (I can only find the global, base blending mode under the Blending Panel), well, it may be a feature request! "Being able to set the forward add blending mode & BlendingOp" :)
    ...if the current implementation makes it possible of course, I can't know it ;)
  • mast
    Hi everyone, if I would like to set up this billboard shader in SF:

    CGPROGRAM

    #pragma vertex vert
    #pragma fragment frag

    // User-specified uniforms
    uniform sampler2D _MainTex;

    struct vertexInput {
    float4 vertex : POSITION;
    float4 tex : TEXCOORD0;
    };
    struct vertexOutput {
    float4 pos : SV_POSITION;
    float4 tex : TEXCOORD0;
    };

    vertexOutput vert(vertexInput input)
    {
    vertexOutput output;

    output.pos = mul(UNITY_MATRIX_P,
    mul(UNITY_MATRIX_MV, float4(0.0, 0.0, 0.0, 1.0))
    - float4(input.vertex.x, input.vertex.z, 0.0, 0.0));

    output.tex = input.tex;

    return output;
    }

    float4 frag(vertexOutput input) : COLOR
    {
    return tex2D(_MainTex, float2(input.tex.xy));
    }

    ENDCG

    How would I go about? I'm trying all sorts of things in the vertex offset node but I'm not getting the result I want. Thank you for your time!
  • MrNinjutsu
    Offline / Send Message
    MrNinjutsu greentooth
    Hey Ace! Loving shaderforge, it's a big help at work :)

    I've come into a bit of a problem; The node tree is gone and I no longer can click on any buttons within the editor, everything else is fine so i assume it's crashed.

    oGzbElN.png
  • Acegikmo
    Strange. What triggered it?
  • MrNinjutsu
    Offline / Send Message
    MrNinjutsu greentooth
    Acegikmo wrote: »
    Strange. What triggered it?

    I'm not sure. But closing down unity entirely doesn't solve it either :/
  • Acegikmo
    Try resetting the unity window layout
  • MrNinjutsu
    Offline / Send Message
    MrNinjutsu greentooth
    Acegikmo wrote: »
    Try resetting the unity window layout

    Sweet! Okay so I've whittled it down to that shader file. I can open other shaders, just not that particular one.

    Edit:

    Okay perhaps not.
1121315171821
Sign In or Register to comment.