Need help performing additive blending in Java2D

I am making a 2D graphics engine using Java2D and I’m in need of help. I want to perform additive blending on my particles but I can not find a way that is fast enough for real-time drawing. Any hints?

I might also be interested in using the transparent pixels stored by photoshop and then replace my black-ish pixels with those.

For those who do not know what additive blending does, it “adds” the value of a pixel to draw to the pixel it’s drawing to and thus a part of a picture will seem more transparent depending on how black it is since black==0.

Maybe try this library:

http://download.java.net/javadesktop/scenario/effects/releases/0.4.9/javadoc/com/sun/scenario/effect/Blend.Mode.html

It has additive blending, and it can be accelerated by the java2d d3d pipeline.

I’ve used it once just to test it out and it worked pretty good, but I didn’t use additive blending, i just used the bloom effect.

That does indeed look promising, but I can’t seem to find a way to download it. I’ve talked to some teachers in school but after checking they all seem pretty clueless as well. One mentioned that it is included in the J3D package, but I checked and it wasn’t in there.

I’ve obviously googled and checked the link for downloads but with no luck. So where can I get it? Thank you!

Hitting Google up for “com.sun.scenario” yielded a link that I shortened to get this one
http://download.java.net/javadesktop/scenario/releases/0.5/

I think the problem is Scenario treats blend modes like an image filter (requires an input image, returns an output image), rather than just selecting the blend mode in Graphics2D like you would SrcOver or Xor.

Something called PhotoComposite got mentioned once - anyone know if it’s going to make it into JDK 7?
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6541868

Sun java2D engineer Chris Campbell mentioned it in his blog a while back, but I haven’t seen anything since. I’ve got a feeling that the JavaFX work is taking priority for the time being:

http://weblogs.java.net/blog/campbell/archive/2007/04/faster_java_2d.html
Coming Soon: PhotoComposite
It’s not officially approved (or integrated) yet, but I’ve been working on adding more blending modes to Java 2D, in addition to those already provided by AlphaComposite. Many of these modes come from traditional photography techniques, thus the name “PhotoComposite”. Some modes are simple (Add, Multiply) and can be accelerated easily using OpenGL’s built-in blending rules, others are more involved (ColorBurn, SoftLight) and benefit greatly from the use of shaders for efficient rendering.

There was also this: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5094232

Which also says that they were going to try do “average, darken, lighten, color burn/dodge” for Java 7.

But if you want to do your own code for now there was this : http://www.java-gaming.org/index.php/topic,18379.0.html

Thank you, I managed to import the package, gonna experiment with it tomorrow :slight_smile:

Also yeah, PhotoComposite seems pretty interesting!