Proposed Approach for Blend Modes in Photoshop in XNA

I am working on a 2D project in C # using XNA, where I need to display a number of sprite seraphs on Texture2D - I switch the display states and use the sprite command and get the results mainly thanks to other stackoverflow messages. What I could not find is how to combine using something other than Alpha or Multiply.

The result I'm looking for will be equivalent to the Lighten blending mode in Photoshop - between the contents of the texture and the sprite I'm painting, I just want the pixels to be lighter than the texture drawn by the texture. My naive approach would be to loop pixel data in the source and destination. Is there a good solution?

+1
source share
1 answer

If you are using XNA 4.0, you can pass the object BlendStateto SpriteBatch.Begin.

You want to install BlendState.ColorBlendFunctionin BlendFunction.Max. The documentation lists the actual mixing features.

To achieve the effect, I think, you might also want to set ColorSourceBlendand ColorDestinationBlendequal Blend.One.

You can do the same in earlier versions of XNA, but you must use SpriteBatch with SpriteSortMode.Immediateand change the corresponding members GraphicsDevice.RenderStateafter calling Begin and before calling Draw for the first time.

Read this blog post for more details.

+2
source

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


All Articles