Search Unity

In Dire need of assistance

Discussion in 'Shaders' started by Deleted User, Apr 12, 2017.

  1. Deleted User

    Deleted User

    Guest

    Hey all,

    I have been fooling around with shaders (copy pasting the work of other hoping to get something working) for the latest project i'm working on but i've run in a bit of a snag.
    So far I've been using Amplify/Shaderforge to built shaders but the next bit of functionality is from shader code which I very much DON'T understand.
    What I guess I'm really asking is if there is some kind soul out there willing to help me convert the following bit of shader code into Amplify/Shaderforge nodes.

    Code (csharp):
    1. Shader "CGShader5"
    2. {
    3.     SubShader
    4.     {
    5.         Pass
    6.         {
    7.             /*Cull Off*/
    8.  
    9.             CGPROGRAM
    10.  
    11.             #pragma vertex vert
    12.             #pragma fragment frag
    13.  
    14.             uniform float4x4 _CullerSpace;
    15.  
    16.             struct vout
    17.             {
    18.                 float4 pos : SV_POSITION;
    19.                 float4 worldpos : TEXCOORD0;
    20.                 float4 localpos : TEXCOORD1;
    21.                 float4 cullerpos : TEXCOORD2;
    22.             };
    23.  
    24.             vout vert(float4 vertex : POSITION)
    25.             {
    26.                 vout _out;
    27.                 _out.pos = mul(UNITY_MATRIX_MVP, vertex);
    28.                 _out.localpos = vertex;
    29.                 _out.worldpos = mul(unity_ObjectToWorld, vertex);
    30.                 _out.cullerpos = mul(_CullerSpace, _out.worldpos);
    31.                 return _out;
    32.             }
    33.  
    34.             float4 frag(vout _in) : COLOR
    35.             {
    36.                 /*if (length(_in.cullerpos.xyz) < 0.5)
    37.                     discard;*/
    38.                 if (_in.cullerpos.x > -0.5 && _in.cullerpos.x < 0.5 &&
    39.                 _in.cullerpos.y > -0.5 && _in.cullerpos.y < 0.5 &&
    40.                     _in.cullerpos.z > -0.5 && _in.cullerpos.z < 0.5)
    41.                     discard;
    42.  
    43.                 return float4(0, 1, 0, 1);
    44.             }
    45.  
    46.             ENDCG
    47.         }
    48.     }
    49. }
    p.s. all credit for the above shader goes to vexe