problem creating lights effectt. split screen and rotate

i had problem creating lights effectts, i follow some tutorial and i got one. ok this that i have.

NewSpriteEffectt,fx:

sampler s0;
texture lightMask;
sampler lightSampler= sampler_state { Texture = ;};

Texture2D SpriteTexture;

sampler2D SpriteTextureSampler = sampler_state
{
Texture = ;
};

struct VertexShaderOutput
{
float4 Position : SV_POSITION;
float4 Color : COLOR0;
float2 TextureCoordinates : TEXCOORD0;

};

float4 MainPS(VertexShaderOutput input) : COLOR
{
return tex2D(SpriteTextureSampler,input.TextureCoordinates) * input.Color;
}
float4 MyPixelShader(float2 coords: TEXTCOORD0):COLOR0
{
float4 color = tex2D(s0,coords);
float4 lightColor = tex2D(lightSampler,coords);
return color*lightColor;
//return float4(1,0,0,.5f);

}
technique Technique1
{
pass Pass1
{
PixelShader = compile ps_4_0_level_9_1 MyPixelShader();
//PixelShader = compile ps_2_0 MyPixelShader();
}
};

Game.cs:

namespace Effects01
{

public class Game1 : Game
{
    GraphicsDeviceManager graphics;
    SpriteBatch spriteBatch;
    Texture2D Emblema,lightMask;
    Effect effect;
    RenderTarget2D lightsTarget;
    RenderTarget2D mainTarget;

    Vector2 position;
    public Game1()
    {
        graphics = new GraphicsDeviceManager(this);
        Content.RootDirectory = "Content";
    }

    protected override void Initialize()
    {


        base.Initialize();
    }

    protected override void LoadContent()
    {
        // Create a new SpriteBatch, which can be used to draw textures.
        spriteBatch = new SpriteBatch(GraphicsDevice);
        Emblema = Content.Load<Texture2D>("emblem");
        lightMask = Content.Load<Texture2D>("lightmask");
        effect = Content.Load<Effect>("NewSpriteEffect");

        var pp = GraphicsDevice.PresentationParameters;
        lightsTarget = new RenderTarget2D(GraphicsDevice,pp.BackBufferWidth/4,pp.BackBufferHeight/4);
        mainTarget = new RenderTarget2D(GraphicsDevice, pp.BackBufferWidth, pp.BackBufferHeight);

        position = new Vector2(32,32);
       
    }

 
    protected override void UnloadContent()
    {
       
    }


    protected override void Update(GameTime gameTime)
    {
        if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || 
        Keyboard.GetState().IsKeyDown(Keys.Escape))
            Exit();

        // TODO: Add your update logic here
        if (Keyboard.GetState().IsKeyDown(Keys.Right)) { position.X += 4; }
        if (Keyboard.GetState().IsKeyDown(Keys.Left)) { position.X -= 4; }
        if (Keyboard.GetState().IsKeyDown(Keys.Up)) { position.Y -= 4; }
        if (Keyboard.GetState().IsKeyDown(Keys.Down)) { position.Y += 4; }


        base.Update(gameTime);
    }

    protected override void Draw(GameTime gameTime)
    {
        GraphicsDevice.SetRenderTarget(lightsTarget);
        GraphicsDevice.Clear(Color.Black);
        spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive);
        //effect.CurrentTechnique.Passes[0].Apply();
        spriteBatch.Draw(lightMask,position,Color.White);
        spriteBatch.End();

        

        GraphicsDevice.SetRenderTarget(mainTarget);
        GraphicsDevice.Clear(Color.CornflowerBlue);

        
        spriteBatch.Begin();
        spriteBatch.Draw(Emblema, new Vector2(400 - Emblema.Width / 2, 240 - Emblema.Height / 2), Color.White);
        spriteBatch.End();

        GraphicsDevice.SetRenderTarget(null);
        GraphicsDevice.Clear(Color.CornflowerBlue);
        spriteBatch.Begin(SpriteSortMode.Immediate,BlendState.AlphaBlend);
        effect.Parameters["lightMask"].SetValue(lightsTarget);
        effect.CurrentTechnique.Passes[0].Apply();
        spriteBatch.Draw(mainTarget,Vector2.Zero,Color.White);
        spriteBatch.End();




        base.Draw(gameTime);
    }
}

}

the program divide the screen in 4 parts what is wron and there is somethin like mirror effectt. if i wan to go up the light go to down… and the sprites like emblema is rotate 180 degree…
thank for your help…

What are you trying to achieve ? What’s the purpose of the 4 screens ?

well i only want to a simple light to move around the world, but instead i got 4 screen and mirrored sprites.

in the post there is a mistake with Texture = ;
sampler s0;
texture lightMask;
sampler lightSampler= sampler_state { Texture = ;};

Texture2D SpriteTexture;

sampler2D SpriteTextureSampler = sampler_state
{
Texture = ;
};

struct VertexShaderOutput
{
float4 Position : SV_POSITION;
float4 Color : COLOR0;
float2 TextureCoordinates : TEXCOORD0;

};

float4 MainPS(VertexShaderOutput input) : COLOR
{
return tex2D(SpriteTextureSampler,input.TextureCoordinates) * input.Color;
}
float4 MyPixelShader(float2 coords: TEXTCOORD0):COLOR0
{
float4 color = tex2D(s0,coords);
float4 lightColor = tex2D(lightSampler,coords);
return color*lightColor;
//return float4(1,0,0,.5f);

}
technique Technique1
{
pass Pass1
{
PixelShader = compile ps_4_0_level_9_1 MyPixelShader();
//PixelShader = compile ps_2_0 MyPixelShader();
}
};

You can nicely format the code and get syntax highlighting by wrapping it in triple backticks. That will fix the brackets too

Have you tried adding addressU addressV in the samplerstates’ declarations and their value as CLAMP?
This should avoid the texture repeat to begin with

thank to all, i have solve my problem. in a next post i will show the complete program to help another people.

Glad you solved it. :slight_smile:
What was the problem then?