Search Unity

Surface Shader cube normal

Discussion in 'Shaders' started by Phantomx, Jun 4, 2013.

  1. Phantomx

    Phantomx

    Joined:
    Oct 30, 2012
    Posts:
    202
    Hi,

    I want ton convert the unity toonshader to a surface shader. There is something I don't know how to convert. In the vertex program they do that:

    Code (csharp):
    1.            
    2. v2f vert (appdata v){
    3. v2f o;
    4. o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
    5. o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
    6. o.cubenormal = mul (UNITY_MATRIX_MV, half4(v.normal,0));
    7. return o;
    8. }
    9.  
    How does
    Code (csharp):
    1.  o.cubenormal = mul (UNITY_MATRIX_MV, half4(v.normal,0));
    translates in surface shader?

    Thanks!
     
  2. Phantomx

    Phantomx

    Joined:
    Oct 30, 2012
    Posts:
    202
    Nevermind, I found it!! it was the same, only the vertex program wasn't declared the same way!

    gives somthing like this:

    Code (csharp):
    1.  
    2.         void vert (inout appdata_full v, out Input o) {
    3.             UNITY_INITIALIZE_OUTPUT(Input,o);
    4.             o.cubeNorm = mul (UNITY_MATRIX_MV, half4(v.normal,0));
    5.  
    6.     }
    7.  
    8.  
     
    Last edited: Jun 4, 2013