# Working on first shader, but getting weird effects

I’m really close now. I had to do some additional math, but here’s the current state of things.

As you can see, the corners are still a bit bright, and the borders are a bit dimmer than I want. I found that after figuring out what the alpha value should be, I still had to multiply the color by the alpha to get the desired effect as shown above. But it’s still not perfect… I will keep experimenting

Here’s the current state of the shader:

``````#if OPENGL
#define SV_POSITION POSITION
#else
#endif

int style;
float4 coordPoint;
Texture2D SpriteTexture;

sampler2D SpriteTextureSampler = sampler_state
{
Texture = <SpriteTexture>;
};

{
float4 Position : SV_POSITION;
float4 Color : COLOR0;
float2 TextureCoordinates : TEXCOORD0;
};

{
float4 color = tex2D(SpriteTextureSampler, input.TextureCoordinates) * input.Color;
float2 coords = (input.TextureCoordinates - coordPoint.xy) / (coordPoint.zw - coordPoint.xy);

if (style == 0)
{
if (coords.x < coords.y) color.a = coords.x;
else color.a = coords.y;
}
else if (style == 1) color.a = coords.y;
else if (style == 2)
{
if (coords.y < 1 - coords.x) color.a = coords.y;
else color.a = 1 - coords.x;
}
else if (style == 3) color.a = coords.x;
else if (style == 5) color.a = 1 - coords.x;
else if (style == 6)
{
if (coords.x < 1 - coords.y) color.a = coords.x;
else color.a = 1 - coords.y;
}
else if (style == 7) color.a = 1 - coords.y;
else if (style == 8)
{
if (1 - coords.x < 1 - coords.y) color.a = 1 - coords.x;
else color.a = 1 - coords.y;
}

color *= color.a;

return color;
}

technique Technique1
{
pass Pass1
{