Customize the colors of the whole scene

I am developing a 2D game in C # / XNA where sprites / backgrounds / etc is Texture2D. I am interested in rendering a specific scene in the "day" or "night". Obviously, one option would be to have two copies of each image, one darker than the other, but this is not very scalable. Is there a way to adjust colors on the fly to make them look darker? I would suggest that it would be easier to adjust the brightness or something (or depending on which one looks better) than trying to apply some kind of uniform conversion to the RGB values, but at that time this is a smaller problem. Is there any way to say "draw this Texture2D, but set all the colors this way to this amount"?

Thank!

+3
source share
2 answers

Check for SpriteBatch.Draw overloads that accept a color parameter. He does exactly what you are looking for.

+2
source

in your account for example.

 ps_out ps( ps_in In )
 {
        PS_OUT Out = ( PS_OUT ) 0;
        float4 color;
        color = tex2D( sBase, In.Base.xy );

        Out.Color = color;
        return Out;
 }

You can use alpha blending, and then use the Swizzle operator on the color element and multiply the alpha / opacity of the color.

eg. color.a = color.a * opacity / 255.0f

+1
source

Source: https://habr.com/ru/post/1755302/


All Articles