I've ported the anisotropic lighting shader from the wiki to a surface shader - works fine. Wanted to create a bumped version, but I get a lot of artifacts on the surface, anyone know why? Code (csharp): Shader "Metervara/Anisotropic Bump" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _MainTex ("Base (RGB)", 2D) = "white" {} _AnisoTex ("Aniso lookup (RGBA)", 2D) = "white" {} _BumpMap ("Normalmap", 2D) = "bump" {} } SubShader { Tags { "RenderType" = "Opaque" } CGPROGRAM #pragma surface surf Anisotropic sampler2D _AnisoTex; half4 LightingAnisotropic (SurfaceOutput s, half3 lightDir, half3 viewDir, half atten) { half3 halfAngle = normalize(viewDir + lightDir); float2 uvA; uvA.x = dot(lightDir,s.Normal); uvA.y = dot(halfAngle,s.Normal); half4 aniso = tex2D( _AnisoTex, uvA ); half4 c; c.rgb = s.Albedo * _LightColor0.rgb * aniso.rgb * (aniso.a * atten * 2); c.a = s.Alpha; return c; } struct Input { float2 uv_MainTex; float2 uv_BumpMap; }; sampler2D _MainTex; sampler2D _BumpMap; fixed4 _Color; void surf (Input IN, inout SurfaceOutput o) { o.Albedo = tex2D (_MainTex, IN.uv_MainTex).rgb * _Color; o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap)); } ENDCG } Fallback "Diffuse" }
I've encountered those little squares with image-based lighting, too. I don't know what causes it (other than the texture lookup), and would definitely like to know how to get rid of it.
I originally suspected that that was the problem, but I thought I tried disabling mipmaps and it did not fix the issue. I will check again.
I just checked and that fixes the problem for the matcap shader as well. I must have been misremembering. What I would like to know now is whether there is a way to tell the graphics card to use mipmaps but not be insane about it. I assume it's similar to this problem: http://aras-p.info/blog/2010/01/07/screenspace-vs-mip-mapping/