Search Unity

Unity 5 custom PBS

Discussion in 'Shaders' started by Phantomx, Dec 12, 2014.

  1. Phantomx

    Phantomx

    Joined:
    Oct 30, 2012
    Posts:
    202
    Hey,
    Anyone tried to make a custom PBS in unity5 ? so far I got the GI and specular working fine, but I still miss how to get the reflection. My feeling is that I need to put something in the emission channel but I can't find what.

    Here's what I got so far:

    Code (CSharp):
    1. Shader "CustomPBS" {
    2.     Properties {
    3.         _MainTex ("Base (RGB)", 2D) = "white" {}
    4.         _Bump ("Normal Map",2D) = "bump" {}
    5.         _Shininess("Shininess",Range(0.0,1)) = 0.5
    6.         _SpecTex ("Specular",2D) = "white" {}
    7.     }
    8.     SubShader {
    9.         Tags { "RenderType"="Opaque" }
    10.         LOD 200
    11.        
    12.         CGPROGRAM
    13.         #pragma surface surf Standard
    14.         #include "UnityPBSLighting.cginc"
    15.        
    16.         sampler2D _MainTex;
    17.         sampler2D _Bump;
    18.         sampler2D _SpecTex;
    19.         float _Shininess;
    20.  
    21.         struct Input {
    22.             float2 uv_MainTex;
    23.         };
    24.      
    25.         void surf (Input IN, inout SurfaceOutputStandard o) {
    26.  
    27.             fixed4 tex  = tex2D (_MainTex, IN.uv_MainTex);
    28.             fixed3 bump = UnpackNormal(tex2D(_Bump,IN.uv_MainTex));
    29.             fixed4 spec = tex2D (_SpecTex, IN.uv_MainTex);
    30.            
    31.            
    32.             o.Albedo = tex.rgb;
    33.             o.Specular = spec.rgb;
    34.             o.Smoothness = spec.a * _Shininess;
    35.             o.Normal = bump;
    36.             //o.Emission =????????;
    37.             o.Alpha = tex.a;
    38.         }
    39.         ENDCG
    40.     }
    41.     FallBack "Diffuse"
    42. }
    43.  
    Also I try to override UnityPBSLighting.cginc with my own, but putting it in a resources folder doesn't seem to do the trick.

    So who tried to play with that yet?
     
  2. steego

    steego

    Joined:
    Jul 15, 2010
    Posts:
    969
    Take a look at this thread, I think that's what you're missing.
     
  3. Phantomx

    Phantomx

    Joined:
    Oct 30, 2012
    Posts:
    202
    That's what I was looking for! thanks!