2
votes

I'm currently learning HLSL with XNA, I figured the best place to start after tutorials would be some simple 2D shaders. I'm attempting to implement a simple lighting shader in 2D.

I draw the scene without shadows to a rendertarget, swap my rendertarget to a shadowmap, draw my light(each individually) onto the shadowmap via alpha channel, swap my rendertarget back to default and render the scene then the shadows on top.

The alpha of the light changes depending on the distance of the current pixel and the point of the light, this is all working fine for me except when I render the scene, if two lights overlap it causes a nasty blending issue.

the problem

I'm using alphablend when I draw on the shadowmap, and when I draw the shadowmap to the scene. Am I just using the wrong blending settings here? I don't know much about blendstates.

Sorry if the question was vague.

1
question is clear ;) Perhaps you can post some relevant code?Caspar Kleijne

1 Answers

1
votes

I've had this happen before when doing software lighting, where your values exceed 255 (or 1.0) and you end up back in the realms of blackness. I believe the values are clamped using a modulo operation causing 1.1 to be 0.1 or 256 to be 1. I notice how the black ellipse is actually two spheres edges combined, this is what is giving me this conclusion.

Hope this gets you closer to understanding and finding out your problem. I have no idea what code you are using already but in your HLSL technique pass you could try adding:

AlphaBlendEnable = true;  
SrcBlend = One;
DestBlend = One;