Search Unity

Mixing built in shaders?

Discussion in 'Shaders' started by yair1221, Feb 1, 2013.

  1. yair1221

    yair1221

    Joined:
    Sep 28, 2011
    Posts:
    39
    hi, im trying to create a reflective shader that won't be affected by the alpha channel, meaning, it would react the same on the whole model...im having some difficulties in mixing some of the basic unity shaders to create that effect...
    heres what i got so far:
    Code (csharp):
    1. Shader "Custom/ReflectiveTeam" {
    2.     Properties {
    3.         _MainTex ("Base (RGB)", 2D) = "white" {}
    4.         _BumpMap ("Bumpmap", 2D) = "bump" {}
    5.         _Cube ("Cubemap", CUBE) = "" {}
    6.     }
    7.     SubShader {
    8.         Tags { "RenderType"="Opaque" }
    9.         LOD 200
    10.        
    11.         CGPROGRAM
    12.         #pragma surface surf Lambert
    13.  
    14.         sampler2D _MainTex;
    15.         sampler2D _BumpMap;
    16.         samplerCUBE _Cube;
    17.  
    18.         struct Input {
    19.             float2 uv_MainTex;
    20.             float2 uv_BumpMap;
    21.             float3 worldRefl;
    22.         };
    23.  
    24.         void surf (Input IN, inout SurfaceOutput o) {
    25.             half4 c = tex2D (_MainTex, IN.uv_MainTex);
    26.             o.Albedo = c.rgb;
    27.             o.Alpha = c.a;
    28.             o.Normal = UnpackNormal (tex2D (_BumpMap, IN.uv_BumpMap));
    29.             o.Emission = texCUBE (_Cube, IN.worldRefl).rgb;
    30.         }
    31.         ENDCG
    32.     }
    33.     FallBack "Diffuse"
    34. }
    i just get tons of errors about missing stuff and things that are compiled for directx11 and so on...

    can anyone help me a bit?
     
  2. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    You're missing the following on line 21:
    Code (csharp):
    1. float3 worldRefl; INTERNAL_DATA
    The INTERNAL_DATA macro is required whenever you're adding these elements and writing to o.Normal.
     
  3. yair1221

    yair1221

    Joined:
    Sep 28, 2011
    Posts:
    39
    that actually solved all the issues :) thanks
    but the model glows very brightly in some areas and in some less, is there a way to stabilize this?
    and the color sections also seems to have disappeared o_O