Home Unity Store

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

Replies

  • Dvonio
    Offline / Send Message
    Dvonio polycounter lvl 4
    Hey, Is it possible to create a "Detail map" texture in a ShaderForge shader? like the secondary maps on the unity 5 standar shader: bbae1f7fdf.png

    Thanks!
  • Polynaught
    Offline / Send Message
    Polynaught polycounter lvl 11
    @AlecMoody
    But that's pretty much how it is done when you want to multisample a texture asset in SF. Can we see your graph/tree?
  • Crest
    Offline / Send Message
    Crest polycounter lvl 6
    Dvonio wrote: »
    Hey, Is it possible to create a "Detail map" texture in a ShaderForge shader? like the secondary maps on the unity 5 standar shader: bbae1f7fdf.png

    Thanks!

    Hey man all you need to do is to change the drop selection under the UV node
    IuwfJqA.png
  • Dvonio
    Offline / Send Message
    Dvonio polycounter lvl 4
    hey man thanks! much love <3 will try it tomrrow
  • Acegikmo
    Shader Forge 1.14 is now live :)

    sf_114_release.jpg
  • AlecMoody
    Offline / Send Message
    AlecMoody ngon master
    The presets look like a nice addition.
  • Ged
    Offline / Send Message
    Ged interpolator
    great work! always nice to have a good starting point :) thanks
  • AlecMoody
    Offline / Send Message
    AlecMoody ngon master
    One of my recent shaders:
    14.jpg
    alec-moody-8.jpg
  • Ged
    Offline / Send Message
    Ged interpolator
    thats really cool alec!
  • Ravenok
    Offline / Send Message
    Ravenok polycounter lvl 7
    Hey all,

    I'm trying to find a function that outputs a graph like this:
    graph.jpg

    Kinda like a floor, but with "softened" angles.

    I'm no mathematician, but for some reason that feels like an impossible thing to get. :)
    Is it?
  • AlecMoody
    Offline / Send Message
    AlecMoody ngon master
    When you say a "graph like this" do you literally mean a 2d line drawing or are you looking to apply that kind of function to RGB values?
  • Ravenok
    Offline / Send Message
    Ravenok polycounter lvl 7
    Yes, I'm sorry for not explaining.
    I need to apply this to RGB values, or values of any kind. Like you'd use a floor/ceil/trunc function, for example.

    Basically I'm trying to create a sort of a posterized shader with soft transitions between the values/hues, and I thought this would be a good way to achieve this with SF.

    Ideally I would also have a way to scale the "smoothing" of the angles/corners, scaling it between something that's very close to a floor function and something that's very smooth and wavy.
  • billymcguffin
    Offline / Send Message
    billymcguffin polycounter lvl 11
    This is more like smooth round rather than smooth floor, but maybe you can work with it: https://www.desmos.com/calculator/t8ev8mqdls

    a = number of steps
    b = sharpness

    it runs into problems with a "sharpness" value below 15.
  • cptSwing
    Offline / Send Message
    cptSwing polycounter lvl 11
    Looks nice, Alec!
  • Ravenok
    Offline / Send Message
    Ravenok polycounter lvl 7
    This is more like smooth round rather than smooth floor, but maybe you can work with it: https://www.desmos.com/calculator/t8ev8mqdls

    a = number of steps
    b = sharpness

    it runs into problems with a "sharpness" value below 15.

    It's not bad actually. Works pretty well. Thanks a lot :)
  • Ravenok
    Offline / Send Message
    Ravenok polycounter lvl 7
    Another question.

    Is it at all possible to include IBL in a custom lighting shader, using unity 5's new sky system/reflections?
    I toyed with adding cubemaps to the existing hierarchy, but due to lack of knowledge, I don't know how to incorporate them properly.

    Also I'd like it to be integrated with unity's sky system, which I have no idea how to achieve (basically make it behave like a PBR preset does, only through custom lighting).
  • Dvonio
    Offline / Send Message
    Dvonio polycounter lvl 4
    Hey, does shader forge use GGX for pbr shaders or the default unity 5 uses (Blinn-Phong) for his standar shader?

    http://forum.unity3d.com/threads/using-ggx-instead-of-blinn-phong.323827/ found this post and wanted to know if shader forge will work ok on my project.

    thanks!
  • Acegikmo
    Finally, after more than a year of waiting, we have now managed to get a huge sale, starting in about 5 hours :D
    https://twitter.com/JoachimHolmer/status/615791983819231232
    Dvonio wrote: »
    Hey, does shader forge use GGX for pbr shaders or the default unity 5 uses (Blinn-Phong) for his standar shader?

    http://forum.unity3d.com/threads/using-ggx-instead-of-blinn-phong.323827/ found this post and wanted to know if shader forge will work ok on my project.

    thanks!

    Not using GGX yet, but, perhaps in the future!
  • Acegikmo
  • Toth
    I'm looking for any help regarding creating a very specific shader using SF. The effect I'm looking for is present in Telltale's Wolf Among Us (See bricks in background).


    The areas in light would be one texture, the areas in dark would be another; the light would not make the mesh dark, just use the lighting info to change the texture. I've created two textures, one "lit texture" and one "shadow texture". I was thinking a hard blended ramp between the two textures would work, but I'm not sure how to have that effected by spotlights


    Any help would be great, thanks!
  • Lt_Commander
    Offline / Send Message
    Lt_Commander polycounter lvl 10
    I just wanted to say that this tool is awesome! It has made my life much easier working with Unity, thank you for the tool. I sold it to my team lead by saying that 'it'd take me a few days to find the functions to get that kind of effect, or it's a one click solution in Shader Forge. You mind if we get a copy?'


    On a side note, I've been working on a translucent glass shader, but it's not playing well with dynamic shadows using just the opacity output - shadows treat it like it was solid. Is there a checkbox I'm missing?
  • Conor
    Offline / Send Message
    Conor polycounter lvl 18
    Shader Forge 1.17 introduces matrices as a data type, and a matrix multiplication operation. Which means…

    VUqLp9B.gifCPP5oeT.gif

    You can now create shaders that render lighting for Unity’s Shuriken particles correctly. Since Unity particles render in Camera space instead of World space, regular light attenuation doesn’t work properly. The shader needs to know the particle’s position in World space. So you put this script on your camera…
    using UnityEngine;
    using System.Collections;
    
    [RequireComponent(typeof(Camera))]
    public class CameraToWorld : MonoBehaviour 
    {
       private Camera myCamera;
    
       void Start () {
          myCamera = GetComponent<Camera>();
       }
    
       void OnPreCull() {
          Shader.SetGlobalMatrix("_Camera2World", myCamera.cameraToWorldMatrix);
       }
    }
    

    Shader Forge's new Global Matrix 4x4 data type can see the _Camera2World matrix. Multiply your vertex positions by this matrix to put them back into world space. Now you can create whatever custom lighting you want. This shader uses point lights for alpha-blended particles, suitable for smoke or clouds. Note that Shader Forge can’t see the light’s Range parameter so you have to put that into the material manually.

    OzoiDwh.png

    Inspired by this https://gist.github.com/Farfarer/158b23f694c2c995f93e
  • Zugzug
    Offline / Send Message
    Zugzug polycounter lvl 5
    Crest wrote: »
    Hey man all you need to do is to change the drop selection under the UV node
    IuwfJqA.png

    You could do this way too, just load the uv set 0 and multiply values to change the detail map. This way you don't mess with the lightmap uv set.

    DetailAdd.png
  • neal_liddle
    Hi guys. Hope someone could help me with this. I'm busy creating a repeating animated texture(caustic). I worked off this, which works, but as soon as you try scale the animated texture(by using multiply with the UV coord) then it breaks. (parts work and others have offsets causing them to jitter)

    I've attached the shader and the caustic texture of size 4 x 8.
    Settings on script will be 0.5(global_uvScale), [4,8,1,0](SeqSettings).
    Any help would really be appreciated!

    mmm...can't seem to upload the shader
  • neal_liddle
    ok. I've uploaded the shader + texture onto dropbox. link
    Any help or just pointing into a direction would help. Thanks!
  • Armageddon
    Offline / Send Message
    Armageddon polycounter lvl 5
    So I'm hoping someone could help me with this shader I'm trying to do.

    I'm trying to get this effect.

    zqyYI.jpg

    On vertex colors though, where between vertexes, if there's a different color on each one it'll blend like that except with custom texture patterns.

    I have this so far.

    sf_vertexblend_7222015.png

    I'm just wanting the noise filter to show up between vertexes of different colors. And the black of the texture will be one color and the white will be the other.

    If anyone has any pointers I'd be much appreciative.
  • Shrike
    Offline / Send Message
    Shrike interpolator
    wouldnt it make more sense trying to do it as a post effect simply applying to the dark areas ?
  • Armageddon
    Offline / Send Message
    Armageddon polycounter lvl 5
    Well I want it to fade between all colors. So red to blue would have that speckle effect. Like this.
  • oquigley
    Here's a simple pattern that I've been playing with - instead of using Sin or Frac to make time-based offsets, I bake the function into a texture, then offset it with a UV pan node.

    f0MIClkwj

    The nice thing about it (in addition to not having to calculate sin) is that you can put whatever function you want into it - easing in or easing out, blinks followed by slow waves, whavever.
  • oquigley
    n00b question - is it possible to use transmission with a custom lighting setup? I'd like to shade the backfaces independently....

    [edit]
    ... Oh, I see - transmission has nothing to do with backfaces... Hmm. Can one independently shade backfaces?
  • Acegikmo
    Shader Forge 1.18 is now out!

    update_118.png

    • 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
    oquigley wrote: »
    n00b question - is it possible to use transmission with a custom lighting setup? I'd like to shade the backfaces independently....

    [edit]
    ... Oh, I see - transmission has nothing to do with backfaces... Hmm. Can one independently shade backfaces?

    Yep!
    As of 1.18 it's trivially done using the Face Sign node and a lerp node :)
    Conor wrote: »
    Shader Forge 1.17 introduces matrices as a data type, and a matrix multiplication operation. Which means…

    VUqLp9B.gifCPP5oeT.gif

    Very nice work, and thanks for the guide!
    Perhaps I should implement this into Shader Forge natively? :)
  • Eric Chadwick
    Shader Forge is awesome, I just bought a seat last week, and have been really enjoying digging into it!
  • AlecMoody
    Offline / Send Message
    AlecMoody ngon master
    I agree. It is also nice to see a package like this that is kept up to date so well. Some of my other asset store purchases have become support nightmares as new unity builds are released.
  • bugo
    Offline / Send Message
    bugo polycounter lvl 17
    I cannot get the ligthmap to work or be available on the checkbox, help?
    The lightmap is getting baked, but how do I get it to show with the material? I'm not doing anything different than blending some lerps together. I tried naming MainTex etc but no success. Any idea?

    edit: I noticed that when I'm on unlit I cant use it? Is that correct? Is there a way to create an unlit version and still use lightmap?
  • cptSwing
    Offline / Send Message
    cptSwing polycounter lvl 11
    Quick question, is there anything related to UDK's DeriveNormalZ available? If not, how would I construct a correct tree to efficiently calculate the blue channel from R and G? Would this even make sense on mobile platforms?

    Cheers :)
  • Drew++
    Offline / Send Message
    Drew++ polycounter lvl 14
    cptSwing wrote: »
    Quick question, is there anything related to UDK's DeriveNormalZ available? If not, how would I construct a correct tree to efficiently calculate the blue channel from R and G? Would this even make sense on mobile platforms?

    Cheers :)

    You can do it this way:

    Z = sqrt( 1 - (X * X + Y * Y) );

    X and Y are the red and green channels.
  • cptSwing
    Offline / Send Message
    cptSwing polycounter lvl 11
    float Z = sqrt( 1 - (X * X + Y * Y) );
    return Z;
    .. in the code node worked a charm. Thanks!
  • NeatWolf
    Offline / Send Message
    NeatWolf polycounter lvl 3
    Hi everyone,

    I was trying to create a refractive material for particles, for example to use them as "black hole", fire distortion or other magic FX. I once made it using classical shader programming, but IIRC that was a heavy modification of an example written by someone else and can't remember who, or maybe I did it from scratch, I can't remember. Probably something inbetween, picking different parts from different shaders I have no memory of, I was learning.

    Is it possible to obtain such effect in Shader Forge? I'd like to have a texture to "blend" the particle distortion out in a circular manner, and have vertex alpha to control the amount of blending (1: totally distorted, 0: transparent)

    Why is it pure black if I set it to be alpha blended? Why isn't the refraction or the alpha mask showing onto the cube?

    I'd like such distorted particles to be able to overlap one onto each other.

    I know it's a bit processor intensive (different grabpasses) but I won't be using many of them.

    Could anyone please help me?

    Thanks to anyone willing to help! :)

    2yn4i9x.png
  • cgvinny
    Offline / Send Message
    cgvinny polycounter lvl 9
    Hey guys,
    I couldn't find any resources to explain how to handle the refraction effect...
    Can anyone could give me a link, or briefly explain me ?
    Thanks a ton ;-)
  • Acegikmo
    NeatWolf wrote: »
    Hi everyone,

    I was trying to create a refractive material for particles, for example to use them as "black hole", fire distortion or other magic FX. I once made it using classical shader programming, but IIRC that was a heavy modification of an example written by someone else and can't remember who, or maybe I did it from scratch, I can't remember. Probably something inbetween, picking different parts from different shaders I have no memory of, I was learning.

    Is it possible to obtain such effect in Shader Forge? I'd like to have a texture to "blend" the particle distortion out in a circular manner, and have vertex alpha to control the amount of blending (1: totally distorted, 0: transparent)

    Why is it pure black if I set it to be alpha blended? Why isn't the refraction or the alpha mask showing onto the cube?

    I'd like such distorted particles to be able to overlap one onto each other.

    I know it's a bit processor intensive (different grabpasses) but I won't be using many of them.

    Could anyone please help me?

    Thanks to anyone willing to help! :)

    2yn4i9x.png

    Make sure the console doesn't have any warnings about the fact that the shader isn't alpha blended. Also, the alpha channel of that texture might be fully white, making it fully opaque. You'll also want to make sure Z/depth write is off, otherwise the grab pass will just grab nonsense
  • NeatWolf
    Offline / Send Message
    NeatWolf polycounter lvl 3
    Acegikmo wrote: »
    Make sure the console doesn't have any warnings about the fact that the shader isn't alpha blended. Also, the alpha channel of that texture might be fully white, making it fully opaque. You'll also want to make sure Z/depth write is off, otherwise the grab pass will just grab nonsense

    I took again the bundled refraction shader and tweaked it until I reached something which is close to the intended result, but not yet perfect.

    Here's the node tree:
    9aXkrLS.png

    The Alpha channel just opacizes the effect making it blend to black. I was expecting it to give a smooth blend between the refracted zone and the rest of the scene.

    Also, as particles overlap, they seem to cut out a square all around them, ruining the effect.

    Mk7fWx0.png

    I also can't get rid of the shadow from the shader.

    Is it possible to fix this or find a solution to make such shader work with Shader Forge?

    Here's a link with the shader and a test texture:
    https://dl.dropboxusercontent.com/u/45747146/Particle%20Refraction%20Shader%20and%20Assets.zip
  • h8spaCec4EspUdE
    I have a question about transparency mode. The shadow on ground does not fade as opacity changes. it remains the same brightness(black) when opacity changes from 1 to 0. When using standard shader, the shadow strength fades with opacity.dNYyWabFAAAAAElFTkSuQmCC
  • neoshaman
    SO i'm toying with shader forge for a while, but don't understand how to set up the pot effect shader in practice? any example? step by step instruction? I find nothing by googling :(
  • Eric Chadwick
    Pot effect? What's that?
  • neoshaman
    Oh I mean post effect/post process, sorry, I bought shader forge just for that :/
  • weareape
    Offline / Send Message
    weareape polycounter lvl 7
    NeatWolf wrote: »
    I took again the bundled refraction shader and tweaked it until I reached something which is close to the intended result, but not yet perfect.

    Here's the node tree:
    9aXkrLS.png

    The Alpha channel just opacizes the effect making it blend to black. I was expecting it to give a smooth blend between the refracted zone and the rest of the scene.

    Also, as particles overlap, they seem to cut out a square all around them, ruining the effect.

    Mk7fWx0.png

    I also can't get rid of the shadow from the shader.

    Is it possible to fix this or find a solution to make such shader work with Shader Forge?

    Here's a link with the shader and a test texture:
    https://dl.dropboxusercontent.com/u/45747146/Particle%20Refraction%20Shader%20and%20Assets.zip

    Hey as far as the shadows go that might be under the renderer tab on your particle system. make sure the cast shadows box is unchecked. Also assuming you want to control the alpha through your particle, plug your vertex color alpha directly into the alpha channel.

    Sorry I keep adding on. You should also multiply the vertex color alpha by a radial gradient to get the fall off you are looking for and plug that in to your alpha channel. Hope this helps
  • Acegikmo
    neoshaman wrote: »
    SO i'm toying with shader forge for a while, but don't understand how to set up the pot effect shader in practice? any example? step by step instruction? I find nothing by googling :(

    First off - SF isn't really made for post effects in general, so the workflow for it isn't very smooth I'm afraid. If it disappoints you can always get a refund :)

    The issue is that it requires a C# side to it as well, so you get a component you can attach to a camera in order for it to work. At least if you want it to work like Unity's post effects. So have a look at how they set their C# components and their shader up. I imagine the shader is quite simple in many cases, especially for things like color correction.

    Otherwise I recommend starting with the post effect preset, then using the SceneColor node and the SceneDepth node to make interesting things!
  • neoshaman
    Thanks for the answer!

    Okay I'll do the effort with the c#. I thought there was some tools to simplify it. So far whatever I tried don't seem to yield any result with the visualization. And I don't understand the node within the post process (why there is vertex node). I have seen people do past effect with it so I assume I could easily do the same.

    Basically I'm trying as a start to just access the screen color and redraw it verbatim. I just have brown color on the visualization so far.

    What I want to achieve in post process is really simple, I just want to sample 4 pixels values (+ or -) around the current fragment (at slider distance, eventually pondered by other data like depth or a mask texture) then choose the max luminosity value for the current fragment. I had a prototype for this effect on strumpy with simple texture.

    I just want to see if its possible.

    However shader forge is still cool for usual shader editing, so no refund :)
  • Ravenok
    Offline / Send Message
    Ravenok polycounter lvl 7
    Does anyone have an idea to how I can mask out the IBL contribution from a PBR shader?

    I'm trying to create a shader that makes everything completely black above/below a certain height in world space. So the shader would behave in a standard way, but starting from a certain height, it would be completely black.

    I currently make the height calculation and multiply every relevant contribution by it, but since reflection from the IBL is handled outside the shader, I can't remove it.
  • HAWK12HT
    Offline / Send Message
    HAWK12HT polycounter lvl 13
    Hi, so trying to make my first shader here. Looking for information on how to go about making custom specular highlights independent of lighting environment, usually when object is rotated.
Sign In or Register to comment.