Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Shader Forge - A visual, node-based shader editor

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

  1. Monkee

    Monkee

    Joined:
    Sep 3, 2012
    Posts:
    8
    Hi guys. I'm developing on a mac, and before upgrading unity to 4.5.5f1 the shader instruction counters (fragment and vertex) would work if I disabled opengl and opengl es render targets. Now no matter what render target I turn on or off, I cannot get the shader instruction counters to work at all. Is there something I am doing wrong? I'm currently using SF 1.04
     
  2. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,293
    That's a known issue with a very low priority at the moment, so you'll have to go without it, I'm afraid!
     
  3. Monkee

    Monkee

    Joined:
    Sep 3, 2012
    Posts:
    8
    No worries Acegikmo, cheers for the prompt reply. Being low priority , I guess there is no ETA on a fix? Just in the process of optimisation at the moment.
     
  4. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,293
    Not really no
     
  5. JohnRossitter

    JohnRossitter

    Joined:
    Dec 18, 2013
    Posts:
    1,027
    Baby Alligator !
     
  6. ArthurClark

    ArthurClark

    Joined:
    May 12, 2013
    Posts:
    15
    Hi Acegikmo! Cool asset you have there! I'm thinking about buying it but I need one particular feature. I need to play sprite animation in shader. Can your product do that? Thank you!
     
  7. JohnRossitter

    JohnRossitter

    Joined:
    Dec 18, 2013
    Posts:
    1,027
    That helped me quite a bit.
    I have been working on a halftone toon shader for a while now, but just could not get the fall off shadows the way I wanted them.

    But here it is now:

    Screen Shot 2015-01-20 at 9.48.59 AM.png Screen Shot 2015-01-20 at 9.51.10 AM.png Screen Shot 2015-01-20 at 9.51.20 AM.png
     
  8. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    That's amazing.

    It definitely can.

    That looks great! [Unsolicited advice that you probably already know:] The moir pattern on the walls can be somewhat fixed by doing distance-based lerps to make the dots larger at set levels as the distance increases. The transition is a bit abrupt, but it's a tradeoff. The other fix, screen-space halftone (+shenanigans) never looks good when the camera moves/rotates, so UV halftone with distance is what has worked well for me. If you're just rendering stills though, screen-space is an easier solution, if you even want to fix it.
     
  9. JohnRossitter

    JohnRossitter

    Joined:
    Dec 18, 2013
    Posts:
    1,027
    Yeah, I'm going a UV halftone approach and Screenspace just could not work for me.
    My comic pages are animated, so the moir patterns are both cool and problematic at the same time.
    90% of my shader detail is emissive and like only 10% is actually based on lighting information.
    The next trick is to make a custom code node to calculate halftones realtime.
     
  10. KaylMyers

    KaylMyers

    Joined:
    Mar 28, 2013
    Posts:
    33
    sf_buildup_sf_1202015.png One more issue, Unity 5b19 SF 1.04
    Any idea why this is shading pink? Works fine until I try to connect in the lerped normals to the main node. Then all pink.
     
  11. Eideren

    Eideren

    Joined:
    Aug 20, 2013
    Posts:
    308
    @JohnRossitter I made this post a while back and I didn't need any code node at the time, it might give you an idea of how to proceed further with your shader.
    It's in screen Space but you can probably tell what you can do to change it to your liking.
     
    Last edited: Jan 20, 2015
  12. Eideren

    Eideren

    Joined:
    Aug 20, 2013
    Posts:
    308
    It might have to do with the fact that you want the normals to change based on a perturbed normal before the perturbed normal is created. In other words, the normal dir node shouldn't be perturbed when connected to a Normal output.(Perturbed means that the normal direction is calculated based on the normal map you gave him and not on the object's normals) I dont even know if you can input a non-perturbated normal dir in a Normal output.
     
  13. KaylMyers

    KaylMyers

    Joined:
    Mar 28, 2013
    Posts:
    33
    That did fix the problem. I'll have to compensate for that elsewhere I guess.
     
  14. JohnRossitter

    JohnRossitter

    Joined:
    Dec 18, 2013
    Posts:
    1,027
    Wow, thats a cool way to do it too.
    I'm going to play with that a bit and see if I can integrate it into my tree.
     
  15. KaylMyers

    KaylMyers

    Joined:
    Mar 28, 2013
    Posts:
    33
    Thanks for all your help so far folks. I am no tech artist, but I'm the closest our studio has at the moment. I'm creating a snow build-up shader using dx11 displacement to add snow to the tops of objects. I have all the masking working properly so that as you rotate an object in the world. The snow always appears on top (your basic slope shader). Problem is when I plug that system into the displacement slot, the displacement always follows the local coordinates of the object, rather than the world coordinates like the diffuse and normal masks. Am I missing something? A unity 5 bug? dx11wrong.jpg sf_buildup_sf_1202015.png
     
  16. vitaly2

    vitaly2

    Joined:
    Apr 3, 2013
    Posts:
    4
    quick question for you guys. I'm trying to animate some values using the standard unity animation, but it's just not working.
    Is there an issue with keyframing the shaders or am I just doing something stupid?
    Or maybe there's a way I can input an animated value?
     
  17. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    To anyone with too much time on their hands, here's a shader.
    SF_Who.jpg
    Code (CSharp):
    1. // Shader created with Shader Forge v1.03
    2. // Shader Forge (c) Neat Corporation / Joachim Holmer - http://www.acegikmo.com/shaderforge/
    3. // Note: Manually altering this data may prevent you from opening it in Shader Forge
    4. /*SF_DATA;ver:1.03;sub:START;pass:START;ps:flbk:,lico:1,lgpr:1,nrmq:1,limd:1,uamb:True,mssp:True,lmpd:False,lprd:False,rprd:False,enco:False,frtr:True,vitr:True,dbil:True,rmgx:True,rpth:0,hqsc:True,hqlp:False,tesm:0,blpr:0,bsrc:0,bdst:1,culm:0,dpts:2,wrdp:True,dith:2,ufog:True,aust:True,igpj:False,qofs:0,qpre:1,rntp:1,fgom:False,fgoc:False,fgod:False,fgor:False,fgmd:0,fgcr:0.5,fgcg:0.5,fgcb:0.5,fgca:1,fgde:0.01,fgrn:0,fgrf:300,ofsf:0,ofsu:0,f2p0:False;n:type:ShaderForge.SFN_Final,id:4022,x:34179,y:32902,varname:node_4022,prsc:2|diff-1408-OUT,emission-2420-OUT;n:type:ShaderForge.SFN_Add,id:2446,x:31758,y:32855,varname:node_2446,prsc:2|A-5905-OUT,B-5821-OUT;n:type:ShaderForge.SFN_Subtract,id:8990,x:31951,y:32855,varname:node_8990,prsc:2|A-2446-OUT,B-9816-OUT;n:type:ShaderForge.SFN_Vector1,id:9816,x:31951,y:32980,varname:node_9816,prsc:2,v1:1;n:type:ShaderForge.SFN_Abs,id:6700,x:32123,y:32855,varname:node_6700,prsc:2|IN-8990-OUT;n:type:ShaderForge.SFN_OneMinus,id:597,x:32498,y:32855,varname:node_597,prsc:2|IN-3174-OUT;n:type:ShaderForge.SFN_Multiply,id:3174,x:32316,y:32855,varname:node_3174,prsc:2|A-6700-OUT,B-3496-OUT;n:type:ShaderForge.SFN_Vector1,id:3496,x:32316,y:32987,varname:node_3496,prsc:2,v1:5;n:type:ShaderForge.SFN_Vector1,id:2118,x:31214,y:32640,varname:node_2118,prsc:2,v1:0.5;n:type:ShaderForge.SFN_Abs,id:5905,x:31575,y:32696,varname:node_5905,prsc:2|IN-8573-OUT;n:type:ShaderForge.SFN_OneMinus,id:7091,x:31385,y:32855,varname:node_7091,prsc:2|IN-9907-OUT;n:type:ShaderForge.SFN_Subtract,id:8573,x:31214,y:32697,varname:node_8573,prsc:2|A-9844-R,B-2118-OUT;n:type:ShaderForge.SFN_Add,id:5821,x:31575,y:32855,varname:node_5821,prsc:2|A-7091-OUT,B-1356-OUT;n:type:ShaderForge.SFN_Vector1,id:1356,x:31575,y:32978,varname:node_1356,prsc:2,v1:-0.2;n:type:ShaderForge.SFN_Min,id:9715,x:33436,y:33002,varname:node_9715,prsc:2|A-4753-OUT,B-5404-OUT,C-9903-OUT;n:type:ShaderForge.SFN_Add,id:997,x:31214,y:33045,varname:node_997,prsc:2|A-9844-G,B-382-OUT;n:type:ShaderForge.SFN_Vector1,id:5454,x:30157,y:33171,varname:node_5454,prsc:2,v1:0.2;n:type:ShaderForge.SFN_Multiply,id:8657,x:32498,y:32698,varname:node_8657,prsc:2|A-5905-OUT,B-8727-OUT;n:type:ShaderForge.SFN_Vector1,id:8727,x:32498,y:32644,varname:node_8727,prsc:2,v1:1.2;n:type:ShaderForge.SFN_OneMinus,id:4753,x:33195,y:32698,varname:node_4753,prsc:2|IN-2094-OUT;n:type:ShaderForge.SFN_Multiply,id:9808,x:32668,y:32855,varname:node_9808,prsc:2|A-597-OUT,B-3123-OUT;n:type:ShaderForge.SFN_Clamp01,id:9450,x:32841,y:32855,varname:node_9450,prsc:2|IN-9808-OUT;n:type:ShaderForge.SFN_Clamp01,id:5404,x:33195,y:32855,varname:node_5404,prsc:2|IN-7999-OUT;n:type:ShaderForge.SFN_ScreenPos,id:3455,x:30096,y:32489,varname:node_3455,prsc:2,sctp:0;n:type:ShaderForge.SFN_ComponentMask,id:9844,x:30900,y:32812,varname:node_9844,prsc:2,cc1:0,cc2:1,cc3:-1,cc4:-1|IN-6515-OUT;n:type:ShaderForge.SFN_Multiply,id:7368,x:30165,y:32647,varname:node_7368,prsc:2|A-3455-UVOUT,B-4043-OUT,C-8146-OUT;n:type:ShaderForge.SFN_Clamp01,id:6515,x:30714,y:32812,varname:node_6515,prsc:2|IN-2152-OUT;n:type:ShaderForge.SFN_Power,id:9907,x:31214,y:32855,varname:node_9907,prsc:2|VAL-9844-G,EXP-9176-OUT;n:type:ShaderForge.SFN_Vector1,id:382,x:31214,y:33171,varname:node_382,prsc:2,v1:0.1;n:type:ShaderForge.SFN_Time,id:8636,x:29571,y:32959,varname:node_8636,prsc:2;n:type:ShaderForge.SFN_Sin,id:1032,x:29972,y:33033,varname:node_1032,prsc:2|IN-3586-OUT;n:type:ShaderForge.SFN_Multiply,id:2406,x:30157,y:33033,varname:node_2406,prsc:2|A-1032-OUT,B-5454-OUT;n:type:ShaderForge.SFN_Vector1,id:9176,x:31214,y:32979,varname:node_9176,prsc:2,v1:3;n:type:ShaderForge.SFN_Add,id:2152,x:30545,y:32812,varname:node_2152,prsc:2|A-3853-OUT,B-3878-OUT;n:type:ShaderForge.SFN_Multiply,id:3586,x:29779,y:32959,varname:node_3586,prsc:2|A-9525-OUT,B-8636-T;n:type:ShaderForge.SFN_Vector1,id:9525,x:29779,y:32905,varname:node_9525,prsc:2,v1:0.75;n:type:ShaderForge.SFN_RemapRange,id:6585,x:31385,y:33045,varname:node_6585,prsc:2,frmn:0,frmx:1,tomn:-3,tomx:3|IN-997-OUT;n:type:ShaderForge.SFN_Vector1,id:7453,x:31575,y:33174,varname:node_7453,prsc:2,v1:25;n:type:ShaderForge.SFN_RemapRange,id:9903,x:31758,y:33045,varname:node_9903,prsc:2,frmn:-3,frmx:3,tomn:0,tomx:1|IN-6955-OUT;n:type:ShaderForge.SFN_Distance,id:8980,x:29785,y:32647,varname:node_8980,prsc:2|A-10-XYZ,B-1196-XYZ;n:type:ShaderForge.SFN_ObjectPosition,id:10,x:29571,y:32580,varname:node_10,prsc:2;n:type:ShaderForge.SFN_ViewPosition,id:1196,x:29571,y:32707,varname:node_1196,prsc:2;n:type:ShaderForge.SFN_Multiply,id:6955,x:31575,y:33045,varname:node_6955,prsc:2|A-6585-OUT,B-7453-OUT;n:type:ShaderForge.SFN_Add,id:3853,x:30349,y:32647,varname:node_3853,prsc:2|A-1212-OUT,B-7368-OUT;n:type:ShaderForge.SFN_Vector1,id:1212,x:30349,y:32592,varname:node_1212,prsc:2,v1:0.5;n:type:ShaderForge.SFN_Vector1,id:8146,x:29970,y:32771,varname:node_8146,prsc:2,v1:2;n:type:ShaderForge.SFN_Max,id:4043,x:29970,y:32647,varname:node_4043,prsc:2|A-8980-OUT,B-8146-OUT;n:type:ShaderForge.SFN_Multiply,id:5097,x:33778,y:33002,varname:node_5097,prsc:2|A-254-OUT,B-6205-OUT;n:type:ShaderForge.SFN_Vector3,id:254,x:33778,y:32908,varname:node_254,prsc:2,v1:1,v2:0,v3:0;n:type:ShaderForge.SFN_LightAttenuation,id:7377,x:32936,y:33147,varname:node_7377,prsc:2;n:type:ShaderForge.SFN_Clamp01,id:8266,x:33107,y:33147,varname:node_8266,prsc:2|IN-7377-OUT;n:type:ShaderForge.SFN_RemapRange,id:1570,x:33442,y:33147,varname:node_1570,prsc:2,frmn:0,frmx:1,tomn:-3,tomx:3|IN-5443-OUT;n:type:ShaderForge.SFN_Multiply,id:6304,x:33619,y:33147,varname:node_6304,prsc:2|A-1570-OUT,B-1350-OUT;n:type:ShaderForge.SFN_Vector1,id:1350,x:33619,y:33286,varname:node_1350,prsc:2,v1:25;n:type:ShaderForge.SFN_RemapRange,id:1699,x:33792,y:33147,varname:node_1699,prsc:2,frmn:-3,frmx:3,tomn:0,tomx:1|IN-6304-OUT;n:type:ShaderForge.SFN_Multiply,id:2420,x:33956,y:33002,varname:node_2420,prsc:2|A-5097-OUT,B-1627-OUT;n:type:ShaderForge.SFN_Vector1,id:1408,x:34179,y:32847,varname:node_1408,prsc:2,v1:1;n:type:ShaderForge.SFN_Clamp01,id:6205,x:33603,y:33002,varname:node_6205,prsc:2|IN-9715-OUT;n:type:ShaderForge.SFN_OneMinus,id:5443,x:33272,y:33147,varname:node_5443,prsc:2|IN-8266-OUT;n:type:ShaderForge.SFN_Clamp01,id:1627,x:33956,y:33147,varname:node_1627,prsc:2|IN-1699-OUT;n:type:ShaderForge.SFN_Cos,id:839,x:29972,y:32889,varname:node_839,prsc:2|IN-3586-OUT;n:type:ShaderForge.SFN_Append,id:3878,x:30354,y:32948,varname:node_3878,prsc:2|A-7261-OUT,B-2406-OUT;n:type:ShaderForge.SFN_Multiply,id:7261,x:30157,y:32889,varname:node_7261,prsc:2|A-2668-OUT,B-839-OUT;n:type:ShaderForge.SFN_Vector1,id:2668,x:30157,y:32836,varname:node_2668,prsc:2,v1:-0.05;n:type:ShaderForge.SFN_Vector1,id:3123,x:32668,y:32976,varname:node_3123,prsc:2,v1:5;n:type:ShaderForge.SFN_Power,id:7999,x:33019,y:32855,varname:node_7999,prsc:2|VAL-9450-OUT,EXP-1183-OUT;n:type:ShaderForge.SFN_Vector1,id:1183,x:33019,y:32976,varname:node_1183,prsc:2,v1:3;n:type:ShaderForge.SFN_RemapRange,id:4784,x:32669,y:32698,varname:node_4784,prsc:2,frmn:0,frmx:1,tomn:-3,tomx:3|IN-8657-OUT;n:type:ShaderForge.SFN_Multiply,id:8429,x:32846,y:32698,varname:node_8429,prsc:2|A-828-OUT,B-4784-OUT;n:type:ShaderForge.SFN_Vector1,id:828,x:32846,y:32640,varname:node_828,prsc:2,v1:25;n:type:ShaderForge.SFN_RemapRange,id:2094,x:33019,y:32698,varname:node_2094,prsc:2,frmn:-3,frmx:3,tomn:0,tomx:1|IN-8429-OUT;pass:END;sub:END;*/
    5.  
    6. Shader "Shader Forge/who_is_there" {
    7.     Properties {
    8.     }
    9.     SubShader {
    10.         Tags {
    11.             "RenderType"="Opaque"
    12.         }
    13.         Pass {
    14.             Name "ForwardBase"
    15.             Tags {
    16.                 "LightMode"="ForwardBase"
    17.             }
    18.        
    19.        
    20.             CGPROGRAM
    21.             #pragma vertex vert
    22.             #pragma fragment frag
    23.             #define UNITY_PASS_FORWARDBASE
    24.             #include "UnityCG.cginc"
    25.             #include "AutoLight.cginc"
    26.             #include "Lighting.cginc"
    27.             #pragma multi_compile_fwdbase_fullshadows
    28.             #pragma multi_compile_fog
    29.             #pragma exclude_renderers xbox360 ps3 flash d3d11_9x
    30.             #pragma target 3.0
    31.             uniform float4 _TimeEditor;
    32.             float4 unity_LightmapST;
    33.             #ifdef DYNAMICLIGHTMAP_ON
    34.                 float4 unity_DynamicLightmapST;
    35.             #endif
    36.             struct VertexInput {
    37.                 float4 vertex : POSITION;
    38.                 float3 normal : NORMAL;
    39.             };
    40.             struct VertexOutput {
    41.                 float4 pos : SV_POSITION;
    42.                 float4 posWorld : TEXCOORD0;
    43.                 float3 normalDir : TEXCOORD1;
    44.                 float4 screenPos : TEXCOORD2;
    45.                 LIGHTING_COORDS(3,4)
    46.                 UNITY_FOG_COORDS(5)
    47.                 #ifndef LIGHTMAP_OFF
    48.                     float4 uvLM : TEXCOORD6;
    49.                 #else
    50.                     float3 shLight : TEXCOORD6;
    51.                 #endif
    52.             };
    53.             VertexOutput vert (VertexInput v) {
    54.                 VertexOutput o = (VertexOutput)0;
    55.                 o.normalDir = mul(_Object2World, float4(v.normal,0)).xyz;
    56.                 float4 objPos = mul ( _Object2World, float4(0,0,0,1) );
    57.                 o.posWorld = mul(_Object2World, v.vertex);
    58.                 float3 lightColor = _LightColor0.rgb;
    59.                 o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
    60.                 UNITY_TRANSFER_FOG(o,o.pos);
    61.                 o.screenPos = o.pos;
    62.                 TRANSFER_VERTEX_TO_FRAGMENT(o)
    63.                 return o;
    64.             }
    65.             fixed4 frag(VertexOutput i) : COLOR {
    66.                 float4 objPos = mul ( _Object2World, float4(0,0,0,1) );
    67.                 i.normalDir = normalize(i.normalDir);
    68.                 i.screenPos = float4( i.screenPos.xy / i.screenPos.w, 0, 0 );
    69.                 i.screenPos.y *= _ProjectionParams.x;
    70. /////// Vectors:
    71.                 float3 normalDirection = i.normalDir;
    72.                 float3 lightDirection = normalize(_WorldSpaceLightPos0.xyz);
    73.                 float3 lightColor = _LightColor0.rgb;
    74. ////// Lighting:
    75.                 float attenuation = LIGHT_ATTENUATION(i)*2;
    76.                 float3 attenColor = attenuation * _LightColor0.xyz;
    77. /////// Diffuse:
    78.                 float NdotL = max(0.0,dot( normalDirection, lightDirection ));
    79.                 float3 indirectDiffuse = float3(0,0,0);
    80.                 float3 directDiffuse = max( 0.0, NdotL) * attenColor;
    81.                 indirectDiffuse += UNITY_LIGHTMODEL_AMBIENT.rgb*2; // Ambient Light
    82.                 float node_1408 = 1.0;
    83.                 float3 diffuse = (directDiffuse + indirectDiffuse) * float3(node_1408,node_1408,node_1408);
    84. ////// Emissive:
    85.                 float node_1212 = 0.5;
    86.                 float node_8980 = distance(objPos.rgb,_WorldSpaceCameraPos);
    87.                 float node_8146 = 2.0;
    88.                 float2 node_7368 = (i.screenPos.rg*max(node_8980,node_8146)*node_8146);
    89.                 float4 node_8636 = _Time + _TimeEditor;
    90.                 float node_3586 = (0.75*node_8636.g);
    91.                 float node_1032 = sin(node_3586);
    92.                 float node_2406 = (node_1032*0.2);
    93.                 float2 node_9844 = saturate(((node_1212+node_7368)+float2(((-0.05)*cos(node_3586)),node_2406))).rg;
    94.                 float node_2118 = 0.5;
    95.                 float node_8657 = (abs((node_9844.r-node_2118))*1.2);
    96.                 float node_7091 = (1.0 - pow(node_9844.g,3.0));
    97.                 float node_6700 = abs(((abs((node_9844.r-node_2118))+(node_7091+(-0.2)))-1.0));
    98.                 float node_9808 = ((1.0 - (node_6700*5.0))*5.0);
    99.                 float node_9450 = saturate(node_9808);
    100.                 float node_382 = 0.1;
    101.                 float node_997 = (node_9844.g+node_382);
    102.                 float node_6585 = (node_997*6.0+-3.0);
    103.                 float node_7453 = 25.0;
    104.                 float3 emissive = ((float3(1,0,0)*saturate(min(min((1.0 - ((25.0*(node_8657*6.0+-3.0))*0.1666667+0.5)),saturate(pow(node_9450,3.0))),((node_6585*node_7453)*0.1666667+0.5))))*saturate(((((1.0 - saturate(attenuation))*6.0+-3.0)*25.0)*0.1666667+0.5)));
    105. /// Final Color:
    106.                 float3 finalColor = diffuse + emissive;
    107.                 fixed4 finalRGBA = fixed4(finalColor,1);
    108.                 UNITY_APPLY_FOG(i.fogCoord, finalRGBA);
    109.                 return finalRGBA;
    110.             }
    111.             ENDCG
    112.         }
    113.         Pass {
    114.             Name "ForwardAdd"
    115.             Tags {
    116.                 "LightMode"="ForwardAdd"
    117.             }
    118.             Blend One One
    119.        
    120.        
    121.             CGPROGRAM
    122.             #pragma vertex vert
    123.             #pragma fragment frag
    124.             #define UNITY_PASS_FORWARDADD
    125.             #include "UnityCG.cginc"
    126.             #include "AutoLight.cginc"
    127.             #include "Lighting.cginc"
    128.             #pragma multi_compile_fwdadd_fullshadows
    129.             #pragma multi_compile_fog
    130.             #pragma exclude_renderers xbox360 ps3 flash d3d11_9x
    131.             #pragma target 3.0
    132.             uniform float4 _TimeEditor;
    133.             float4 unity_LightmapST;
    134.             #ifdef DYNAMICLIGHTMAP_ON
    135.                 float4 unity_DynamicLightmapST;
    136.             #endif
    137.             struct VertexInput {
    138.                 float4 vertex : POSITION;
    139.                 float3 normal : NORMAL;
    140.             };
    141.             struct VertexOutput {
    142.                 float4 pos : SV_POSITION;
    143.                 float4 posWorld : TEXCOORD0;
    144.                 float3 normalDir : TEXCOORD1;
    145.                 float4 screenPos : TEXCOORD2;
    146.                 LIGHTING_COORDS(3,4)
    147.                 #ifndef LIGHTMAP_OFF
    148.                     float4 uvLM : TEXCOORD5;
    149.                 #else
    150.                     float3 shLight : TEXCOORD5;
    151.                 #endif
    152.             };
    153.             VertexOutput vert (VertexInput v) {
    154.                 VertexOutput o = (VertexOutput)0;
    155.                 o.normalDir = mul(_Object2World, float4(v.normal,0)).xyz;
    156.                 float4 objPos = mul ( _Object2World, float4(0,0,0,1) );
    157.                 o.posWorld = mul(_Object2World, v.vertex);
    158.                 float3 lightColor = _LightColor0.rgb;
    159.                 o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
    160.                 o.screenPos = o.pos;
    161.                 TRANSFER_VERTEX_TO_FRAGMENT(o)
    162.                 return o;
    163.             }
    164.             fixed4 frag(VertexOutput i) : COLOR {
    165.                 float4 objPos = mul ( _Object2World, float4(0,0,0,1) );
    166.                 i.normalDir = normalize(i.normalDir);
    167.                 i.screenPos = float4( i.screenPos.xy / i.screenPos.w, 0, 0 );
    168.                 i.screenPos.y *= _ProjectionParams.x;
    169. /////// Vectors:
    170.                 float3 normalDirection = i.normalDir;
    171.                 float3 lightDirection = normalize(lerp(_WorldSpaceLightPos0.xyz, _WorldSpaceLightPos0.xyz - i.posWorld.xyz,_WorldSpaceLightPos0.w));
    172.                 float3 lightColor = _LightColor0.rgb;
    173. ////// Lighting:
    174.                 float attenuation = LIGHT_ATTENUATION(i)*2;
    175.                 float3 attenColor = attenuation * _LightColor0.xyz;
    176. /////// Diffuse:
    177.                 float NdotL = max(0.0,dot( normalDirection, lightDirection ));
    178.                 float3 directDiffuse = max( 0.0, NdotL) * attenColor;
    179.                 float node_1408 = 1.0;
    180.                 float3 diffuse = directDiffuse * float3(node_1408,node_1408,node_1408);
    181. /// Final Color:
    182.                 float3 finalColor = diffuse;
    183.                 return fixed4(finalColor * 1,0);
    184.             }
    185.             ENDCG
    186.         }
    187.     }
    188.     FallBack "Diffuse"
    189.     CustomEditor "ShaderForgeMaterialInspector"
    190. }
    191.  

    I like this a lot. I'll help you tomorrow if no one else has.
    [EDIT::] You can correct the snow's rotation by transforming the Normal from world to local space, but the displacement rotation just won't match up for me. It works great if the transformation isn't done for the snow, but as soon as the snow is corrected, it breaks the displacement. Also, it's not just tesselation - the same happens in standard vertex dispalcement. I'd be really interested if anyone has a solution.
     
    Last edited: Jan 21, 2015
  18. Sylmerria

    Sylmerria

    Joined:
    Jul 2, 2012
    Posts:
    365
    Hi,

    Have you a ETA for support stencil buffer ? Because now it's free and for support it, it's "just" ( with big " :) ) a menu like blending.
     
  19. sundance

    sundance

    Joined:
    Mar 19, 2014
    Posts:
    52
    Hi, i have touble with standard bloom post effect. I use IBL shader from shader forge.

    Lighting source must be behind object.
    Without HDR:

    With HDR:

    Is this feature of shader forge or i just make something wrong?
    P.S. Unity 5b18, Shader Forge 1.04.
     
  20. KaylMyers

    KaylMyers

    Joined:
    Mar 28, 2013
    Posts:
    33
    The idea is to have the snow always on top facing y in world space. So converting to local space wont work for me here. I also tried converting the displacement from local to world space, but that doesn't give me the desired result either. Its so close:(
     
  21. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    Is anyone interested in a very generic comic-ish node graph? It currently needs some fixing up and commenting, but it's fairly functional in that it shows some of the basic concepts, like distance-based halftone scaling, triplanar vs UV halftone, edge darkening, light-ramp with or without a ramp texture, and rough (wobbly) ramp lighting (for a more hand-drawn look).
    SF_Jan15ComicShader_Overview01.jpg
    SF_Jan15ComicShader_Overview02.jpg

    Yep, I tried a few more things to no avail. It's probably something easy to fix, but I don't know how. :oops:
     
  22. JohnRossitter

    JohnRossitter

    Joined:
    Dec 18, 2013
    Posts:
    1,027
    Well that's a mouthful :)
     
  23. JohnRossitter

    JohnRossitter

    Joined:
    Dec 18, 2013
    Posts:
    1,027
    Here is the one I'm working with:
    I guess the main difference being that I'm not trying to calculate the halftone at runtime, but rather have is specified as a texture input based on the existing texture.....oh and the fact that im pushing ramped lighting into the diffuse channel
    Screen Shot 2015-01-21 at 2.00.32 PM.png Screen Shot 2015-01-21 at 1.57.12 PM.png
     
  24. Shushustorm

    Shushustorm

    Joined:
    Jan 6, 2014
    Posts:
    1,084
    Hello everyone!

    Recently, I have updated Shader Forge and after some testing, I am running into several problems.
    Maybe someone can help me with that. I don't know if those are still bugs or if I am doing something wrong.

    1. See 01image. This appears every time I am saving while a shader made in Shader Forge v1.04 is in the project. Restarting Unity solves this problem until the shader is edited again or a new shader is added.

    01image:
    01image.PNG

    2. Sometimes, when duplicating nodes, I am running into name conflicts. (see 02image) Most of the time this happens when duplicating texture / texture asset nodes.

    02image:
    02image.PNG

    3. Sometimes texture asset nodes are not appearing inside Shader Forges properties, nor in the object's material component in Unity, even though the node is connected properly.

    4. See 04image. Sometimes those errors occur. I don't know why, but the material turns pink. When I compile the shader again in Shader Forge, the errors and the pink color disappear. (see 04image2)

    04image:
    04image.PNG

    04image2:
    04image2.PNG

    Many thanks in advance,
    Greetings,
    Shu


    EDIT:
    Also, if this information is useful:
    I am using Unity 4.6.0f3.
     
    Last edited: Jan 21, 2015
  25. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    A project I'm currently working on requires I setup a custom projection matrix for my camera in Unity. Because of this implementation, much of the lighting and shadows are either incorrect or non-existent. I have lighting working with ShaderForge, but I can't seem to get the shadow casting to show up correctly. I was wondering if somebody might be able to point me in the right position for how I can achieve my own shadows in a shader. Preferably using ShaderForge.
     
    Last edited: Jan 22, 2015
  26. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    Hello, I've started using Unity 5.0 beta 20 and I've come across an issue with the shaders created with Shader Forge. Here's an example of simple alpha cutout. On the left is the SF shader and on the right is Unity 5's new standard shader set to cutout. They both look normal (they're set to different colors):



    And here are the same planes rotated on the spot. They should both be invisible (since the planes are single-sided and so are the shaders). But as you can see the Shader-Forge created cutout shader is NOT invisible:



    The same problem happens with tessellated shaders as well. Basically it looks like shaders created with Shader Forge look wrong whenever back faces are visible. Instead of simply not being rendered they show the skybox (or whatever solid BG color you set).

    Does anyone have an idea about fixing this issue?
     
  27. sundance

    sundance

    Joined:
    Mar 19, 2014
    Posts:
    52
    Ok, i understood the reason of problem.
    We just need to add clamp function for final specular in forward base pass.


    P.S. I think this is should be fix.
     
    FreakForFreedom likes this.
  28. KaylMyers

    KaylMyers

    Joined:
    Mar 28, 2013
    Posts:
    33
    Are you writing to the depth buffer on your shader? If so, try turning that off and see if you get the proper result.
     
  29. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    Well I don't know how to set that option in Shader Forge but looking directly at the shader source it says "ZWrite Off". I also tried "ZWrite On" but it didn't change anything.
     
  30. KaylMyers

    KaylMyers

    Joined:
    Mar 28, 2013
    Posts:
    33
    Huh. It would be in your blending settings. If you uncheck auto sort it will give you access to a "write to depth buffer" check box. I don't know if it does anything under the hood other than adding the zwrite on or off.
     
  31. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    Thanks! But those are the only options available for me there:

     
  32. KaylMyers

    KaylMyers

    Joined:
    Mar 28, 2013
    Posts:
    33
    Ah, looks like the deferred prepass removes the sorting overrides. Does it work in forward?
     
  33. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    Indeed, so I switched to Forward and I must have tried almost all the variant on all the blending settings and none of them worked.

    I also noticed that if I unplug the alpha from the Alpha Clip port on the main node, then the issue disappears; the backfaces are not rendered anymore (as is expected). So it's the alpha (transparent cutout) that seems to create the problem...
     
  34. KaylMyers

    KaylMyers

    Joined:
    Mar 28, 2013
    Posts:
    33
    Not sure on that one then. Seems like an odd behavior. Another bug maybe?
     
  35. KaylMyers

    KaylMyers

    Joined:
    Mar 28, 2013
    Posts:
    33
    Is there another forum for this stuff by the way? I hate to keep filling up this one thread with so many different projects and questions...
     
    Deon-Cadme likes this.
  36. ryan chen

    ryan chen

    Joined:
    Jan 21, 2015
    Posts:
    7
    Looking for this dissolve effect ! please help me!
     
  37. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    Yes, it really looks like it... :(
     
  38. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    I hate it too, but this seems to be the only thread for issues related to Shader-Forge shaders and the author comes by fairly often. Of course there's the Shader Forge site itself but it's mostly for bug reports and feature requests....
     
    Deon-Cadme likes this.
  39. Deon-Cadme

    Deon-Cadme

    Joined:
    Sep 10, 2013
    Posts:
    288
    Has @Acegikmo (Joachim) ever played with the idea of setting up his own forum on the website? He could probably pick out a few voluntary moderators from the community after a while or ask active members in this area to help him.

    I just started learning about shaders, went fairly well so far, managed to put together a few cool effects xD
    Shader Forge is awesome for learning but I feel bad at the thought of writing here every time I have a simple, beginner questions. Many topics could probably, on their own, snowball into threads like this one if the SF community had more space.
     
  40. DMeville

    DMeville

    Joined:
    May 5, 2013
    Posts:
    418
    Last edited: Jan 22, 2015
  41. TBruce

    TBruce

    Joined:
    Jan 18, 2015
    Posts:
    86
    Hi,

    I have a line created with the LineRender and a square sprite that has a transparent cutout. Occasionally will I need to place the box on the line and mask out the part of the line the box is on. Only that part of the line need be masked out.

    I will enable/disable the sprite at will. Below are 2 example images to show what I am trying to accomplish.

    Can you please tell me if SF can accomplish this? Thanks in advance.


     
    Last edited: Jan 23, 2015
  42. ryan chen

    ryan chen

    Joined:
    Jan 21, 2015
    Posts:
    7
  43. DMeville

    DMeville

    Joined:
    May 5, 2013
    Posts:
    418
    Definitely possible, just might take a bit of work ;) Some of the ideas behind the hologram shader on the wiki could be helpful as well (http://acegikmo.com/shaderforge/wiki/index.php?title=Hologram_Shader)

    Maybe I'll play around with it in my free time today, looks like a neat effect to try and recreate
     
  44. ryan chen

    ryan chen

    Joined:
    Jan 21, 2015
    Posts:
    7
    Great, I will be referring Hologram Shader, try to make it。
     
  45. KaylMyers

    KaylMyers

    Joined:
    Mar 28, 2013
    Posts:
    33
    http://wiki.unity3d.com/index.php?title=DepthMask

    Shader Forge can be used to recreate the shader there.
     
  46. ryan chen

    ryan chen

    Joined:
    Jan 21, 2015
    Posts:
    7
    Today I tried to do a bit :), I'm not a professional, you help me look at what needs improvement。

     
  47. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    Here's a force field effect I made entirely in SF (except glow post effect). I can't share the source, but I think it looks cool...
    SF_ForceField01.jpg
    SF_ForceField04.gif
     
    Baldinoboy likes this.
  48. Play_Edu

    Play_Edu

    Joined:
    Jun 10, 2012
    Posts:
    722
    cool effect
     
  49. Obsurveyor

    Obsurveyor

    Joined:
    Nov 22, 2012
    Posts:
    277
    Are there known issues with Alpha Clip? I was playing with some of the recent shaders from the thread and had ShaderForge mangle shaders in some weird ways. I wasn't doing anything more innocuous than connecting and disconnecting to Alpha Clip. I haven't been able to find a way to reproduce all of them yet(but I'll be working on this more today) so I only have a screenshot of one. The issues I ran into, with 1.04 and a brand new Unity 4.6.1f1 project:
    1. I have a shader that is just completely unable to attach anything to Alpha/Alpha Clip/Refraction/Outline Width or DX11 Tessellation. Any time you drag something that could potentially attach, they all gray out with only Vertex Offset available. Fixed: Somehow RGB got connected into the graph when it should have just been R. Probably did it while playing around.
    2. The shaders that use Alpha Clip are getting corrupted when I close and re-open them(doesn't matter if I use the x on the window or click Return to menu). They get this weird halftone looking alpha clip applied to them when they're opened up. The only way to fix them is to copy and paste them into a new shader... until they corrupt again. Here's an example:

    [shader source]
     
    Last edited: Jan 24, 2015
  50. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,840
    you simply have to take out the following line:
    Cull Off
    in the custom "ShadowCaster" pass.

    lars