본문 바로가기
Shader

Shader Test

by 대마왕J 2016. 3. 26.

 

정리 하나도 안한거임

 

 

 

 

 

Shader "Myproject/simple" {
    properties
 {
  _Diff("Diffuse color", Color) = (1,1,1)
  _MainTex("tex",2D) = "white"{} 
  _NormalTex("Normal",2D)= "bump"{}
  _RimColor("RimColor", Color) = (1,1,1)
  _ScanColor("ScanColor", Color) = (1,1,1)
  _CameraSpec("specColor", Color) = (1,1,1)
  _Toon("Toon",int) = 1
 } 
 
 SubShader
 {
      Tags { "RenderType" = "Opaque" }
      CGPROGRAM
      #pragma surface surf MyLambert
     
   sampler2D _MainTex;
   sampler2D _NormalTex;
   float3 _Diff;
   float3 _RimColor;
   float3 _CameraSpec;
   float3 _ScanColor;
   float _Toon;
   struct Input
   {
          //float4 color : COLOR;
    float2 uv_MainTex;
    float2 uv_NormalTex;
    float3 viewDir;
    float3 worldPos;
      };
      void surf (Input IN, inout SurfaceOutput o)
   {
  float4 c = tex2D(_MainTex, IN.uv_MainTex);
          o.Albedo = c.rgb*_Diff ;
    o.Normal = UnpackNormal(tex2D(_NormalTex,IN.uv_NormalTex) );
    o.Normal.x *= 2;
    o.Normal.y *= 2;
    o.Alpha = 1;
    float rim = abs(dot(IN.viewDir, o.Normal));
    float invrim = 1-rim;
    o.Emission = pow(invrim,3) * c.rgb * _RimColor.rgb* (sin(_Time.y*20)*0.5+0.5);
    float3 blink = pow(1-frac(IN.worldPos.rgb.y+_Time.y),20) *_ScanColor.rgb ;
     o.Emission += blink*2 + ceil(saturate(rim-0.98)*2)/2;
      }
  
  
   half4 LightingMyLambert( SurfaceOutput s , half3 lightDir, half atten   )
   {
  float NdotL = dot(s.Normal, lightDir);
  float HalfLambert = (ceil((NdotL *0.5+0.5)*_Toon)/_Toon);
  half4 c = 0;
  c.rgb = s.Albedo * HalfLambert * _LightColor0.rgb * atten ;
  c.a = 1;
  return c;
  
   }
      ENDCG
    }
    Fallback "Diffuse"
  }

반응형

댓글