Help with Shader

Hello,

I found this easy 2D lighting tutorial
http://blog.josack.com/2011/07/xna-2d-dynamic-lighting.html

This is the actual Shader Code.

texture lightMask;
sampler mainSampler : register(s0);
sampler lightSampler = sampler_state{Texture = lightMask;};

struct PixelShaderInput
{
float4 TextureCoords: TEXCOORD0;
};

float4 PixelShaderFunction(PixelShaderInput input) : COLOR0
{
float2 texCoord = input.TextureCoords;

float4 mainColor = tex2D(mainSampler, texCoord);
float4 lightColor = tex2D(lightSampler, texCoord);

return mainColor * lightColor;

}

technique Technique1
{
pass Pass1
{
PixelShader = compile ps_3_0 PixelShaderFunction();
}
}

Getting a error in the MGFX tool in this line
sampler lightSampler = sampler_state{Texture = lightMask;};

Does someone know how to fix this?
I’m using openGL so changed to ps_3_0

Try:

SamplerState lightSampler
{
    Texture = (lightMask);
    Filter = POINT;
    AddressU  = Wrap;        
    AddressV  = Wrap;
};

ofc U/V and filter what ever you need… or just start with () in texture.

Works, thank you very much :slight_smile: