get depth mask (z-buffer data) from Java3D

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

get depth mask (z-buffer data) from Java3D

cosmolev
This post was updated on .
Hi!

I'm trying to get depth mask from Java3D. It looks like previously (in earlier versions of Java3D) it worked, but currently all the code examples I was able to find are not working.

According to http://download.java.net/media/java3d/javadoc/1.4.0/javax/media/j3d/Canvas3D.html I should either wait for waitForOffScreenRendering and then read buffer or override postSwap method of Canvas3D and read buffer there.

1. In the first case u.getCanvas().getGraphicsContext3D().readRaster(raster); (https://github.com/cosmolev/DepthMaskPlayground/blob/master/src/DepthMaskSaver.java#L81) never returns anything because it got stuck in the infinite loop at GraphicsContext3D.java:2242 - while (!readRasterReady) loops forever.

2. In the second case with overridden postSwap (https://github.com/cosmolev/DepthMaskPlayground/blob/master/src/MyCanvas3D.java#L21) I have an error:
3D [dev] 1.6.0-pre12-daily-experimental daily

Exception occurred during Canvas 3D callback:
java.lang.IllegalStateException: initialize already in state true: ResizeableImpl[Initialized true, realized true, texUnit 0, samples 0,
	Factory   jogamp.opengl.windows.wgl.WindowsWGLDrawableFactory@523225c9,
	Handle    0xffffffffab01166a,
	Caps      GLCaps[wgl vid 7 arb: rgba 8/8/8/0, trans-rgba 0x0/0/0/0, accum-rgba 16/16/16/16, dp/st/ms 24/0/0, one, mono  , hw, GLProfile[GL4bc/GL4bc.hw], offscr[fbo]],
	fboI back 0, front 0, num 1,
	FBO front read 1, FBO[name r/w 1/1, init true, bound false, size 700x700, samples 0/32, modified false/false, depth RenderAttachment[type DEPTH, format 0x81a6, samples 0, 700x700, name 0x1, obj 0x333815e0], stencil null, colorbuffer attachments: 1/8, with 1 textures: [TextureAttachment[type COLOR_TEXTURE, target GL_TEXTURE_2D, level 0, format 0x8051, 700x700, border 0, dataFormat 0x1907, dataType 0x1401; min/mag 0x2600/0x2600, wrap S/T 0x812f/0x812f; name 0x1, obj 0x51a3879b], null, null, null, null, null, null, null], msaa[null, hasSink false, dirty true], state OK, obj 0x27243f65],
	FBO back  write 1, FBO[name r/w 1/1, init true, bound false, size 700x700, samples 0/32, modified false/false, depth RenderAttachment[type DEPTH, format 0x81a6, samples 0, 700x700, name 0x1, obj 0x333815e0], stencil null, colorbuffer attachments: 1/8, with 1 textures: [TextureAttachment[type COLOR_TEXTURE, target GL_TEXTURE_2D, level 0, format 0x8051, 700x700, border 0, dataFormat 0x1907, dataType 0x1401; min/mag 0x2600/0x2600, wrap S/T 0x812f/0x812f; name 0x1, obj 0x51a3879b], null, null, null, null, null, null, null], msaa[null, hasSink false, dirty true], state OK, obj 0x27243f65],
	Surface   GDISurface[ displayHandle 0x0
, surfaceHandle 0xffffffffab01166a
, size 700x700
, UOB[ OWNS_SURFACE | OWNS_DEVICE | WINDOW_INVISIBLE ]
, WindowsWGLGraphicsConfiguration[DefaultGraphicsScreen[WindowsGraphicsDevice[type .windows, connection decon, unitID 0, handle 0x0, owner false, NullToolkitLock[obj 0x5a4ed947]], idx 0], pfdID 7, ARB-Choosen true,
	requested GLCaps[rgba 8/8/8/0, trans-rgba 0x0/0/0/0, accum-rgba 16/16/16/16, dp/st/ms 24/0/0, one, mono  , hw, GLProfile[GL4bc/GL4bc.hw], offscr[fbo]],
	chosen    GLCaps[wgl vid 7 arb: rgba 8/8/8/0, trans-rgba 0x0/0/0/0, accum-rgba 16/16/16/16, dp/st/ms 24/0/0, one, mono  , hw, GLProfile[GL4bc/GL4bc.hw], offscr[fbo]]]
, surfaceLock <3cbe13f6, 63109aa1>[count 1, qsz 0, owner <J3D-Renderer-1>]
, GDIDummyUpstreamSurfaceHook[pixel 700x700]
, upstreamSurface false ]]
	at jogamp.opengl.GLFBODrawableImpl.initialize(GLFBODrawableImpl.java:185)
	at jogamp.opengl.GLFBODrawableImpl.associateContext(GLFBODrawableImpl.java:397)
	at jogamp.opengl.GLContextImpl.associateDrawable(GLContextImpl.java:843)
	at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:706)
	at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:580)
	at javax.media.j3d.JoglPipeline.createNewContext(JoglPipeline.java:6412)
	at javax.media.j3d.Canvas3D.createNewContext(Canvas3D.java:4602)
	at javax.media.j3d.Canvas3D.createNewContext(Canvas3D.java:2376)
	at javax.media.j3d.GraphicsContext3D.doClear(GraphicsContext3D.java:1728)
	at javax.media.j3d.GraphicsContext3D.doReadRaster(GraphicsContext3D.java:2264)
	at javax.media.j3d.GraphicsContext3D.readRaster(GraphicsContext3D.java:2231)
	at MyCanvas3D.postSwap(MyCanvas3D.java:36)
	at javax.media.j3d.Renderer.doWork(Renderer.java:1400)
	at javax.media.j3d.J3dThread.run(J3dThread.java:271)
com.jogamp.opengl.GLException: J3D-Renderer-1: Context not current on thread, inDestruction: false, obj 0x65286e01, ctx 0x30000, isShared false, surf true 0xffffffffab01166a, <33d8f60, 3e8fe949>[count 0, qsz 0, owner <NULL>]
	at jogamp.opengl.GLContextImpl.release(GLContextImpl.java:397)
	at jogamp.opengl.GLContextImpl.release(GLContextImpl.java:376)
	at javax.media.j3d.JoglPipeline.releaseCtx(JoglPipeline.java:7257)
	at javax.media.j3d.Canvas3D.releaseCtx(Canvas3D.java:4826)
	at javax.media.j3d.Canvas3D.releaseCtx(Canvas3D.java:2425)
	at javax.media.j3d.Renderer.doWork(Renderer.java:1416)
	at javax.media.j3d.J3dThread.run(J3dThread.java:271)

DefaultRenderingErrorListener.errorOccurred:
UNEXPECTED_RENDERING_ERROR: Renderer: Unexpected RuntimeException caught during rendering
graphicsDevice = Win32GraphicsDevice[screen=0]
canvas = MyCanvas3D[canvas0,0,0,700x700,invalid]

Process finished with exit code 1

All the code is on github (it's compact, just 2 classes).

I would be happy to get any suggestions. Hopefully I'm not the only one who is trying to get scene's depth mask :)
Reply | Threaded
Open this post in threaded view
|

Re: get depth mask (z-buffer data) from Java3D

gouessej
Administrator
Hi

Is it reproducible only on your machine?
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: get depth mask (z-buffer data) from Java3D

cosmolev
I've tried on two different machines (both Windows 7 though) - the behavior is completely equal.

Also I think it's somehow related to this regression bug: https://java.net/jira/browse/JAVA3D-512

So it seems there were no bug in Java 3D 1.4.0 and it appeared in Java 3D 1.5.0. I can confirm that this bug exists in 1.5.0. Unfortunately I wasn't able to run 1.4.0 because there are no binaries compiled for x64.
Reply | Threaded
Open this post in threaded view
|

Re: get depth mask (z-buffer data) from Java3D

gouessej
Administrator
The bug is very similar but the symptom is different. You can fill a bug report against Java3D on Github. Thank you for your investigation. I have no suggestion of fix yet.
Julien Gouesse | Personal blog | Website