[SOLVED partially] What to do, if multisampling doesn't supported by graphic card?

Hi Guys,

I need some help or needful hints again :neutral_face:
In my application I use

settings.setSamples(4); 

for making model edges smooth. This works fine on my desktop machine, but on my laptop the application crash with the errors:

I have read that some graphic cards don’t support multisampling and in this case programm crashed, if I using setSample() for my app.
(Is it true, that all intel graphics cards don’t support multisampling?)

Can I somehow ensure that multisampling is used only, if it supports by the graphics card and and otherwise:

settings.setSamples(0);

Thanks for any suggestions in advance :}

Your EsKay.

1 Like

You can read the capabilities of the card however I’m not sure it will work before your app goes into init.

http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:read_graphic_card_capabilites

Otherwise you could set it to zero as default, then in init check for the capability and if it’s there change samples to appropriate value and restart() your app settings.

In production, the usual way is to provide a settings window (much like jmonkey does by default) and customize that, so that you are given the choice beforehand.

Hey @DannyJo,

Sound like a plan, but I have no idea how to handle it.

With the following I can get a arry list of constants

 Collection<Caps> caps = renderer.getCaps();
Logger.getLogger(HuskiApplication.class.getName()).log(Level.INFO, "Caps: {0}", caps.toString());
for (Caps c : Caps.values()) 
     System.out.println(c);

Both on my desktop pc and on my laptop contains the output: Multisample
But it works on my laptop only with (0 or 1) >> defacto no multisample

Laptop output:

I think there must a possiblity to get a value of Multisample, which tell me, if i can use setSample(value bigger than 0), but I don’t know how :frowning:

@jayfella

Thx you too.
This solution make sense but the final version is for computer noobs, so all preferences should be predefined.
I should only run at the beginning with best-looking presentation, for the current system :3

Could be something like:

Integer integer = ((GLRenderer) renderManager.getRenderer()).getLimits().get(Limits.FrameBufferSamples);

you are searching for. Note, there is probably a reason that getLimits is hidden…

Hi @zzuegg :3

I would like try this, but can’t cast to (GLRenderer)
There is no import possibile for com.jme3.renderer.opengl.GLRenderer or something like and GLRenderer is unkown :confused:

Do you have any idea why? :no_mouth:

Oh, i guss you are using 3.0 then. Don’t have the 3.0 currently available but i am quite sure there was a similar method back then

@zzuegg
I don’t find something like that :’(((((((((((((((((((((((((((((((((

Also 3.1 checks if multisample is supported and will not crash if its not available.

Thanks @Momoko_Fan :} but i’m using jme sdk3.0 stable. This is what i download at the project development begin.
I don’t know how difficult is switch with my application to 3.1 :confused: but i’ve read that can make any problems :frowning:

So I’m searching for a solution to get this information from jme sdk3.0 :}

Use FXAA filter instead of sampling. It gives better results and is a bit faster.

@FrozenShade Sounds good, but is it suported by all graphic cards?
Do you know any good tutorials to use FXAA in jme?

best regards :}

It’s too simple filter to even look for tutorial. Read on wiki what FXAA is, play for some time with settings (4 or 5 values only).
If you are not familiar with filters in JME just google it, there was one tutorial here about scene processors and filters, it’s easy to setup a filter in JME.

1 Like

Finally I found the solution in the class Caps.java
https://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/core/com/jme3/renderer/Caps.java

This works for me:
Initialized appsettings at first with sample value 0

settings.setSamples(0);

and check the support of multisampling for the graphic card in simpleInitApp() . If it is supported then update the appsettings:

public void simpleInitApp() {
   ...
   Collection<Caps> caps = renderer.getCaps();

   //caps.contains(Caps.Multisample) return true if multisample ist supportet
   if (caps.contains(Caps.Multisample)){
        settings.setSamples(4);
        restart();
   }
   ...
}

Thanks to all for helping and next time I will have a look to FXAA filter. :3

Good night to all
Your EsKay :blush:

1 Like

Nice that it works for you, just to have it mentioned, even if the caps are present it says nothing about the amount of samples supported.

A quickly written code for 3.0 using the lwjgl renderer would look like:

public int getSupportedSamples(Renderer renderer){
        if(renderer.getCaps().contains(Caps.Multisample)){
            try {
                Field field=renderer.getClass().getDeclaredField("maxFBOSamples");
                field.setAccessible(true);
                return (int) field.get(renderer);
            } catch (NoSuchFieldException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        }else{
            return 0;
        }
    }

Just writen against the googlecode so its not tested. But should work

You are lovly :blush: with one more return at the end it run but with wrong return value :confused:
For my desktop pc it returns 32 but it only works with setSamples(16) .
Do you have any idea, where is the bug?

I still have a lot to learn :grinning: if I see your solution and my :wink:

Sorry don’t know. Could well be that maxFBOSamples and the samples you are setting are something different.
Would have to digg deeper, but thats a bit hard on googlecode :wink:
3.1 return 32 on my machine, and i have no error when setting 32.

it looks like connected to another problem:

if I use setSamples with 32 :confused:

maybe that’s the problem!
Suported Multisample (32) but can only use 16 because he don’t find this ARB pixel format ^^

I have to read first what that ARB pixel format is and what it does :3