I've been thinking about how to add Additive blending to this, and after some reading up around the internets it seems this is not possible.

I've read the java doc's for AlphaComposite, and I'm thinking that it would be possible with some maths and bashing my head against the keyboard to create a new AdditiveComposite class that can be used in much the same way for blending additively with Graphics2D.

On top of this, it would be possible to create any type of blending required (I'm thinking Photoshop - such as Overlay and Liniar Burn, etc.

I wanted to have a discussion on this topic, to see if this has been done before, found to be impossible or if theres a better way to go about this.

A caveat would be that any blending would have to be used in a Update/Render game loop, and therefor be as fast as possible.

So, any thoughts?

EDIT: Ohh yeh, my current project is to create a game engine from scratch, mainly as a learning experience, and also becasue I would like to have an end-product that I fully understand the inner workings of. I'd rather go the long way with this rather than 'Go use XYZ Library, as it will do everything you need.'

The graphics code seems pretty smart about providing the compose() function with only the area of interest, so i think if you use it for limited small effects, it might run OK.

I noticed that my compose() function was being given 64x64 tiles, rather than all the image at once. There's mention in the API of multithreading, but the result doesn't appear to use it.

Digging down into the java source code, i found their alphacomposite creates BufferedImages from the rasters, then calls a native function called Blit. I didn't look deeper than a quick glance at that file, didn't really understand it. There seems to be a ton of boilerplate in Java.

I've used a similar process in C# for applying things like edge-finding to CCTV images, but found it to be very slow. Then again, that was quite a heavy calculation per pixel, rather than just adding color values.

I'm not sure now the Composite/CompositeContext works - does it run in software, or instruct the graphics hardware to use that calculation? If this is handled at a pixel level in java, it would be very slow to execute in low-end systems right?

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org