Hello.
I was trying to make a lightning system. I have a RenderTarget2D that starts at black where the lights are drawn with additive BlendState. It then multiplies the normal render colors., and for the moment works. The problem is that im not able to get the values to pass over 1 (for light to have a greater intensity).
When I draw the lights map over the game render with the following blend state (to multiply the rgb and keep the alpha that is always 1 on the light map)
public readonly static BlendState LightBufferDrawBlendState = new(){
ColorDestinationBlend = Blend.SourceColor,
ColorSourceBlend = Blend.Zero,
ColorBlendFunction = BlendFunction.Add,
AlphaDestinationBlend = Blend.SourceAlpha,
AlphaSourceBlend = Blend.Zero,
AlphaBlendFunction = BlendFunction.Add
};
The image result is not the one I expected.
For drawing the lights in the LightBuffer, I apply a brighten effect as the effect parameter I use for beggining the SpriteBatch, where the Bright is the Light color / intensity.:
float4 MainPS(VertexShaderOutput input) : COLOR
{
float4 baseColor = tex2D(SpriteTextureSampler,input.TextureCoordinates) * input.Color;
return float4(baseColor.x*Bright.x, baseColor.y*Bright.y, baseColor.z*Bright.z, baseColor.w);
}
Note that the RenderTarget is instantiated with SurfaceFormat of HalfVector4 so that it can allow numbers over 1.
I don’t really have a lot of experience with MonoGame shading/effects/advanced drawing so im a bit lost.
Thank you.