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

Vertex Frag Bump shader ?

Discussion in 'Shaders' started by JonnyHilly, May 7, 2014.

  1. JonnyHilly

    JonnyHilly

    Joined:
    Sep 4, 2009
    Posts:
    742
    I'm looking for a bump map shader to modify...
    basicly I would like to add multipasses to a bump mapped shader....
    But everything I can find (built into unity, or the wiki) uses surface shaders, which can't use "Pass"
    Anyone know where I can find a "Transparent-Bump" shader compatible with usual Unity lighting and shadows etc... that is a Vert/Frag shader, and not a Surface shader please ?

    thanks
    Jon
     
  2. RC-1290

    RC-1290

    Joined:
    Jul 2, 2012
    Posts:
    639
    By taking a surface shader with normal mapping, adding #pragma debug and looking at the generated code. (This will be easier in Unity 4.5, then you just use the 'Show generated code' button)

    Surface shader do allow for extra passes, by the way. You just need to keep in mind that they will create a bunch of passes themselves.
     
  3. JonnyHilly

    JonnyHilly

    Joined:
    Sep 4, 2009
    Posts:
    742
    Thanks RC, I thought I found some docs saying you cant use Pass with surface... I did try just adding Pass{} with no other new code, around one of the standard bump surface shaders and it immediately gets syntax error, so I thought that confirmed that it didnt work.

    Thanks for the #pragma debug tip. :)
     
  4. RC-1290

    RC-1290

    Joined:
    Jul 2, 2012
    Posts:
    639
    It's definitely possible, I recently wrote a shader that added extra passes for the Vertex-Lit render path:

    Code (csharp):
    1. SubShader {
    2.    
    3.     // Surface Shader Passes:
    4.     CGPROGRAM
    5.     #pragma surface surf Lambert
    6.    
    7.     struct Input {
    8.         /* Input Stuff */
    9.     };
    10.  
    11.     void surf (Input IN, inout SurfaceOutput o) {
    12.         /* Surface shader stuff */
    13.     }
    14.     ENDCG
    15.    
    16.     // Vertex Lit:
    17.     Pass {
    18.         Tags { "LightMode" = "Vertex" }
    19.         CGPROGRAM
    20.         #pragma vertex vert
    21.         #pragma fragment frag
    22.         #include "UnityCG.cginc"
    23.        
    24.         /* Vertex and fragment shader here */
    25.        
    26.         ENDCG
    27.     }
    28. }
    In this case, the surface shader generates passes with the lightmodes ForwardBase, ForwardAdd, PrepassBase and PrepassFinal (And optionally some shadow passes), and an extra pass is used for the vertex-lit path. (VertexLM and VertexLMRGBM are also needed if you want vertex-lit lightmapping support)