   Antialiase or blur?
  Hi! I have simple shader, whitch draws outline using some dirty trick I found on the internet. But, as you can see from the image, outline is very messy. How can I antialiase or blur somehow to appear thick and clean? Do I have to do it on pixel shader or vertex shader?Shader source here: //////////////////////////////////////////////////////////////////////ANIMATION LIBRARY DEFINITION///////////////////////////////////////////////////////////////////////////////////    float4x4 MatrixPalette[56];//////////////////////////////////////////////////////////////////////WORLDS DEFINITION///////////////////////////////////////////////////////////////////////////////////    float4x4 World;//////////////////////////////////////////////////////////////////////Engine Shared Values///////////////////////////////////////////////////////////////////////////////////shared float4x4 View : VIEW;shared float4x4 Projection : PROJECTION;//////////////////////////////////////////////////////////////////////Texture///////////////////////////////////////////////////////////////////////////////////    texture BasicTexture;    // Stores sampler state info for the texture    sampler TextureSampler = sampler_state    {  Texture = (BasicTexture);    AddressU  = WRAP;    AddressV  = WRAP;    MIPFILTER = LINEAR;    MINFILTER = LINEAR;    MAGFILTER = LINEAR;    };//////////////////////////////////////////////////////////////////////Structs////////////////////////////////////////////////////////////////////////////////////////////////////////////////Output for the outline vertex shaderstruct VS_OUTPUT2{float4 Position: POSITION0;float4 Normal: TEXCOORD1;};// This is passed into our vertex shader from Xna    struct VS_INPUT    {   // This is the position of the vertex in the model filefloat4 position : POSITION;   // The vertex normalfloat3 normal : NORMAL;// This is the texture coordinate for the vertex in the model filefloat2 texcoord : TEXCOORD0;  float3 tangent    : TANGENT;// These are the indices (4 of them) that index the bones that affect// this vertex.  The indices refer to the MatrixPalette.half4 indices : BLENDINDICES0;// These are the weights (4 of them) that determine how much each bone// affects this vertex.float4 weights : BLENDWEIGHT0;    };// This is passed out from our vertex shader once we have processed the input    struct VS_OUTPUT    {   // The final position of the vertex in world spacefloat4 position : POSITION;// The texture coordinate associated with the vertexfloat2 texcoord : TEXCOORD0;   float4 color : COLOR;    };  // This is the output from our skinning method    struct SKIN_OUTPUT    {   float4 position;   float4 normal;   float4 tangent;    };//////////////////////////////////////////////////////////////////////XNA Skin Shader////////////////////////////////////////////////////////////////////////////////////////////////////////// // This method takes in a vertex and applies the bone transforms to it.    SKIN_OUTPUT Skin4( const VS_INPUT input)    {   SKIN_OUTPUT output = (SKIN_OUTPUT)0;   // Since the weights need to add up to one, store 1.0 - (sum of the weights)   float lastWeight = 1.0;   float weight = 0;   // Apply the transforms for the first 3 weights   for (int i = 0; i < 3; ++i)   {  weight = input.weights;  lastWeight -= weight;  output.position+= mul( input.position, MatrixPalette[input.indices]) * weight;  output.normal  += mul( input.normal, MatrixPalette[input.indices]) * weight;  output.tangent  += mul( input.tangent , MatrixPalette[input.indices]) * weight;   }   // Apply the transform for the last weight   output.position+= mul( input.position, MatrixPalette[input.indices[3]])*lastWeight;   output.normal  += mul( input.normal, MatrixPalette[input.indices[3]])*lastWeight;   output.tangent  += mul( input.tangent, MatrixPalette[input.indices[3]])*lastWeight;   return output;    };//////////////////////////////////////////////////////////////////////Pixel Shader////////////////////////////////////////////////////////////////////////////////////////////////////////////This is the ouline pixel shader. It just outputs unlit black.float4 Black(float2 Tex : TEXCOORD0) : COLOR{return float4(0.0f, 0.0f, 0.0f, 1.0f);}//////////////////////////////////////////////////////////////////////Vertex Shader////////////////////////////////////////////////////////////////////////////////////////////////////////////"peaks" the surface (scales it out on it's normal) VS_OUTPUT2 Outline(VS_INPUT Input){//Here's the important value. It determins the thickness of the outline.//The value is completely dependent on the size of the model.//My model is very tiny so my outine is very tiny.//You may need to increase this or better yet, caluclat it based on the distance//between your camera and your model.float offset = 0.15;float4x4 WorldViewProjection = mul(mul(World, View), Projection);SKIN_OUTPUT skin = Skin4(Input);VS_OUTPUT2 Output;Output.Normal= mul(skin.normal, World);Output.Position= mul(skin.position, WorldViewProjection)+(mul(offset, mul(skin.normal, WorldViewProjection)));return Output;}//////////////////////////////////////////////////////////////////////Techniques//////////////////////////////////////////////////////////////////////////////////////////////////////////  void TransformVertex2 (in VS_INPUT input, out VS_OUTPUT output)    {   // Calculate the skinned position   SKIN_OUTPUT skin = Skin4(input);   // This is the final position of the vertex, and where it will be drawn on the screen   float4x4 WorldViewProjection = mul(World,mul(View,Projection));   output.position = mul(skin.position, WorldViewProjection);   // This is not used by is included to demonstrate how to get the normal in world space   float4 transformedNormal = mul(skin.normal, WorldViewProjection);   output.texcoord = input.texcoord;   output.color = 1;    }// Pixel Shaderfloat4 ps_default2(VS_OUTPUT input) : COLOR{float4 Color = tex2D(TextureSampler, input.texcoord);return Color;}   technique TransformTechnique    {    pass P0    {VertexShader = compile vs_1_1 TransformVertex2 ();PixelShader  = compile ps_1_1 ps_default2();  }//Render the outline surface inverted to create fake edge detectionpass P1{VertexShader = compile vs_3_0 Outline();PixelShader  = compile ps_3_0 Black();CullMode = CW;}    }
  gd.net allows the <img> tag:<img src="image-url">;  A different way to create outlines that I saw one program  use was to create a slightly larger* mesh and reverse the direction of the triangles. Give that mesh the desired outline color with no lighting or texture and draw it at the same spot as the actual mesh. This one will, since the triangles are facing the other direction, have the front culled and the back remaining.Clever little trick which might work for you. Is automatically anti-aliased if you have that enabled.*Note that this isn't simply scaling it larger. You'd have to "grow" out the mesh in the direction of the normal. I have no experience with this, but I bet your standard 3D modeling software could do this in a jiffy.   