Here is the code of the shader as it is at the moment - without a manipulated cube map.
I noticed, that I can see the edges of the mesh, if I apply it to an game object. I can not find out, how this is coming. Maybe someone can look over it, please?
Shader "Anisotropic/Metal brushed"
{
Properties
{
_Color("Main Color", Color) = (0.6716418,0.6716418,0.6716418,1)
_MainTex("Base (RGB) Gloss (A)", 2D) = "gray" {}
_BumpMap("Normalmap", 2D) = "bump" {}
_ReflectionPower("_ReflectionPower", Range(0,1) ) = 0.5
_ReflectionBlur("_ReflectionBlur", Range(1,5) ) = 3
_Cube("Reflection Cubemap", Cube) = "gray" {}
_SpecularPower("_SpecularPower", Range(0,1) ) = 0.5
_Specular("_Specular", 2D) = "black" {}
}
SubShader
{
Tags
{
"Queue"="Geometry"
"IgnoreProjector"="False"
"RenderType"="Opaque"
}
Cull Back
ZWrite On
ZTest LEqual
ColorMask RGBA
Fog{}
CGPROGRAM
#pragma surface surf Anisotropic vertex:vert
#pragma target 3.0
float4 _Color;
sampler2D _MainTex;
sampler2D _BumpMap;
float _ReflectionPower;
float _ReflectionBlur;
samplerCUBE _Cube;
float _SpecularPower;
sampler2D _Specular;
struct AnistropicSurfaceOutput {
half3 Albedo;
half3 Normal;
half3 Emission;
half3 Gloss;
half Specular;
half Alpha;
half4 Custom;
};
inline half4 LightingAnisotropic (AnistropicSurfaceOutput s, half3 lightDir, half3 viewDir, half atten)
{
float Angle = 0.0;
float2 Alpha2 = float2( 0.1, 0.9 );
float pi4 = 12.56637061435917295; // Pi * 4
float3 L = normalize( lightDir );
float3 V = normalize( viewDir );
float3 H = normalize( L + V );
float2 H2 = normalize( float2( H.x, H.y ));
float2 rot = float2( cos( Angle ), sin( Angle ));
H2 = float2( dot( H2, float2( rot.x, -rot.y )), dot( H2, float2( rot.y, rot.x )));
float2 H3 = H2 / Alpha2;
H3 = H3 * H3;
float tanDelta = sqrt( 1.0 / H.z - H.z );
float3 diff = max (0, dot (s.Normal, lightDir));
float specular = exp( -tanDelta * tanDelta * ( H3.x + H3.y )) / ( pi4 * Alpha2.x * Alpha2.y * sqrt( L.z * V.z )) * s.Specular;
half4 c;
c.rgb = ( _LightColor0.rgb * diff * s.Albedo + specular * max(L.z, 0.0) * s.Gloss ) * (atten * 2);
c.a = s.Alpha;
return c;
}
struct Input {
float2 uv_MainTex;
float2 uv_BumpMap;
float3 simpleWorldRefl;
float2 uv_Specular;
};
void vert (inout appdata_full v, out Input o) {
float4 VertexOutputMaster0_0_NoInput = float4(0,0,0,0);
float4 VertexOutputMaster0_1_NoInput = float4(0,0,0,0);
float4 VertexOutputMaster0_2_NoInput = float4(0,0,0,0);
float4 VertexOutputMaster0_3_NoInput = float4(0,0,0,0);
o.simpleWorldRefl = -reflect( normalize(WorldSpaceViewDir(v.vertex)), normalize(mul((float3x3)_Object2World, SCALED_NORMAL)));
}
void surf (Input IN, inout AnistropicSurfaceOutput o) {
float4 Tex2D0=tex2D(_MainTex,(IN.uv_MainTex.xyxy).xy);
float4 Multiply0=_Color * Tex2D0;
float4 Tex2DNormal0=float4(UnpackNormal( tex2D(_BumpMap,(IN.uv_BumpMap.xyxy).xy)).xyz, 1.0 );
float4 TexCUBE0=texCUBEbias(_Cube,float4( IN.simpleWorldRefl.x, IN.simpleWorldRefl.y,IN.simpleWorldRefl.z, _ReflectionBlur ));
float4 Multiply1=TexCUBE0 * _ReflectionPower.xxxx;
float4 Tex2D1=tex2D(_Specular,(IN.uv_Specular.xyxy).xy);
float4 Master0_5_NoInput = float4(1,1,1,1);
float4 Master0_7_NoInput = float4(0,0,0,0);
float4 Master0_6_NoInput = float4(1,1,1,1);
o.Albedo = Multiply0;
o.Normal = Tex2DNormal0;
o.Emission = Multiply1;
o.Specular = _SpecularPower.xxxx;
o.Gloss = Tex2D1;
o.Normal = normalize(o.Normal);
o.Alpha = 1.0;
o.Custom = 0.0;
}
ENDCG
}
Fallback "Bumped Specular"
}