Pixelartifacts on edges when activating Antialiasing...


ive already sent a bug report to unity but unfortunately ive no response yet. I get artifacts when activating AA in my scene (editorview, webplayer, standalone).

Theres a mesh with a reflective/specular shader with a cubemap and i get this white pixels on pc and mac, too. (latest display driver, different machines).

Does anybody have the same problems? Any ideas on that? Would be great. Thanks a lot.

alt text

The built-in specular shader is the culprit. To remove the white artifacts, add o.Normal = fixed3(0,0,1); after o.Specular = _Shininess; in the surf function from the built-in specular shader. This line is omitted due to performance reasons apparently. (discussions here and here)

The shader code below is for plain ol’ Specular, from the “Normal-Glossy.shader” file from http://unity3d.com/support/resources/assets/built-in-shaders.html, but with the added fix:

Shader "Specular (Fixed)" {
Properties {
	_Color ("Main Color", Color) = (1,1,1,1)
	_SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1)
	_Shininess ("Shininess", Range (0.01, 1)) = 0.078125
	_MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {}

SubShader {
	Tags { "RenderType"="Opaque" }
	LOD 300
#pragma surface surf BlinnPhong

sampler2D _MainTex;
fixed4 _Color;
half _Shininess;

struct Input {
	float2 uv_MainTex;

void surf (Input IN, inout SurfaceOutput o) {
	fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
	o.Albedo = tex.rgb * _Color.rgb;
	o.Gloss = tex.a;
	o.Alpha = tex.a * _Color.a;
	o.Specular = _Shininess;
	o.Normal = fixed3(0,0,1);

Fallback "VertexLit"

As for the Reflective/Specular shader, adding o.Normal = fixed3(0,0,1); gives a compiler error.

It’s also been suggested to use Bumped Specular (maybe with Reflective too?) with a flat normalmap to fix the white artifacts.

I can’t reproduce this. Maybe it has been resolved… Even though I couldn’t find any mention about this on the release notes since 2.6, except for a brief worrying on 3.2.

Or, most likely, it’s an artifact from your specific scene set up, generated because our current algorithms just can’t handle everything, specially under OpenGL ES 2.0, like Mr Statement grasped on the comments.

For imported Models, i was able to minnimize artifacts by tweaking the smoothing angle in the importsettings.

Take a look at this post http://forum.unity3d.com/threads/83260-Unity-3.3-MSAA-and-particles...