# 2D Point Light XNA , Why my point light radius is Oval?

I friend of mine , taught me how to make a simple 2d point light with shader, so i follow his steps and finally done it !

but something happend , the light shape is like an oval and not like a circle , my friends couldnt explain me why,

could you help me how to fix it, and explain me why it happend?

here is how it looks like http://dl.dropbox.com/u/2553973/screengrab/PointLight_07.png

Texture InputTexture;

sampler InputTextureSampler = sampler_state {
texture = <InputTexture>;
magfilter = LINEAR;
minfilter = LINEAR;
mipfilter = LINEAR;
};

{
float4 Position  : POSITION0;
float2 TexCoord  : TEXCOORD0;
float4 Color     : COLOR0;
};

float4      ambientColor = float4(1.0,1.0,1.0,0.0);
float       ambientIntensity = 0.3f;

{
//float4 color = float4(1, 0, 0, 1);
float4 texCol = tex2D(InputTextureSampler, input.TexCoord);

float4 color = ambientIntensity*ambientColor;
float dist;

//Light 1
float  lightIntensity = 15.0f;
float4 lightPos = float4(0.3f,0.3f,0.0f,0);
float4 lightColor =  float4(0, 0, 1, 1);

dist = distance(lightPos, input.TexCoord);

texCol = saturate(color) *texCol;

return texCol;
}

technique PointLight
{
pass Pass1
{
}
}


XNA CODE

    GraphicsDevice.SetRenderTarget(normalRender);
GraphicsDevice.Clear(Color.Black);
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, null, effectLight);
spriteBatch.Draw(background, Vector2.Zero, Color.White);
spriteBatch.End();

normalRenderTexture = normalRender;

GraphicsDevice.SetRenderTarget(null);
GraphicsDevice.Clear(Color.Black);
spriteBatch.Begin();
spriteBatch.Draw(normalRenderTexture, Vector2.Zero, Color.White);
spriteBatch.End();

• @LuisEstrada dl.dropbox.com/u/2553973/PointLightXNA.zip , here is the project, the light is coded inside the Shader, is just a sample project :D, btw XNA 4.0 – Joyal Feb 26 '12 at 0:21
• for a quick fix please change the size of your image to be a square. I will explain why soon. – Luis Estrada Feb 26 '12 at 0:50
• @LuisEstrada it tottaly worked, i imagine why, because the aspect ratio of the texcoords of the image isnt square, but, is there any solution to keep using non square images? – Joyal Feb 26 '12 at 1:21
• I modified your code a bit to get a simple solution. See attached: dl.dropbox.com/u/29838828/PointLightXNA.zip – Luis Estrada Feb 27 '12 at 4:38