Weird Halo With Simple Subtractive 2D Lights

Hi, maybe it’s just me, but does the lighting look a little funny?

It looks fine when there’s just one light source, but when light sources come together I’m seeing some sort of halo and when moving around the lights look kind of blobby.

I guess it looks kinda cool, but I feel like a chump not understanding at least why it’s happening.

414

I’m just using the subtract light strategy. I have another post detailing this more here:

Thanks!

Even the single light image looks off to me, compared to the light image you posted in the other thread. I wonder if its because the colours are inverted. Your light image is black, but it reverses to white, so a nice soft light in black will turn into a harsh white in black?

I flipped it in Paint.Net myself and it actually doesn’t look like that at all. Your image looks like a fairly even gradient, but in the above image you posted it looks heavily biased towards the center, then falls off sharply on the outsides.

I feel like I’ve seen this before but I can’t quite put my finger on it. Like I said in the other thread, I’m not super familiar with blend states. What does this look like if you render your inverted light over a black background. Does it come out as expected?

That halo is an illusion. This happens when you reach maximum intensity (limited by surface format / backbuffer). You are creating sort of 2D metaball. Either map Attenuation function, something like Hermit interpolation should help to mitigate that transition. Or make sure you don’t get clamped value so easily.

All I’m doing is I’m is laying a bunch of black gradient circles on a white background and subtracting that from the main drawing. I’m not sure what a “map Attenuation function” or a “Hermit interpolation” is. Is that like a shader thing?

I’m not sure what you’re asking, you’re asking if the main draw was black what would it look like? The whole screen would be black in that case.

I’m really just trying to recreate this “subtract” behavior that can be seen in Aseprite. I can jam as many circle gradients in Aseprite and it doesn’t do this weird stuff as seen in the game.

Am I correct in thinking that this code is supposed to behave the same way?

public readonly static BlendState blendStateSubtract = new BlendState
    {
        ColorSourceBlend = Blend.One,
        AlphaSourceBlend = Blend.One,

        ColorDestinationBlend = Blend.One,
        AlphaDestinationBlend = Blend.One,

        ColorBlendFunction = BlendFunction.ReverseSubtract,
        AlphaBlendFunction = BlendFunction.ReverseSubtract
    };