Search Unity

Shader Forge - A visual, node-based shader editor

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

  1. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Hey guys, I recently made a few water shaders and one of them was for a waterfall. It is pretty simple but works really great. Used vertex colors and painted the edges black for better blending. It is uv mapped by scale so can use the same model with material. So used a few techniques that I have not before and am very happy with it.

    Issues are I really want to be able to use refraction, but that has many clipping issues. Also have to use alpha blending, but that does not work with fog or sorting or will allow shadows. So the only way to be able to use this shader is an opaque panning shader which looks aweful. Is there any way to have alpha blending, even if no refraction, and receive shadows and work with fog? Just seems like a simple thing. Any plans for Deferred Alpha?

    Thanks guys. Really appreciate any help.
     
  2. RodneyO

    RodneyO

    Joined:
    Jan 22, 2011
    Posts:
    50
    Where I can find the graph for this?
     
  3. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    Dithered alpha, Scene Color, or Cubemap are the only ways that I can think of actually making it look okay with SF.

    Dithered looks like crap without super-sampling or some other antialiasing image effect.
    (gif scaled to half size, looks much worse at full res - see next pic to compare)
    SF_IFL_Baldinoboy_waterTransDitheredAlpha.gif
    SF_IFL_Baldinoboy_waterTransDitheredAlpha.jpg

    Scene color disables receiving shadows.
    SF_IFL_Baldinoboy_waterTransSceneColor.gif

    And the cubemap method (bake reflection probe, use result with Cubemap node with a View Dir connected to a Negate node for the Dir input) looks a bit dated and kind of magnifies whatever is behind the surface, but it can work if you don't need to see moving objects through the water for gameplay and don't mind the magnification look.
    SF_IFL_Baldinoboy_waterTransCube.gif

    I hope this helps... I know it's not ideal, and there's probably other methods inside of SF that I don't know about.

    I think it's just the default PBR setup with the color set to red, semi-high gloss or low roughness, and low metallic. The sky probably plays a large part in how the shader looks. I could be wrong though.
     
    Baldinoboy likes this.
  4. RodneyO

    RodneyO

    Joined:
    Jan 22, 2011
    Posts:
    50
    Thanks IFL, the default PBR doesn't give you the transparent settings which is what I'm after.
     
  5. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    Are you in forward or deferred rendering?

    [EDIT::] Works for me. True transparency only works in Forward. So... use Forward, connect something to the Opacity, and then you get that glorious fade/reflective option. And if you're trying to have the camera render in Deferred, you can still use Forward shaders.
     
    Last edited: Feb 21, 2017
  6. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    Working on a realtime shockwave with a complex volumetric smoke rolling out. It gets effected by lights and shadows too if it's opaque rendered. Pretty cheap on the GPU.



     
    Lex4art, ftejada, RodneyO and 2 others like this.
  7. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Thank you so much for the reply. The dithering definitely helps. Never used it before. It is not perfect but I am now able to have it receive shadows and use Deferred which I did not think was possible. Just made a particle shader that uses the same settings with some emission. Not volumetric fog like what I would like but it works was mist.



    Thanks again IFL!
     
  8. Studio_Akiba

    Studio_Akiba

    Joined:
    Mar 3, 2014
    Posts:
    1,421
    Hey Guys, Long-Time, No-Read :p

    I have been trying to work out how to create a world-space Triplanar UV shader with tiling control for something, but am having a lot of trouble with it.

    For some reason the object appears almost burnt, so the normal map isn't being applied properly, but the Acegikmo Wiki only has examples using diffuse maps, no specialty maps like Normal or Metallic.

    The idea of this is that I can duplicate concrete railings and walls along an area and alter the tiling amount to limit the amount of tiling data, without having to have unique UV's on everything, but this is turning out to be more complicated than following the wikis.

    http://acegikmo.com/shaderforge/wiki/index.php?title=World-Space_UV_Mapping
    http://acegikmo.com/shaderforge/wiki/index.php?title=Triplanar_Mapping

    sf_world-spacepbr_2222017.png
     

    Attached Files:

  9. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    Found the problem. The normalmap checkbox isn't ticked :)
     
    hopeful likes this.
  10. Studio_Akiba

    Studio_Akiba

    Joined:
    Mar 3, 2014
    Posts:
    1,421
    Oops!
    Missed that, thanks :D
     
  11. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    np :D
     
  12. ethanwgross

    ethanwgross

    Joined:
    Jun 25, 2014
    Posts:
    83
    There is a major bug in the current version of Shader Forge that prevents you from being able to scroll in the left side panel. As a result, you cannot access certain shader settings because they are out of view and there is no scroll bar.
     
    Last edited: Feb 26, 2017
  13. deadlycrow

    deadlycrow

    Joined:
    Feb 10, 2014
    Posts:
    166
    hey, 2 questions, i want to know how to achieve a refractive color aberration? like the one water does on light wavelenghts? and also, is shader forge ever be multi-pass or what? thank you! @Acegikmo
     
  14. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    Working on a 3d volumetric nebula shader with the same technique. This also recieves lights like the third example.

     
    FPires and Baldinoboy like this.
  15. olavrv

    olavrv

    Joined:
    May 26, 2015
    Posts:
    515
    Fantastic work!
     
  16. Alex_4x

    Alex_4x

    Joined:
    Feb 2, 2014
    Posts:
    21
  17. TheNathanParable

    TheNathanParable

    Joined:
    Mar 21, 2014
    Posts:
    17
    Hi, I was just about to purchase Shader Forge with 25% off as part of the wishlist sale, but right when I was about to start the checkout process the discount suddenly disappeared? And if you check the Wishlist Sale, Shader Forge suddenly isn't there anymore, despite there still being three days left. What happened?
     
    Jodwig and hopeful like this.
  18. Jodwig

    Jodwig

    Joined:
    Feb 23, 2014
    Posts:
    4
    Would love to know, too, since I'm in the same boat.
     
  19. TheNathanParable

    TheNathanParable

    Joined:
    Mar 21, 2014
    Posts:
    17
    Well, i've tried tweeting both the Unity Asset Store and Unity twitter accounts. I'll let you know if I get a response.
     
  20. Cannes_xk

    Cannes_xk

    Joined:
    Apr 5, 2015
    Posts:
    4
    I'm in the same situation. In the end if they do not solve it ... we will end up buying the amplify shader
     
  21. ertanunver

    ertanunver

    Joined:
    Jan 31, 2014
    Posts:
    1
    I am a noob and I have a question. How do I get the current color of any vertex?
     
  22. TheNathanParable

    TheNathanParable

    Joined:
    Mar 21, 2014
    Posts:
    17
    Well, we're on the last day of the sale now and still no response from anyone as to why Shader Forge's sale ended three days earlier than it was supposed to.

    I guess I won't be buying Shader Forge at this time. :(
     
  23. Jodwig

    Jodwig

    Joined:
    Feb 23, 2014
    Posts:
    4
    You still have 18h left, I believe.
     
  24. spvn

    spvn

    Joined:
    Dec 10, 2013
    Posts:
    80
    Same here. Everything else on the wishlist sale is still on sale except shader forge suddenly disappeared... Guess I won't be getting it this time :(
     
  25. Alex_4x

    Alex_4x

    Joined:
    Feb 2, 2014
    Posts:
    21
    Very cool effect. This create by shader ?
     
  26. ehuvio

    ehuvio

    Joined:
    Nov 4, 2014
    Posts:
    15
    Hi, I'm new to Shader Forge, so sorry if I'm asking a stupid question.
    Anyway I want to create a shader that turns on a hidden texture when a certain spot light is lighting them and off when not - like a magical flash light. I would really appreciate any hint.
     
  27. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    502
    Yes, you can sort of do that.

    The way to do it probably won't be a custom lighting model, or something that applies 'per-light' though.

    Maybe have 2 worlds, the first being normal and the second being basically a mask. Use a render texture on a second camera, that only outputs where a light is shown, then use that as a mask in the main world for where to show a texture.

    The other way to do it, is if you were OK to pass light values to all applicable materials. In the shader, you have access to world space of a pixel, and if you give the shader a vector 3 that's based off your light position, you can check to see if it's in range (point light). There's some more math you'd have to do for a spot light, but if you're ok with that and you can pass the light position and rotation to each material that needs it, it might be the faster way.
     
  28. nbac

    nbac

    Joined:
    Jul 7, 2015
    Posts:
    267
    i managed to put together a frosted glass shader. based on the distance of objects behind the glass object get more or less blured. i want to have SSR on it. since i have to use deffered shader for that i can not use custom lit. there for i put my scenecolor with all its necessary operation into the base color. i do not get the desired SSR´s. as soon as i put a regular color in the very same shader with the very same settings they do appear.

    any suggestions?

     
  29. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    502
    Have you tried plugging scene colour into any other outputs (emissive)? Also, when testing, maybe multiply the scene colour by 0.5 or a colour, and making the base colour something dark but reasonably saturated to try and see if there's any difference that comes up.

    Also make sure your material roughness/metal/spec/gloss values are good for sowing SSR's.
     
  30. jackishere

    jackishere

    Joined:
    Mar 1, 2014
    Posts:
    22
    Hello,

    Just wanted to share.

    Here's a script to remove meta pass automatically which is pretty annoying thing to do when you compile a post process shader and have to delete it manually.

    how to use:

    Just include this script into your project

    You can also select which shader that you want to exclude from the stripping

    via "Window/ShaderForge Meta Remover".



    https://github.com/jackisgames/ShaderForgeMetaPassRemover
     
  31. deadlycrow

    deadlycrow

    Joined:
    Feb 10, 2014
    Posts:
    166
    Hi, @Acegikmo why the unity's Global fog script does not catch any Shader forge's shader AT ALL ?? what can i do, not a single one of the shaders made in shader forge catch the fog from the "Global fog" script... any solution to this???
     
  32. steffrock

    steffrock

    Joined:
    Apr 24, 2015
    Posts:
    3
    Hi gang, I've run into an error, where when I try to open SF it flashes a window and then writes these messages.
    I don't know where to begin with this. I have tried downloading SF again and have restarted my machine and Unity as I read on another thread. Any help would be greatly appreciated!
    upload_2017-3-11_16-53-14.png
     
  33. steffrock

    steffrock

    Joined:
    Apr 24, 2015
    Posts:
    3
    I just posted this same issue. Did you find a solution? @shrapnel92 @masarunuma
     
  34. nbac

    nbac

    Joined:
    Jul 7, 2015
    Posts:
    267
    tried this and sevearal other things - cant get it to work. as i said as soon as i put a color instead of my custom input into the base get the desired effect. so what deferincites my rgb input from a standard color?
     
  35. deadlycrow

    deadlycrow

    Joined:
    Feb 10, 2014
    Posts:
    166
    Hey people, i just made a tutorial :) check it out, subscribe and give a thumbs up if you liked it :)
     
    Jesus, Malbers, Ga2Z and 1 other person like this.
  36. ehuvio

    ehuvio

    Joined:
    Nov 4, 2014
    Posts:
    15
    Hi. I'm trying to do the math for calculating whether the point is inside of the cone, but fail to get hold of the cone's properties. There's nodes for light and point positions, but is there a way to access light cone's aperture and it's center bottom point. Or are they accessible by code only?
     
  37. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    502
    It'll be something where you attach a script to your spot light and it looks for the current spot angle, light distance, intensity, worldspace position, rotation, etc etc etc and passes that to a material. The material will need your shader that has appropriate inputs for those things.
     
  38. ehuvio

    ehuvio

    Joined:
    Nov 4, 2014
    Posts:
    15
    I've done calculating the cone and thought that I already had it, but for some reason it doesn't replace the mask when point is not inside the cone. In Unity's script, where I do an approximation, it always calculates the isInsideCone correctly. Here's the picture: sf_uusikoe_3172017.png

    The total mask is same size as the splatter image, but completely transparent. Any ideas?
     
  39. steffrock

    steffrock

    Joined:
    Apr 24, 2015
    Posts:
    3
    Could anyone lead me to some help with this?
     
  40. lorenzodom

    lorenzodom

    Joined:
    Apr 3, 2015
    Posts:
    22
    Hello everyone

    Im trying to achieve a matte Shadow effect, i just want to mask the shadow projected on a surface and use it as transparency.

    1-I alredy have the mask.

    2-But if I connect the nodes to the "opacity clip" the sader crash
    Console Error:
    Shader error in 'MatteShadowMd': undeclared identifier 'attenuation' at line 64 (on d3d11)
    Compiling Vertex program with DIRECTIONAL SHADOWS_OFF LIGHTMAP_OFF DIRLIGHTMAP_OFF DYNAMICLIGHTMAP_OFF



     
  41. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    502
    Just a heads up, looks like you're applying the reflection texture in the custom light section, so it'll be added for each light you have affecting the ocean.

    For example, if you have 2 directional lights, the reflection of the skybox (or whatever is above and picked up by the mirror script) will be twice as bright.

    Unless I've missed something here, the right place to plug that little section is into Emission.

    Other than that, great work dude. Your method for controlling the water colour is an easier to use alternative than mine, though maybe a bit more expensive (hey, worth it). I was using light coefficient extinction values as a vector 3, and just raising it to the power of (depth behind water surface). But apart from plugging in known and correct values for water types, which is handled perfectly, it wasn't great fun to play with.

    Other things to do is to clamp the (depth behind water surface) to a (max visibility) value. So instead of getting progressively darker, it just stops at the (water colour) value. Easy, simple, good looking.
     
    hopeful likes this.
  42. MattyWS

    MattyWS

    Joined:
    Jan 24, 2013
    Posts:
    70
    Is there any way of rendering the wireframe of your model as a shader? No tricks like rendering out the wireframe in some 3D software and using a texture, preferably. I'd like to be able to make a shader that fades a model in starting with a wireframe much like how buildings were contructed in this game;

     
    daville likes this.
  43. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    502
    Sorry to spam the thread, but I'm looking for someone to extend the Unity Wiki Mirror Script. $20-35.
    details: https://connect.unity.com/jobs/58d27a940909150021ce2d4e

    If you, or anyone you know can do this, please help by sending them this way.

    Basically it's a flip of the reflection camera matrix off the Unity Wiki Mirror Script.


    It'll be for something shader forge related, I'm not giving away any clues as to what it might be for.
    water_reflection.png
     
  44. daville

    daville

    Joined:
    Aug 5, 2012
    Posts:
    303
    Is it possible to create an Anisotripic Shader in ShaderForge?
     
    Waz likes this.
  45. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    Yes. It's tricky though. It took me a while to work it out. I don't have my version anymore, but I think it was based on the shader guru @Farfarer's here, and specifically this function:
    Code (CSharp):
    1. float _AnisoOffset, _Cutoff;
    2. inline fixed4 LightingAniso (SurfaceOutputAniso s, fixed3 lightDir, fixed3 viewDir, fixed atten)
    3. {
    4.    fixed3 h = normalize(normalize(lightDir) + normalize(viewDir));
    5.    float NdotL = saturate(dot(s.Normal, lightDir));
    6.  
    7.    fixed HdotA = dot(normalize(s.Normal + s.AnisoDir.rgb), h);
    8.    float aniso = max(0, sin(radians((HdotA + _AnisoOffset) * 180)));
    9.  
    10.    float spec = saturate(dot(s.Normal, h));
    11.    spec = saturate(pow(lerp(spec, aniso, s.AnisoDir.a), s.Gloss * 128) * s.Specular);
    12.  
    13.    fixed4 c;
    14.    c.rgb = ((s.Albedo * _LightColor0.rgb * NdotL) + (_LightColor0.rgb * spec)) * (atten * 2);
    15.    c.a = 1;
    16.    clip(s.Alpha - _Cutoff);
    17.    return c;
    18. }
    To start, I think I used comments on my nodes for consistency in the variable relationships with the above function. So there was probably a Dot Product (Normalized instead of Standard mode) node with the comment "NdotL" and a Dot Product node with the comment "HdotA".
    Hope this helps.
     
    daville likes this.
  46. daville

    daville

    Joined:
    Aug 5, 2012
    Posts:
    303
    Thanks I'll check it out
     
  47. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    Here's a quick shader doodle that I made despite having a ton of environment modeling to finish by tomorrow........

    DNA Donut:
    SF_IFL_DNADonut.gif
    It's not actually rotating around a vertical axis - if you look at the base pairs you'll notice that it's rotating along the double helix with the center of the base pairs being stationary. It looks neat in VR.

    The mesh is exactly 1x1x1, positioned at the world center on the X axis, and each end of the double helix aligns perfectly with the other.
    SF_IFL_DNADonutGraphAndMesh.jpg
     
    ibyte, Pancar, Malbers and 2 others like this.
  48. mrcrowpsey

    mrcrowpsey

    Joined:
    Jan 13, 2014
    Posts:
    2
    Hi,

    i'm learning shader forge and i have a question i would love some guidance with.

    i need to create an interactive shader, think a water's surface that generates ripples when touched.
    i'm able to create the graph that creates the ripples, but i'm not sure how to go about making it reactive and change the origin of the wave based on input.
     
  49. midogame

    midogame

    Joined:
    Nov 2, 2016
    Posts:
    18
    Hello everyone,

    Is there a way in Shader Forge where I'd be able to produce an animated Edge Glow like in the first 35 seconds of this video?
    I've been trying hard looking, but couldn't find any tips to do it.



    Thanks
     
  50. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Can shader forge create geometry shader?