Search Unity

  1. Click here to see what's on sale for the "Best of Super Sale" on the Asset Store
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Shader Forge - A visual, node-based shader editor

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

  1. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,249
    None of these are nodes, they're complex problems that require more than a simple node solution. Splitting and moving vertices can be done if the mesh is hard-edged, and you simply offset them by the normal direction.
    Glow around object is almost always done using post processing, not localized shaders like the ones SF produces.
    Having proper outlines on a non-hard-edged mesh can work, and I've considered implementing a way of using the vertex colors as unified normals, and then have a toggle in the shader, for whether or not you want to use the vertex normals or the vertex color normals.
    Multi-pass shaders like fur and grass are rather complex, and currently not planned for SF1, but something like it will most likely make it into SF2 :)
     
    Deleted User likes this.
  2. JohnyK

    JohnyK

    Joined:
    Jun 13, 2014
    Posts:
    13
    Hello to all!
    I have just purchased this amazing asset but I am not sure how to use it for my university project...
    I want to create a cell animation using the following cell model: http://www.turbosquid.com/3d-models/3d-model-animal-cell/514082

    Any ideas on how to create a similar reflection shader using Shader Forge?

    I am interested in the "liquid" inner cell material he is using as it cant be exported from 3DS to Unity..

    Thanks!
     
  3. Deleted User

    Deleted User

    Guest

    So splitting mesh can be already done in latest version? If yes which are the nodes? :)

    Regarding the glow, i have thinking a way for make this in free version with the help of fresnel or outline, but fresnel doesn't work everywhere, and same situation occurred in outline where alpha channel doesn't work (aforementioned problem), maybe i can done work with 2 models and depth blend, but more models is equivalent of more consumed performance, so you have some ideas about that?
     
  4. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    7,175
    You need to make sure you have a hard edged mesh first, but basically you just do this:



    With a little bit of playing, you can also do this sort of thing:

     
    Last edited: Dec 2, 2014
  5. Deleted User

    Deleted User

    Guest

    I thought a thing like that, where black model is a glow with additive material:

     
    Last edited by a moderator: Dec 2, 2014
  6. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    7,175
    In that case, make sure you smooth your mesh's normals and then bake the hard edges into a normal map and you should be good to go.
     
    Deleted User likes this.
  7. Eideren

    Eideren

    Joined:
    Aug 20, 2013
    Posts:
    295
    @3DLABS Hey, a while ago you mentionned needing parallax shaders or something like that, i dont know if you still do but i needed that as well and ported the one reissgrant(from the unity forums)wrote to shader forge.
    So here's the PARALLAX/RELIEF MAPPING with correct silhouettes :
    Relief-Parallax.png

    You have to disable mipmap generation in the advanced tab on the texture importer else it'll be highly aliased and the mesh has to have tangents(which can be generated by unity's model importer).
     
    Deon-Cadme and RUNIARTS like this.
  8. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    559
    Oh man you are a saint ! I've been looking for a decent parallax action for SF for a year now. I'll try this right now.
    Thanx !
     
    RUNIARTS likes this.
  9. Deleted User

    Deleted User

    Guest

    For case you have also a code for this? :D

     
  10. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    559
    Hey Eideren. Is there any way you can upload the shader ? I wrote the codes, but probably made a few syntax errors that I can't spot at all, or got the float/fixed/samplers wrong

     
    RUNIARTS likes this.
  11. Eideren

    Eideren

    Joined:
    Aug 20, 2013
    Posts:
    295
    @Cactus_on_Fire Sure, there you go.
    Should'have done it since the start, it's such pain that we are unable to paste in the code node.
     

    Attached Files:

    RUNIARTS likes this.
  12. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    559
    Nope :\
    I still get the pink material error.

     
  13. Eideren

    Eideren

    Joined:
    Aug 20, 2013
    Posts:
    295
    @Cactus_on_Fire Are you sure it doesn't come from the material you created, did you try with a new one ? I'm using unity 4.6 and it was already working on 4.5, i dont have a single plugin which changes how materials behave.
    I am using it right now and i dont see anything wrong with it ...
    Did you check that SF didn't cut the links between some nodes ?

    If the above didn't work then could you look at the rest of the errors and tell me if one of them differs from the rest ?
     
    RUNIARTS likes this.
  14. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    559
    Nope. It may be because of the older version of unity or SF though. I'm using Unity 4.3.1 with ShaderForge beta 0.36 so I don't know how compatible the shader is. Can you prefab the shader with the material applied to a simple mesh like a cube and try like that ? The shader should work even though SF can't open it correctly.

    Thx for taking the time.
     
  15. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    7,175
    What platform are you running. I opened the source and added "#pragma glsl" and that seemed to get it working for me on OSX at least.
     
  16. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    559
    Windows 8

    did you add that to the very beginnnig of the code ?
     
  17. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    7,175
    I tossed it in the pragma section in the source in place of SM3's. If you're on Windows 8 though this really shouldn't be an issue.
     
  18. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    7,175


    With shader forge, I'm finally one step closer to having my Actually Nice Looking Toon Shader complete. Using it and vpaint, I now have vertex colours controlling the line thickness, distance scaling, and z-offset. On top of that, I have it set up so that the shadow bias is being controlled in the actual shader by vertex colours as well. Because shader forge doesn't support multiple passes (yet), I'm using a two material solution for this. One material will contain the toon shader itself, while this material currently contains the outline shader.
     
    Acegikmo likes this.
  19. Deleted User

    Deleted User

    Guest

    Problem with fresnel in alpha clip:

    Bug?

     
  20. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    7,175
    Plug a normal direction node into the Nrm connection.
     
    Deleted User likes this.
  21. lotsofwind

    lotsofwind

    Joined:
    Jan 8, 2014
    Posts:
    3
    hi. does anyone know how do i control outline color alpha? doesnt seem to do anything. wanted to make outline color semi-transparent
     
  22. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    7,175
    I believe that the outline system in shader forge is RGB only. You can sort of get around this with a two-material solution though.
    1. Add a second material to your mesh
    2. Create a shader and plug something like this into your vertex offset node
    3. Set the blending mode to frontface culling
    4. Through either a texture or vertex colour or some other option, control the alpha
    5. Put this shader on the second material
    It's not the most elegant solution, but it's mostly what I'm doing now.
     
    Last edited: Dec 5, 2014
  23. topofsteel

    topofsteel

    Joined:
    Dec 2, 2011
    Posts:
    984
    Where would I start in SF to reproduce the atmosphere including the clouds in the attached image. Particularly the clouds on the far side and the depth of the atmosphere. Thanks.

     
  24. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    559
    Not sure about SF but there is a plugin that produces quality and accurate sunrays like that.
    As for the foggy light on the top, not sure but there are a few tricks you can use to get similar effects. You can use volumetric light scripts or compose some spheres with depth blend values to make it volumetric like so :

     
    RUNIARTS likes this.
  25. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    7,175
    As an aside, if you're using Unity Free, you can replicate this with a camera that specifically orbits around the planet and by setting the falloff in the surface object shaders instead of using a depth blend.
     
  26. HenriqueGomez

    HenriqueGomez

    Joined:
    Dec 13, 2012
    Posts:
    63
    Guys, can Depth Blend be used with Vertex Offset ?
     
  27. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    7,175
    Do you have any tips for having anisotropic stuff working well? It's kinda evaded me thus far.
     
  28. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    I threw mine together using the LightingAniso function shown here (turned into a mess of nodes and commented relays). I can post my simplest aniso graph if you need it.
     
  29. neroziros

    neroziros

    Joined:
    Aug 25, 2012
    Posts:
    129
  30. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    You probably want Light Attenuation, but I'm not so sure that it's the same as what's available in UE4.

    Here's a couple of shots of a comic style that I did with ShaderForge not too long ago...
    VIDraKeep_Comic_02.jpg ComicStyle07.jpg
     
  31. neroziros

    neroziros

    Joined:
    Aug 25, 2012
    Posts:
    129
    Wow that looks awesome! But I wonder, would it be possible to avoid lighting the shadows when working with multiple lights (i.e, prevent the lights illuminate the shadows from other lights)?

    In the example I posted it isn't like that, but in my case I'd like to have fully black shadows even while working with multiple light sources.

    Cheers
     
  32. RUNIARTS

    RUNIARTS

    Joined:
    Jun 22, 2013
    Posts:
    54
    DEAR EIDEREN !

    Thank you deeply so much for your amazing Work in Bringing us some Better Parallax Relief To ShaderForge Users !


    This shader is alot better than Unity SHaderforge Parallax Default That For sure !
    If you Dont mind i got here some questions/Suggestions

    ... You said this one comes with "Correct Silhoetes" ...

    But "Oclusion" Aka Emulation of shadows ... or "Sillhoete Clipping" At its Edges
    Its not reaaly Included in this Code Equation Isnt ?​

    Can you please Include it ?

    You got here a Actuall POM Relief Shader Code That Was SHared here in the forums
    ... That Got its Curvature And Shadows Driven from the Normals and we can also tile uvs etc ...

    http://forum.unity3d.com/threads/fabio-policarpo-relief-mapping-with-correct-silhouettes.32451/

    This was quite a High Stuff Shared like "5 Years" Lightly ago ...



    I guess it still have its charm ( expecially done in shaderforge ) ...​
    But the Technique realy needs some Kind of Occlusion with shadows ...
    and also the Clipping Edges to look good and clip those nasty "moving parts" away ...




    This is me Testing your Cool shader ! And it Reaaly gives a Deepness Feeling ...

    It works Good ! Especially to Flat planes just ! ...

    ( We have to avoid concave meshes or Tiny Uv Zones ... Otherwise it will look reaaly messy ^^

    Also i must warn that the "relief effect" is just Working "per poly face" ...
    At this state of the code It doesn't Really connect the polygons edges ...
    It doesn't care about normals either ...

    So each polygon face got its own Individual extrusion xD
    Instead of Extruding all Polygons together with the geometry normals direction ...
    .. as it should ... lol ...

    But its reaaly a cool start Done here ! )

    ANYWAY ! ! THANKS SO MUCH FOR SHARING !

    :cool:


    PS: I see you are quite a Shader Genious !
    Also a Merchant And you Have that WOunderfull SHADERFORGE Cloud SHaders !
    http://forum.unity3d.com/threads/re...ailed-morphing-3d-clouds.274943/#post-1876836

    Tell-me DO you Include SHaderforge Sourçes in Your SHaders ?

    PS2: If you Want to Get it Deeper and make a Professional SHaderforge Nodes for Relief Mapping to Put at Assets Store as new product Here is a "proper" Example of What We all Would love to Have Converted into SHaderforge Powered Nodes :



    If you can Convert that Technique to SHaderforge Nodes ... and even Include Physical Based Properties ...
    You can even Make some money releasing it at Assets Store ! What you think ?

    We almost dont Have SHaderforge Powered Professional nodes At Assets Store ...
    Just the Cool ones from Imaginary Human : https://www.assetstore.unity3d.com/en/#!/content/14635

    Anyway THANK YOU SO MUCH For Sharing your Efforts with us !

    Waves & Crash down .....
    After 6 months Waiting ...
    I am Reaaly Hopping here SHaderforge 0.37 is released any day this week now ...

    Ho Dear Shader ACE LORD .. The Drugs ... !!
     
    Last edited: Dec 9, 2014
  33. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    @3DLABS - does the substance that causes that kind of enthusiasm come in pill form? ;)
    That's not really how lighting is supposed to work. You can manually change the blend modes for each forward-add pass to multiply each set of shadows... but that would require that every single light be within range of a fragment for the fragment to be lit. Is that what you want? Do you have a screenshot of what you're trying to achieve?
     
    RUNIARTS likes this.
  34. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    7,175
    This could probably also be done with shadow volumes, but that'd be pretty heavy on the fill rate and CPU to calculate them.
     
  35. Eideren

    Eideren

    Joined:
    Aug 20, 2013
    Posts:
    295
    @3DLABS Ah ah ah, thanks man, I appreciate the effort you put into that post ! Yeah, I kinda ditched that part for whatever reason, the fix is attached to this post(still doesn't render shadows tough, reasons below).

    Well, I did some research after I posted actually, I took a look at the Cone Step Mapping approach but it seems that this solution has patenting issues, yup, i wont waste my time on something that i wont be able to use in game, so i can't help you there.
    I am still searching for another better relief mapping solution though.

    Nope, my clouds doesn't include the SF code since I rewrote the shader after prototyping it in SF but it can easily be reproduced. I might add it in the next update but I could just aswell PM it to you, only if you buy them of course :p.
     

    Attached Files:

    RUNIARTS likes this.
  36. Guideborn

    Guideborn

    Joined:
    Jun 15, 2013
    Posts:
    228
    Are there any tutorials regarding animated textures for shaders? Is it possible to create a texture that scrolls and/or blink?
     
  37. Eideren

    Eideren

    Joined:
    Aug 20, 2013
    Posts:
    295
    @Guideborn The wiki already contains most of the basis on UVs which you will use to place pixels on your surface and animate them in shader, you should probably start here.
     
    RUNIARTS likes this.
  38. Deleted User

    Deleted User

    Guest

    This shader doesn't work for me, why?
     
  39. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,199
    Will Shaderforge be able to work together with the new Unity5-GI system?
    I already baked a scene and now want to use a Shaderforge-shader for my ground object, but of course the Gi disapears when I switch from Standard to my custom shader.
     
    Last edited: Dec 9, 2014
    philwinkel likes this.
  40. ExperimentalGame

    ExperimentalGame

    Joined:
    Sep 18, 2013
    Posts:
    10
    I have some questions regarding other forms of tesselation, expecially Phong Tesselation.
    Ive read on the Beta Feedback on userecho that these are coming sooner or later - so i have to quote one of my favourite movies "when will it be now ?", is there a estimate release date ?

    On the other hand can someone expain to me how i can include something like the example surface phong tesselation shader (http://docs.unity3d.com/Manual/SL-SurfaceShaderTessellation.html) into my shaderforge shaders. Or use the codenode to get acces to the UnityEdgeLengthBasedTess function ?
    I'm out of ideas at the moment ... o_O

    // edit:
    But maybe im a bit to focused on phong tesselation - if there is a good way to raise the detail and smooth out hard edges on characters with the current possible tesselation available within shaderforge. I would love if someone points me into that direction ;)
    My camera distance based tesselation i tryed, didnt had the nice smooth results of the phong tesselation
     
    Last edited: Dec 9, 2014
  41. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    7,175
    If you're using forward rendering, making sure you use the "enable depth rendering in foward" script that comes in the shaderforge examples folder.
     
    Deleted User likes this.
  42. neroziros

    neroziros

    Joined:
    Aug 25, 2012
    Posts:
    129
    @IFL I understand. A perfect example would be the style of Wolf Among Us. Pic

    In both images you can how, despite there being at least 2 directional lights, the shadows are fully black and stylized.

    My current idea is to first shade the scene with a directional light and then, during the rendering of the following lights, only light the fragments whose colors are higher than 0. But I'm not sure how to do this using shader forge

    Cheers

    UPDATE: I managed to get the desired effect by manually messing a bit with the shader code. Basically I changed the blend mode to "Blend DstAlpha one" and set the directional light alpha channel as its attenuation.

    And if you're interested, this is the full code

    Code (CSharp):
    1. Shader "Redline/Matte Gradient Color Hard Shadows" {
    2.     Properties {
    3.         _Color ("Color", Color) = (0.9338235,0.9544226,0.9544226,1)
    4.         _Diffuse ("Diffuse", 2D) = "white" {}
    5.         _Normals ("Normals", 2D) = "bump" {}
    6.         _Outiline ("Outiline", Float ) = 0.01
    7.     }
    8.     SubShader {
    9.         Tags {
    10.             "RenderType"="Opaque"
    11.         }
    12.         Pass {
    13.             Name "Outline"
    14.             Tags {
    15.             }
    16.             Cull Front
    17.          
    18.             Fog {Mode Off}
    19.             CGPROGRAM
    20.             #pragma vertex vert
    21.             #pragma fragment frag
    22.             #include "UnityCG.cginc"
    23.             #pragma fragmentoption ARB_precision_hint_fastest
    24.             #pragma multi_compile_shadowcaster
    25.             #pragma exclude_renderers gles xbox360 ps3 flash
    26.             #pragma target 3.0
    27.             uniform float _Outiline;
    28.             struct VertexInput {
    29.                 float4 vertex : POSITION;
    30.                 float3 normal : NORMAL;
    31.             };
    32.             struct VertexOutput {
    33.                 float4 pos : SV_POSITION;
    34.             };
    35.             VertexOutput vert (VertexInput v) {
    36.                 VertexOutput o;
    37.                 o.pos = mul(UNITY_MATRIX_MVP, float4(v.vertex.xyz + v.normal*_Outiline,1));
    38.                 return o;
    39.             }
    40.             fixed4 frag(VertexOutput i) : COLOR {
    41.                 return fixed4(float3(0,0,0),0);
    42.             }
    43.             ENDCG
    44.         }
    45.         Pass {
    46.             Name "ForwardBase"
    47.             Tags {
    48.                 "LightMode"="ForwardBase"
    49.             }
    50.          
    51.          
    52.             Fog {Mode Off}
    53.             CGPROGRAM
    54.             #pragma vertex vert
    55.             #pragma fragment frag
    56.             #define UNITY_PASS_FORWARDBASE
    57.             #include "UnityCG.cginc"
    58.             #include "AutoLight.cginc"
    59.             #pragma multi_compile_fwdbase_fullshadows
    60.             #pragma exclude_renderers gles xbox360 ps3 flash
    61.             #pragma target 3.0
    62.             uniform float4 _LightColor0;
    63.             uniform float4 _Color;
    64.             uniform sampler2D _Diffuse; uniform float4 _Diffuse_ST;
    65.             uniform sampler2D _Normals; uniform float4 _Normals_ST;
    66.             struct VertexInput {
    67.                 float4 vertex : POSITION;
    68.                 float3 normal : NORMAL;
    69.                 float4 tangent : TANGENT;
    70.                 float2 texcoord0 : TEXCOORD0;
    71.             };
    72.             struct VertexOutput {
    73.                 float4 pos : SV_POSITION;
    74.                 float2 uv0 : TEXCOORD0;
    75.                 float4 posWorld : TEXCOORD1;
    76.                 float3 normalDir : TEXCOORD2;
    77.                 float3 tangentDir : TEXCOORD3;
    78.                 float3 binormalDir : TEXCOORD4;
    79.                 LIGHTING_COORDS(5,6)
    80.                 float3 shLight : TEXCOORD7;
    81.             };
    82.             VertexOutput vert (VertexInput v) {
    83.                 VertexOutput o;
    84.                 o.uv0 = v.texcoord0;
    85.                 o.shLight = ShadeSH9(float4(mul(_Object2World, float4(v.normal,0)).xyz * unity_Scale.w,1)) * 0.5;
    86.                 o.normalDir = mul(float4(v.normal,0), _World2Object).xyz;
    87.                 o.tangentDir = normalize( mul( _Object2World, float4( v.tangent.xyz, 0.0 ) ).xyz );
    88.                 o.binormalDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w);
    89.                 o.posWorld = mul(_Object2World, v.vertex);
    90.                 o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
    91.                 TRANSFER_VERTEX_TO_FRAGMENT(o)
    92.                 return o;
    93.             }
    94.             fixed4 frag(VertexOutput i) : COLOR {
    95.                 i.normalDir = normalize(i.normalDir);
    96.                 float3x3 tangentTransform = float3x3( i.tangentDir, i.binormalDir, i.normalDir);
    97. /////// Normals:
    98.                 float2 node_334 = i.uv0;
    99.                 float3 normalLocal = UnpackNormal(tex2D(_Normals,TRANSFORM_TEX(node_334.rg, _Normals))).rgb;
    100.                 float3 normalDirection =  normalize(mul( normalLocal, tangentTransform )); // Perturbed normals
    101.                 float3 lightDirection = normalize(_WorldSpaceLightPos0.xyz);
    102. ////// Lighting:
    103.                 float attenuation = LIGHT_ATTENUATION(i);
    104.                 float3 finalColor = (_LightColor0.rgb*min(((tex2D(_Diffuse,TRANSFORM_TEX(node_334.rg, _Diffuse)).rgb*_Color.rgb)+UNITY_LIGHTMODEL_AMBIENT.rgb),max(0,dot(lightDirection,normalDirection)))*attenuation);
    105. /// Final Color:
    106. [B]                [U]return fixed4(finalColor,attenuation);[/U][/B]
    107.             }
    108.             ENDCG
    109.         }
    110.         Pass {
    111.             Name "ForwardAdd"
    112.             Tags {
    113.                 "LightMode"="ForwardAdd"
    114.             }
    115.             Blend DstAlpha one            
    116.          
    117.             Fog { Color (0,0,0,0) }
    118.             CGPROGRAM
    119.             #pragma vertex vert
    120.             #pragma fragment frag
    121.             #define UNITY_PASS_FORWARDADD
    122.             #include "UnityCG.cginc"
    123.             #include "AutoLight.cginc"
    124.             #pragma multi_compile_fwdadd_fullshadows
    125.             #pragma exclude_renderers gles xbox360 ps3 flash
    126.             #pragma target 3.0
    127.             uniform float4 _LightColor0;
    128.             uniform float4 _Color;
    129.             uniform sampler2D _Diffuse; uniform float4 _Diffuse_ST;
    130.             uniform sampler2D _Normals; uniform float4 _Normals_ST;
    131.             struct VertexInput {
    132.                 float4 vertex : POSITION;
    133.                 float3 normal : NORMAL;
    134.                 float4 tangent : TANGENT;
    135.                 float2 texcoord0 : TEXCOORD0;
    136.             };
    137.             struct VertexOutput {
    138.                 float4 pos : SV_POSITION;
    139.                 float2 uv0 : TEXCOORD0;
    140.                 float4 posWorld : TEXCOORD1;
    141.                 float3 normalDir : TEXCOORD2;
    142.                 float3 tangentDir : TEXCOORD3;
    143.                 float3 binormalDir : TEXCOORD4;
    144.                 LIGHTING_COORDS(5,6)
    145.             };
    146.             VertexOutput vert (VertexInput v) {
    147.                 VertexOutput o;
    148.                 o.uv0 = v.texcoord0;
    149.                 o.normalDir = mul(float4(v.normal,0), _World2Object).xyz;
    150.                 o.tangentDir = normalize( mul( _Object2World, float4( v.tangent.xyz, 0.0 ) ).xyz );
    151.                 o.binormalDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w);
    152.                 o.posWorld = mul(_Object2World, v.vertex);
    153.                 o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
    154.                 TRANSFER_VERTEX_TO_FRAGMENT(o)
    155.                 return o;
    156.             }
    157.             fixed4 frag(VertexOutput i) : COLOR {
    158.                 i.normalDir = normalize(i.normalDir);
    159.                 float3x3 tangentTransform = float3x3( i.tangentDir, i.binormalDir, i.normalDir);
    160. /////// Normals:
    161.                 float2 node_335 = i.uv0;
    162.                 float3 normalLocal = UnpackNormal(tex2D(_Normals,TRANSFORM_TEX(node_335.rg, _Normals))).rgb;
    163.                 float3 normalDirection =  normalize(mul( normalLocal, tangentTransform )); // Perturbed normals
    164.                 float3 lightDirection = normalize(lerp(_WorldSpaceLightPos0.xyz, _WorldSpaceLightPos0.xyz - i.posWorld.xyz,_WorldSpaceLightPos0.w));
    165. ////// Lighting:
    166.                 float attenuation = LIGHT_ATTENUATION(i);
    167.                 float3 finalColor = (_LightColor0.rgb*min(((tex2D(_Diffuse,TRANSFORM_TEX(node_335.rg, _Diffuse)).rgb*_Color.rgb)+UNITY_LIGHTMODEL_AMBIENT.rgb),max(0,dot(lightDirection,normalDirection)))*attenuation);
    168. /// Final Color:
    169.                 return fixed4(finalColor * 1,1);
    170.             }
    171.             ENDCG
    172.         }
    173.     }
    174.     FallBack "Diffuse"
    175.     CustomEditor "ShaderForgeMaterialInspector"
    176. }
     

    Attached Files:

    Last edited: Dec 9, 2014
  43. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    559
    You need to select deferred renderer on your camera instead of forward. Only deferred allows depth value calculation in SF.
     
    Deleted User likes this.
  44. RUNIARTS

    RUNIARTS

    Joined:
    Jun 22, 2013
    Posts:
    54
    Hi there Eideren ! Thanks so much for your Update to this Shader code ! And for all your Coolness !

    About that Shaderforge Clouds Shader !

    I think You should include The Shaderforge Nodes prototipe in your Clouds product Next Updates !
    Could be valuable to advanced users that might want to modify how the procedural noise Behaves and allow them to do advanced modifications as in normal mixtures, add more layers etc ...

    This is a Very Cool Asset ! Especially valuable for the Low 10$ Price tag !



    http://forum.unity3d.com/threads/re...te-highly-detailed-morphing-3d-clouds.274943/
    Some Debugs & Ideas Attached and Spoiled Bellow :


    Clouds Shader NExt Versions EVolution ..


    Im Actually looking a long time ago for Real volumetric Shaders ... in Unity ..

    Like the ones we can see in all webgl glory at Shadertoy

    https://www.shadertoy.com/results?query=volumetric



    Those Volumetric Procedural and Fractal Shader Codes there Are completly mind Blowing

    https://www.shadertoy.com/results?query=tag=fractal

    It seams that Will be more easy to bring those codes to Unity 5 Because of how Unity 5 Switched from Cg 2.2 to HLSL Natively Reads And compiles And converts HLSL code Directly ...

    But i Guess to bring ShaderToy Shaders Features TO UNITY Can become a MarketPlace for you Man ! :D

    RELIEF SHADERS IN SHADERFORGE DEBUGS

    Thanks Million much for the Update on the Relief ShaderForge code !

    It works alot better now ! The Relief is working Better "per uv segment" instead of Per poly now ...



    The Shader is Fast ! And non Expensive !

    And its working Prety good NOW !
    BUT JUST WORKS on Traditional Cubes or Spheres ...


    Whenever we try to aply it to a Actual mesh ...
    ( And nothing better than the Amazing 90's Stanford Bunny To prove it : )



    If we connect the Alpha on the Shader! It does Some Extra 3 Cool fx !

    1 - Shader cracks on UvSeams
    2 - In All meshes The Alpha got Zsort Issues ...
    3 - In some others the mesh Just Completely Disappears : )

    But Dont go for my Word just ...

    I uploaded a Repro Project Package
    ( for the usual Nothing better than the project to test bugs )




    Download here : https://db.tt/1TCTUPJf


    As far as i debugued , the Deep Sorting Issues in the code ...
    Appear even without alpha channel plugued ...

    BUT The Backfaces Zsorting & Mesh Disapearing issues
    ... actually go off If we Change the Blending mode from Alpha blended to none ...



    By the Way the Shader Just Works on Direct x 11 ...
    If one Change enviroment to Direct X 9 it trows Alot errors ...




    Well for other better news ...

    The AWSOME AceGikmo Did Added the DDX DDY nodes from Unreal !
    in Latest Update ..


    New in Shader Forge RC 0.37 / 1.0? : (Unreleased)
    • Added node: DDX
    • Added node: DDY

    This ddx/ddy are Used for Derivative Calculations in Bump Offset :

    https://docs.unrealengine.com/lates...essionReference/Utility/index.html#bumpoffset

    DDX/DDY
    The DDX expression exposes DDX/DDY derivative calculation, a GPU hardware feature used in pixel shader calculation.


    WIch means that as soon Next Version comes Out We will be able to Fully Port The Code for Relief I posted Some time ago ^^

    Visual Nodes Guide Full Size: http://s27.postimg.org/aaanohrbl/POM4.jpg





    http://forum.unity3d.com/threads/sh...sed-shader-editor.222049/page-45#post-1816324

    http://forum.unity3d.com/threads/sh...sed-shader-editor.222049/page-46#post-1818389


    Lets Keep our Fingers Crossed ....

    THANKS SO MUCH FOR ALL YOUR COOL HELP !

    Keep Great and grand !



    @IFL
    Cannabis Does you Bad !
    But You should Try Some HEMP SEEDS !
    Its the Exact Same Substance as Cannabis ...
    And is awesome to do all kind of Delicious Smoothies !
    http://www.cleancuisineandmore.com/hemp-seed-benefits/

    3DLabs is out ! Cheers ! :D
     
  45. Eideren

    Eideren

    Joined:
    Aug 20, 2013
    Posts:
    295
    @3DLABS
    Shader marked as alpha blended will almost always have depth issues.
    Once you connect something to the alpha input, sf will automatically change the blend mode to Alpha blended and it'll stay that way untill you change it yourself, that's the reason why you saw those errors when nothing was connected to the alpha node.
    If you want to have a better depth sorting, go to the blending tab in SF, deactivate auto sort then turn on "Write to depth Buffer".

    I also saw that you forgot about deactivating mipmap generation, change the texture type to "Advanced" in the texture importer and turn off the generate Mip Maps option.

    You shouldn't use the alpha clip in the sphere's case since the mesh is devoid of sharp edges.

    I dont have a clue as to what's going on with your rock, do you have the same problems with other imported assets ?

    Dx9 doesn't support loops well, Dx11 is always recommended if you have those kind of shaders, it'll perform better.
     
  46. donov

    donov

    Joined:
    Apr 15, 2013
    Posts:
    50
    Will this tool ever include a functionality like the new standard shader, turning of components/channels when not used?
     
  47. OneWayRoad

    OneWayRoad

    Joined:
    Jul 27, 2013
    Posts:
    26
    I wonder if theres a tutorial for hair shader.
     
  48. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,249
    In Shader Forge 1, probably not. In Shader Forge 2 though, it should definitely be supported :)
     
    OnePxl and Cascho01 like this.
  49. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,199
    What about making Shaderforge generally compatible to Unity5 Realtime/Baked-GI (Need of new Nodes)?
     
  50. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,249
    Coming soon!
     
    OnePxl likes this.
unityunity