Orihaus

AEON Base Texture (June 2013)

Jun 9th, 2013
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 4.44 KB | None | 0 0
  1. Shader "AEON_Base_Texture"
  2. {
  3.     Properties  
  4.     {
  5.         _DiffuseAmount ( "Diffuse Amount", Range( 0.0, 0.25 ) ) = 0.25
  6.         _TexAmount ( "Texture Amount", Range( 0.0, 1.0 ) ) = 0.25
  7.         _SpecAmount ( "Specular Amount", Range( 0.0, 48.0 ) ) = 1.0
  8.         _SpecTexAmount ( "Spec Texture Amount", Range( 0.0, 1.0 ) ) = 0.25
  9.         _MainMap ( "Main Texture", 2D ) = "main" {}
  10.         _Normalmap ( "Normalmap", 2D ) = "normal" {}
  11.         _Specmap ( "Specmap", 2D ) = "spec" {}
  12.        
  13.         _FresnelPower ( "Fresnel Power", Range( 0.0, 16.0 ) ) = 8.0
  14.         _FresnelPrimarySecondary ( "Primary/Secondary Fresnel Degree", Range( 0.0, 1.0 ) ) = 1.0
  15.         _FresnelTertiary ( "Fresnel Tertiary Infusion", Range( 0.0, 0.25 ) ) = 0.25
  16.         _FresnelBoost ( "Fresnel Boost", Range( 1.0, 2.0 ) ) = 0.0
  17.         _FresnelBalance ( "Fresnel Balance", Range( 0.0, 0.25 ) ) = 0.25
  18.         _FresnelEmitColor ( "Fresnel Emit Color", Color ) = ( 0.89, 0.945, 1.0, 0.0 )
  19.        
  20.         _PrimarySecondary ( "Primary/Secondary Degree", Range( 0.0, 1.0 ) ) = 1.0
  21.         _Tertiary ( "Tertiary Infusion", Range( 0.0, 0.25 ) ) = 0.25
  22.         _Gloss ( "Gloss", Range( 0.0, 2.0 ) ) = 1.0
  23.     }
  24.        
  25.     SubShader
  26.     {
  27.         Tags
  28.         {
  29.           "Queue"="Geometry+0"
  30.           "IgnoreProjector"="False"
  31.           "RenderType"="Opaque"
  32.         }
  33.  
  34.         Cull Back
  35.         ZWrite On
  36.         ZTest LEqual
  37.  
  38.         CGPROGRAM
  39.         #pragma target 3.0
  40.         #pragma surface surf SimpleSpecular novertexlights fullforwardshadows
  41.         //fullforwardshadows approxview dualforward
  42.        
  43.         float _Gloss;
  44.         float _PrimarySecondary;
  45.         fixed _Tertiary;
  46.        
  47.         fixed CalculateSpecular( fixed3 lDir, fixed3 vDir, fixed3 norm, float gloss )
  48.         {    
  49.             float3 halfVector = normalize( lDir + vDir );
  50.             float specDot = saturate( dot( halfVector, norm ) );
  51.            
  52.             float primaryBlob = pow( specDot, _Gloss * 128.0 );
  53.             float secondaryBlob = pow( specDot, _Gloss * 16.0 );
  54.             float tertiaryBlob = pow( specDot, _Gloss * 8.0 );
  55.             float tripleSpec = lerp( primaryBlob, secondaryBlob, _PrimarySecondary ) + tertiaryBlob * _Tertiary;
  56.  
  57.             return tripleSpec * gloss;
  58.         }
  59.        
  60.         fixed4 LightingSimpleSpecular( SurfaceOutput s, fixed3 lightDir, fixed3 viewDir, fixed atten )
  61.         {
  62.             fixed diff = saturate( dot( s.Normal, lightDir ) );
  63.             fixed spec = CalculateSpecular( lightDir, viewDir, s.Normal, s.Gloss ) * s.Specular;
  64.            
  65.             fixed4 c;
  66.             c.rgb = ( s.Albedo * _LightColor0.rgb * diff + _LightColor0.rgb * spec ) * atten;
  67.             c.a = s.Alpha;
  68.            
  69.             return c;
  70.         }
  71.        
  72.         fixed4 LightingSimpleSpecular_DirLightmap( SurfaceOutput s, fixed4 color, fixed4 scale, fixed3 viewDir, bool surfFuncWritesNormal, out fixed3 specColor )
  73.         {
  74.             UNITY_DIRBASIS
  75.             half3 scalePerBasisVector;
  76.            
  77.             half3 lm = DirLightmapDiffuse( unity_DirBasis, color, scale, s.Normal, surfFuncWritesNormal, scalePerBasisVector );
  78.             half3 lightDir = normalize( scalePerBasisVector.x * unity_DirBasis[0] + scalePerBasisVector.y * unity_DirBasis[1] + scalePerBasisVector.z * unity_DirBasis[2 ]);
  79.            
  80.             specColor = lm * CalculateSpecular( lightDir, viewDir, s.Normal, s.Gloss ) * s.Specular;
  81.            
  82.             return half4( lm * 0.5, 1.0 );
  83.         }
  84.        
  85.         struct Input
  86.         {
  87.             float2 uv_MainMap;
  88.             float2 uv_Normalmap;
  89.             float2 uv_Specmap;
  90.             float3 viewDir;
  91.         };
  92.    
  93.         sampler2D _MainMap;
  94.         sampler2D _Normalmap;
  95.         sampler2D _Specmap;
  96.  
  97.         fixed _SpecAmount;
  98.         fixed _SpecTexAmount;
  99.         fixed _TexAmount;
  100.         fixed _DiffuseAmount;
  101.        
  102.         float _FresnelPower;
  103.         float _FresnelPrimarySecondary;
  104.         float _FresnelTertiary;
  105.         float _FresnelBoost;
  106.        
  107.         float4 _FresnelEmitColor;
  108.         float _FresnelBalance;
  109.  
  110.         void surf( Input IN, inout SurfaceOutput o )
  111.         {
  112.             o.Normal = UnpackNormal( tex2D( _Normalmap, IN.uv_Normalmap ) );
  113.        
  114.             float fresnelDot = 1.0 - saturate( dot( normalize( IN.viewDir ), o.Normal ) );
  115.             float fresnelPrimaryBlob = pow( fresnelDot, _FresnelPower * 2.0 );
  116.             float fresnelSecondaryBlob = pow( fresnelDot, _FresnelPower );
  117.             float fresnelTertiaryBlob = pow( fresnelDot, _FresnelPower * 0.5 );
  118.             float fresnel = lerp( fresnelPrimaryBlob, fresnelSecondaryBlob, _FresnelPrimarySecondary ) + fresnelTertiaryBlob * _FresnelTertiary;
  119.             fresnel *= _FresnelBoost;
  120.        
  121.             float tex = lerp( tex2D( _MainMap, IN.uv_MainMap ).r, 1.0, _TexAmount );
  122.             o.Albedo = _DiffuseAmount * tex;
  123.             o.Emission = fresnel * _FresnelEmitColor;
  124.             o.Specular = lerp( tex2D( _Specmap, IN.uv_Specmap ).r, 1.0, _SpecTexAmount ) * _SpecAmount;
  125.             o.Gloss = lerp( fresnel, 1.0, _FresnelBalance );
  126.         }
  127.    
  128.         ENDCG
  129.     }
  130.        
  131.     Fallback "Diffuse"
  132. }
Advertisement
Add Comment
Please, Sign In to add comment