Using setNumSamples() doesn't work

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

Using setNumSamples() doesn't work

Qu0ll
I am using JOGL 2 and create my GL capabilities like so:

final GLCapabilities capabilities = new GLCapabilities(GLProfile.get(GLProfile.GL2));
capabilities.setHardwareAccelerated(true);
capabilities.setNumSamples(8);
capabilities.setSampleBuffers(true);

which works correctly but when I try to increase the number of samples to 16 or perhaps 32 (both of which should be supported by this GPU), the presence of jaggies actually increases and the quality of the rendering is much worse.

However, when I try the sample Eclipse project used in this tutorial:

http://www.leolol.com/tutorials/graphics_tutorials.html

I can increase the number of samples up to 32 and achieve high quality, smoothed shapes.

I think the tutorial is using JOGL 1.x so why can't I do this with JOGL 2.x?
Reply | Threaded
Open this post in threaded view
|

Re: Using setNumSamples() doesn't work

bardackx
It´s curious, I can only reach 2 (but the GPU supports up to 32). Try runing with ( -Djogl.debug=all) to see what is wrong
Reply | Threaded
Open this post in threaded view
|

Re: Using setNumSamples() doesn't work

Qu0ll
Interesting.  With debug turned on I actually see numerous exceptions.  I am not sure if that's expected behaviour or not.

Here are some of the highlights:

java.lang.Exception: WindowsWGLGraphicsConfigurationFactory got HDC 0x72014767
	at com.jogamp.opengl.impl.windows.wgl.WindowsWGLGraphicsConfigurationFactory.updateGraphicsConfiguration(WindowsWGLGraphicsConfigurationFactory.java:110)
	at com.jogamp.opengl.impl.windows.wgl.WindowsWGLGraphicsConfiguration.updateGraphicsConfiguration(WindowsWGLGraphicsConfiguration.java:90)
	at com.jogamp.opengl.impl.windows.wgl.WindowsWGLDrawable.setRealizedImpl(WindowsWGLDrawable.java:69)
	at com.jogamp.opengl.impl.GLDrawableImpl.setRealized(GLDrawableImpl.java:145)
	at javax.media.opengl.awt.GLCanvas.addNotify(GLCanvas.java:433)
	at java.awt.Container.addNotify(Container.java:2578)
	at javax.swing.JComponent.addNotify(JComponent.java:4685)
	at java.awt.Container.addNotify(Container.java:2578)
	at javax.swing.JComponent.addNotify(JComponent.java:4685)
	at java.awt.Container.addNotify(Container.java:2578)
	at javax.swing.JComponent.addNotify(JComponent.java:4685)
	at java.awt.Container.addNotify(Container.java:2578)
	at javax.swing.JComponent.addNotify(JComponent.java:4685)
	at javax.swing.JRootPane.addNotify(JRootPane.java:739)
	at java.awt.Container.addNotify(Container.java:2578)
	at java.awt.Window.addNotify(Window.java:663)
	at java.awt.Frame.addNotify(Frame.java:470)
	at java.awt.Window.show(Window.java:859)
	at java.awt.Component.show(Component.java:1563)
	at java.awt.Component.setVisible(Component.java:1515)
	at java.awt.Window.setVisible(Window.java:842)


WGL DrawableType does not match: req(onscrn true, pbuffer false), got(onscreen false, pbuffer false, pixmap false)
WGL DrawableType does not match: req(onscrn true, pbuffer false), got(onscreen false, pbuffer false, pixmap false)

AWT-EventQueue-0: !!! Initializing OpenGL extension address table for com.jogamp.opengl.impl.windows.wgl.WindowsOnscreenWGLContext [OpenGL -1.-1, options 0x0, null, handle 0x0, com.jogamp.opengl.impl.gl4.GL4bcImpl@e53108,
	Drawable Read/Write: com.jogamp.opengl.impl.windows.wgl.WindowsOnscreenWGLDrawable[Realized true,
	Factory   com.jogamp.opengl.impl.windows.wgl.WindowsWGLDrawableFactory@c7e553,
	handle    0xffffffff8f0144ba,
	Window    JAWT-Window[windowHandle 0x214a6, surfaceHandle 0xffffffff8f0144ba, bounds Rect[0/0 624x442], pos 0/0, size 624x442, visible true, locked true,
	config class javax.media.nativewindow.awt.AWTGraphicsConfiguration[class javax.media.nativewindow.awt.AWTGraphicsScreen[class javax.media.nativewindow.awt.AWTGraphicsDevice[type AWT, awtDevice Win32GraphicsDevice[screen=0], handle 0x0], idx 0],
	chosen    GLCapabilities[Capabilities[Onscreen: true, Red: 8, Green: 8, Blue: 8, Alpha: 0, Opaque: true], GL profile: GLProfile[GL2/GL2], PBuffer: false, DoubleBuffered: true, Stereo: false, HardwareAccelerated: true, DepthBits: 24, StencilBits: 0, Red Accum: 0, Green Accum: 0, Blue Accum: 0, Alpha Accum: 0, Multisample: true, Num samples: 16, PBuffer-FloatingPointBuffers: false, PBuffer-RenderToTexture: false, PBuffer-RenderToTextureRectangle: false],
	requested GLCapabilities[Capabilities[Onscreen: true, Red: 8, Green: 8, Blue: 8, Alpha: 0, Opaque: true], GL profile: GLProfile[GL2/GL2], PBuffer: false, DoubleBuffered: true, Stereo: false, HardwareAccelerated: true, DepthBits: 24, StencilBits: 0, Red Accum: 0, Green Accum: 0, Blue Accum: 0, Alpha Accum: 0, Multisample: true, Num samples: 16, PBuffer-FloatingPointBuffers: false, PBuffer-RenderToTexture: false, PBuffer-RenderToTextureRectangle: false],
	sun.awt.Win32GraphicsConfig@173a10f[dev=Win32GraphicsDevice[screen=0],pixfmt=0],
	encapsulated WindowsWGLGraphicsConfiguration[class javax.media.nativewindow.DefaultGraphicsScreen[class javax.media.nativewindow.windows.WindowsGraphicsDevice[type Windows, handle 0x0], idx 0], pfdID 1, wglChoosen true,
	requested GLCapabilities[Capabilities[Onscreen: true, Red: 8, Green: 8, Blue: 8, Alpha: 0, Opaque: true], GL profile: GLProfile[GL2/GL2], PBuffer: false, DoubleBuffered: true, Stereo: false, HardwareAccelerated: true, DepthBits: 24, StencilBits: 0, Red Accum: 0, Green Accum: 0, Blue Accum: 0, Alpha Accum: 0, Multisample: true, Num samples: 16, PBuffer-FloatingPointBuffers: false, PBuffer-RenderToTexture: false, PBuffer-RenderToTextureRectangle: false],
	chosen    GLCapabilities[Capabilities[Onscreen: true, Red: 8, Green: 8, Blue: 8, Alpha: 0, Opaque: true], GL profile: GLProfile[GL2/GL2], PBuffer: false, DoubleBuffered: false, Stereo: false, HardwareAccelerated: true, DepthBits: 24, StencilBits: 0, Red Accum: 16, Green Accum: 16, Blue Accum: 16, Alpha Accum: 16, Multisample: false, Num samples: 0, PBuffer-FloatingPointBuffers: true, PBuffer-RenderToTexture: false, PBuffer-RenderToTextureRectangle: false]]],
	wrappedWindow AWT-GLCanvas[ class javax.media.nativewindow.awt.AWTGraphicsConfiguration[class javax.media.nativewindow.awt.AWTGraphicsScreen[class javax.media.nativewindow.awt.AWTGraphicsDevice[type AWT, awtDevice Win32GraphicsDevice[screen=0], handle 0x0], idx 0],
	chosen    GLCapabilities[Capabilities[Onscreen: true, Red: 8, Green: 8, Blue: 8, Alpha: 0, Opaque: true], GL profile: GLProfile[GL2/GL2], PBuffer: false, DoubleBuffered: true, Stereo: false, HardwareAccelerated: true, DepthBits: 24, StencilBits: 0, Red Accum: 0, Green Accum: 0, Blue Accum: 0, Alpha Accum: 0, Multisample: true, Num samples: 16, PBuffer-FloatingPointBuffers: false, PBuffer-RenderToTexture: false, PBuffer-RenderToTextureRectangle: false],
	requested GLCapabilities[Capabilities[Onscreen: true, Red: 8, Green: 8, Blue: 8, Alpha: 0, Opaque: true], GL profile: GLProfile[GL2/GL2], PBuffer: false, DoubleBuffered: true, Stereo: false, HardwareAccelerated: true, DepthBits: 24, StencilBits: 0, Red Accum: 0, Green Accum: 0, Blue Accum: 0, Alpha Accum: 0, Multisample: true, Num samples: 16, PBuffer-FloatingPointBuffers: false, PBuffer-RenderToTexture: false, PBuffer-RenderToTextureRectangle: false],
	sun.awt.Win32GraphicsConfig@173a10f[dev=Win32GraphicsDevice[screen=0],pixfmt=0],
	encapsulated WindowsWGLGraphicsConfiguration[class javax.media.nativewindow.DefaultGraphicsScreen[class javax.media.nativewindow.windows.WindowsGraphicsDevice[type Windows, handle 0x0], idx 0], pfdID 1, wglChoosen true,
	requested GLCapabilities[Capabilities[Onscreen: true, Red: 8, Green: 8, Blue: 8, Alpha: 0, Opaque: true], GL profile: GLProfile[GL2/GL2], PBuffer: false, DoubleBuffered: true, Stereo: false, HardwareAccelerated: true, DepthBits: 24, StencilBits: 0, Red Accum: 0, Green Accum: 0, Blue Accum: 0, Alpha Accum: 0, Multisample: true, Num samples: 16, PBuffer-FloatingPointBuffers: false, PBuffer-RenderToTexture: false, PBuffer-RenderToTextureRectangle: false],
	chosen    GLCapabilities[Capabilities[Onscreen: true, Red: 8, Green: 8, Blue: 8, Alpha: 0, Opaque: true], GL profile: GLProfile[GL2/GL2], PBuffer: false, DoubleBuffered: false, Stereo: false, HardwareAccelerated: true, DepthBits: 24, StencilBits: 0, Red Accum: 16, Green Accum: 16, Blue Accum: 16, Alpha Accum: 16, Multisample: false, Num samples: 0, PBuffer-FloatingPointBuffers: true, PBuffer-RenderToTexture: false, PBuffer-RenderToTextureRectangle: false]]], com.jogamp.opengl.impl.windows.wgl.WindowsOnscreenWGLDrawable, GLEventListeners num 1 [SimpleJOGL@a39137[init false], ]]]]] 

As you can see, it requests 16 samples and initially accepts that number but then rejects it and sets the number of samples to 0 (hence the crappy output).

Does anyone know why this is so?  I can provide more detailed debug if that would help in the analysis.
Reply | Threaded
Open this post in threaded view
|

Re: Using setNumSamples() doesn't work

Demoscene Passivist
Administrator
I also tested multisampling support with my own framework (using NEWT+AWT). After it didn't work there I tried the official multisample example from the JOGL-Demos repository: http://github.com/sgothel/jogl-demos/blob/master/src/demos/multisample/Multisample.java

That didn't work either. To be 100% sure I tested it on an ATI card and on a NVidia card so eliminate driver issues. Guess what: Didn't work .  So it's definitly broken.

I filed an official bug report on bugzilla regarding this issue: http://jogamp.org/bugzilla/show_bug.cgi?id=410

Any additions/useful information u can provide for this bugreport are really appreciated.
Reply | Threaded
Open this post in threaded view
|

Re: Using setNumSamples() doesn't work

Qu0ll
Thanks for that D.P.  I will add some of the stack traces and debug output from my machine to the bug details in an effort to assist in a speedy resolution.
Reply | Threaded
Open this post in threaded view
|

Re: Using setNumSamples() doesn't work

gouessej
Administrator
In reply to this post by Demoscene Passivist
2 other people reproduced this bug on javagaming.org, Michael Bien already tried to fix it once as far as I know. If it is reproducible on Linux, I will have to fix it soon (before october).
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Using setNumSamples() doesn't work

gouessej
Administrator
In reply to this post by Qu0ll
Your bug is not really reproducible on Linux... Here I get simply no multi sampling :(
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Using setNumSamples() doesn't work

Demoscene Passivist
Administrator
In reply to this post by Qu0ll
While Sven hopefully works on the resolution of JOGL2 bug 410 "Multisampling doesn't work at all" I developed a quite simple workaround in the meantime by implementing a couple of utility methods that dynamically generate a "super sampling" GLSL fragment shader. Combined with rendering ur output to an oversampled FBO and then downsampling it with the generated shader u get FSAA that easily surpasses native MSAA in quality and ofcourse works with the current JOGL2 build .

So if u haven't worked around this issue by urself until now u may be interested in taking a look at my little implementation.
Reply | Threaded
Open this post in threaded view
|

RE: Using setNumSamples() doesn't work

Qu0ll

Hi,

 

Sorry it has taken me so long to get back to you and thanks for the information, it looks like an interesting technique.  I'll see if I can get some use out of it!

 

Cheers,

 

John

 

From: Demoscene Passivist [via jogamp] [mailto:[hidden email]]
Sent: Saturday, 9 October 2010 10:26
To: Qu0ll
Subject: Re: Using setNumSamples() doesn't work

 

While Sven hopefully works on the resolution of JOGL2 bug 410 "Multisampling doesn't work at all" I developed a quite simple workaround in the meantime by implementing a couple of utility methods that dynamically generate a "super sampling" GLSL fragment shader. Combined with rendering ur output to an oversampled FBO and then downsampling it with the generated shader u get FSAA that easily surpasses native MSAA in quality and ofcourse works with the current JOGL2 build .

So if u haven't worked around this issue by urself until now u may be interested in taking a look at my little implementation.


View message @ http://jogamp.762907.n3.nabble.com/Using-setNumSamples-doesn-t-work-tp1427769p1668277.html
To unsubscribe from Using setNumSamples() doesn't work, click here.

 

Reply | Threaded
Open this post in threaded view
|

Re: Using setNumSamples() doesn't work

Sven Gothel
Administrator
In reply to this post by Demoscene Passivist
On Saturday, October 09, 2010 01:25:34 Demoscene Passivist [via jogamp] wrote:
>
> While Sven hopefully works on the resolution of JOGL2 bug 410 "Multisampling
> doesn't work at all"
Solved.

> I developed a quite simple workaround in the meantime
> by implementing a couple of utility methods that dynamically generate a
> "super sampling" GLSL fragment shader. Combined with rendering ur output to
> an oversampled FBO and then downsampling it with the generated shader u get
> FSAA that easily surpasses native MSAA in quality

how about performance ?

Quality indeed, have seen the result of our little multisampling demo
on NV and AMD, the latter resulted in false colors.

> and ofcourse works with
> the current JOGL2 build .
>
> So if u haven't worked around this issue by urself until now u may be
> interested in taking a look at my little
> http://copypastaresearch.tumblr.com/post/1270735985/while-experimenting-with-glsl-based-fsaa-aka
> implementation .

looks like a glsl toolbox candidate.

~Sven
Reply | Threaded
Open this post in threaded view
|

Re: Using setNumSamples() doesn't work

Demoscene Passivist
Administrator
>how about performance ?

It's ok'isch. I would estimate 2xSSAA is performance wise roughly equivalent to 16xMSAA and look like 8xMSAA+.

Taking into account that SSAA isn't just smoothing the polygon edges but also the textures (thereby reducing texture aliasing effects), I guess its a valid tradeoff wich could be considered.

Other than that if u do some kind of deferred shading stuff, SSAA is the only way to go anyway.

>looks like a glsl toolbox candidate.

Was thinking about that too. As u can see I already have encapsulated it a bit into some kind of helper class, but it's still not usable as simple opt-in out-of-the-box. Maybe if I should thow some more brainz at this I could come up with a smoother solution API wise. Or some else has a nice idea about this ?