JDK-8090548 : 3D: Support blending when diffuse component has alpha (transparency)
  • Type: Enhancement
  • Component: javafx
  • Sub-Component: graphics
  • Affected Version: 8
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2013-03-08
  • Updated: 2019-02-14
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Blocks :  
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
Check out the attached image. Although this is a bug (RT-28025) having half-transparent materials is very desirable and as we can see achievable. 

Unfortunately, currently there is no way to set half-transparent material. Alpha value is ignored in diffuseColor. 

So I propose to render transparently meshes with materials whose diffuseColor or diffuseMap are not opaque.
Comments
The fix to RT-40600 should work for some use cases as long as any overlapping 3D shapes are sorted such that the transparent 3D shapes (nearest last) are rendered after opaque 3D shapes.
01-05-2015

I noted the following when reviewing the fix for RT-40600. We will need to re-examine the blending equation used for 3D when we implement blending in 9, since the currently used equation, which matches 2D, assumes that we are using premultiplied alpha. When we add proper blending support we will also want to implement RT-17494 to allow for textures with non-premultiplied alpha. In such cases the blend equation that implements SRC_OVER changes from (1,1-alpha) to (alpha,1-alpha).
01-05-2015

There are a lot of votes for this issue. And I just voted myself. :-) If at all possible, this would be a really useful feature to add to JDK 9.
01-03-2015

The changes I mentioned above still work, in my previous attempts I did not re-enable depth-test, this is with depth test re-enabled (same code with 1 more line): https://www.youtube.com/watch?v=PlTv-mPU5X8 And Picking still works..
28-02-2015

Understandably there is more involved. And that you folks are busy. I only included the last 2 links for algorithm reference regarding the gl es2 pipeline. I had also seen talk about the depth sorting, while implementation may differ vendor to vendor, the maths are the important part. I also shared how I achieved the effect to give the willing and long waiting a temporary option... Until such time that you folks can get it implemented. (a ray of Hope)
27-02-2015

@Jason: Thank you for your interest in JavaFX 3D. We very much wanted to add this feature into JavaFX and we do plan to consider it for the 9 release (though we may not offer a full solution). As you have noted, to fully support this feature isn't as trivial as setting the blending operation. There are technical challenges such as transparency sorted rendering and picking semantic. A vendor specific implementation in general isn't an ideal solution for a platform independent API either.
26-02-2015

@Chien and FX Team Here is a gl implementation of "order independent dual depth peeling": http://mmmovania.blogspot.com/2010/11/order-independent-transparency-dual.html and I presume the paper to which was mentioned: http://developer.download.nvidia.com/SDK/10/opengl/src/dual_depth_peeling/doc/DualDepthPeeling.pdf
26-02-2015

@Don, I have not tested this on any of the newer builds (8.20+) and cannot confirm that the following will result in the same manner. Though I may get back to playing around with it soon. The code I changed is in the modules\graphics\src\main\native-prism-es2 package. In GlContext.c you should find -> 1733) /* * Class: com_sun_prism_es2_GLContext * Method: nSetDeviceParametersFor3D * Signature: (J)V */ JNIEXPORT void JNICALL Java_com_sun_prism_es2_GLContext_nSetDeviceParametersFor3D(...){} I made the above mentioned changes, ran a clean build, and simply supplied the material an alpha value in runtime. (IF (been months now) I made any changes in .java code, it was in one of the classes referencing this call) I'd be interested to see if it worked for you as well.. Remember that Culling, and DepthTest are important to achieve a decent appearance. Good Luck and best regards.
26-02-2015

This looks very promising - I think I only need Simple Transparency! I am a little lost as to what you changed - ES2 native code? A bit more information on what and how would be great. An example would also be good. I totally empathize with your frustration - I have been working on a Java I2C project while waiting for progress with JavaFX Many regards Don
26-02-2015

"Simple" transparency is fairly easy to implement ( this was a while ago however, pre-JavaOne '14 ) In ES2 native code I simply changed these 2 lines: //glDisable(GL_BLEND); //glBlendFunc(GL_ONE, GL_ZERO); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); To get a proper effect, culling should be disabled, or set to None. This is only for very basic "I can see through you" transparency. I used this guide: http://www.ntu.edu.sg/home/ehchua/programming/opengl/cg_basicstheory.html -> section 7.2 Alpha-Blending I did not bother with depth-test or culling in native code as those are controllable from runtime. I would attach photo's if I were able. I can however share links to twitter showing the results. My first attempt: https://twitter.com/jdub1581/status/517095300809248768 My colleagues : http://imgur.com/BuIqEgZ 2nd photo is the same build as the 1st I have been following this post since back in 2013. It is now 2015 and there has been almost 0 progress made in this regard, which is a little disheartening to say the least. I love and only use JavaFX, so with that I hope you can empathize with my frustration.
26-02-2015

Hello and thanks for your answer! I am not sure of all the implications of your proposal in our use case, but I think it might work. We will try to implement your proposal ASAP and post our results here!
05-01-2015

@Herve: Have you looked into the SubScene class? If you are trying to achieve "layering" of scenes SubScene with transparent fill can be a good alternative.
05-01-2015

Any hint on when you will support transparency with JavaFX (I understand after u40 of course) ? Even a partial solution would be better than nothing. BTW I understand that it might not be a simple problem. In our use case, we try to show transparent clouds or various 3D areas in a "gods view" 3D Map. For the moment, we use wireframe because of this limitation.
03-01-2015

Hi Don, 8u40 has a relatively short release cycle. It is primarily for bug fixes and a few very important and low risk "features". As for new 3D features, we have to prioritize accordingly. Our plan is to add support for the embedded platform and introduce a new vertex format to support user defined normal.
14-07-2014

Hi, I just want to lobby once again for transparency. It is essential for water animation. It is also used in static construction such as a window as well as making objects fade and appear. 50% transparency is better than none as long as it leads to fully variable as found in Java3D and OGL. Best wishes Don
12-07-2014

This work will have API implication that we aren't ready to deal with in 8u40. Hence pushing it to 9.
08-07-2014

I have been waiting a long time for this feature - it is very important for water animation.
11-04-2014

Our plan is to resolve this issue before JavaFX 9 especially if it doesn't involve new API work. It is tentatively scheduled for JavaFX 8u40.
18-03-2014

Is there anychance to give this a higher priority? If the deep sorting is the problem maybe you can create a simple non deepsorting Strategy. There are usecases which dont deepsorting e.g. i want to create a particle efect.
18-03-2014

Too late for Lombard, but is a good candidate for an update release.
30-10-2013

Transparency should be influenced by the diffuse component only. The alpha channel in specular (color and map) and self illumination map will have no impact.
30-10-2013

It would be helpful if the influence on transparency is clarified/described also for the opacity-value of the specular color and for the alpha-values of the self illumination and specular maps. Thanks.
07-05-2013

This will bring back transparency depth sorting issue as reported in RT-15250
14-03-2013