# HLSL Shadow Mapping occurs only around player

I've recently begun playing around with Monogame (OpenSource "remake" of XNA). My current task is to write a simple shadow mapping shader. After following Riemer's XNA Tutorial I got the shadows to show up. But interestingly only around where the "player" (camera) is. When I'm outside of the light's radius there's no light showing up around the camera (which is good), but the light from my spotlight should of course still be there. But it's not. The shadows and the bright lighting from my spotlight only appear around player.

As I said, my HLSL code is exactly the same as Riemer's (Except that I wrote SV_POSITION instead of POSITION0 at the VertexShaderInput struct because MonoGame only supports Pixel-/Vertexshader 4.0 and above)

I also have a feeling that my Light-View/-Projection Matrices might somehow be wrong:

Matrix lightsView = Matrix.CreateLookAt(lightPos, new Vector3(lightPos.X, lightPos.Y-1, lightPos.Z), new Vector3(0, 0, 1));
Matrix lightsProjection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45F), 1f, 1f, 10f);


(I know that my "up" vector is not pointing upwards; that was the only way I got the light to point downwards from it's position, otherwise it would always point to (0 -1 0) even if I wrote it so that the lights coordinates were used and then it would go y -1 from the light - really weird...)

I really hope someone knows what's up here, this issue prevented me from doing anything else in my code for a couple of days now...

PS: Here's my rendering code:

    ////In my Model-Class
private void DrawModel(string tech)
{
Matrix[] transforms = new Matrix[model.Bones.Count];
model.CopyAbsoluteBoneTransformsTo(transforms);

foreach (var mesh in model.Meshes)
{
foreach (ModelMeshPart part in mesh.MeshParts)
{
part.Effect = Game1.effect;
Matrix tempWorld = ((transforms[mesh.ParentBone.Index] * Matrix.CreateScale(scale)) * rotationMatrix) * Matrix.CreateTranslation(pos);
part.Effect.CurrentTechnique = part.Effect.Techniques[tech];
part.Effect.Parameters["xWorldViewProjection"].SetValue(tempWorld * Game1.camera.View * Game1.camera.Projektion);
part.Effect.Parameters["xTexture"].SetValue(textures[part]);
part.Effect.Parameters["xWorld"].SetValue(tempWorld);
part.Effect.Parameters["xLightPos"].SetValue(Game1.currentLevel.lightPos);
part.Effect.Parameters["xLightPower"].SetValue(Game1.currentLevel.lightPower);
part.Effect.Parameters["xAmbient"].SetValue(Game1.currentLevel.ambientPower);
part.Effect.Parameters["xLightsWorldViewProjection"].SetValue(tempWorld * Game1.currentLevel.lightsViewProjectionMatrix);
}

mesh.Draw();
}
}

////In my Level-Class
public void Render()
{
var device = Game1.graphics.GraphicsDevice;

device.SetRenderTarget(renderTarget);
device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.Black, 1.0f, 0);

device.SetRenderTarget(null);

device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.Black, 1.0f, 0);
}

private void DrawScene(string tech)
{
foreach (var model in models)
{
model.Render(tech);
}
}


and the light-update code:

private void UpdateLightData()
{
ambientPower = 0.2f;

lightPos = new Vector3(-0.2F, 1.2F, 1.1F);

lightPower = 1.8f;

Matrix lightsView = Matrix.CreateLookAt(lightPos, new Vector3(lightPos.X, lightPos.Y-1, lightPos.Z), new Vector3(0, 0, 1));
Matrix lightsProjection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45F), 1f, 1f, 10f);

lightsViewProjectionMatrix = lightsView * lightsProjection;
}