Renderer and GPU Capabilities

Hello fellow jMonkeys,

I’m having trouble to understand the renderer and capabilities.
The AppSettings class provides constants for various versions of LWJGL OpenGL renderer as well as 2 options for JOGL renderer.

LWJGL only works when i select LWJGL_OpenGL2 or LWJGL_OpenGL3, all other options result in UnsupportedOperationException, which is quite obvious looking at the lines

if (settings.getRenderer().equals(AppSettings.LWJGL_OPENGL2)
        || settings.getRenderer().equals(AppSettings.LWJGL_OPENGL3)) {
} else {
    throw new UnsupportedOperationException("Unsupported renderer: " + settings.getRenderer());

in com.jme3.system.lwjgl.LwjglContext.initContextFirstTime()
so first question: whats the point in the other constants that you can choose from?

Also, when i set the renderer to AppSettings.LWJGL_OPENGL2 my app runs with no problem, however when i use AppSettings.LWJGL_OPENGL3 my app crashes with

UnsupportedOperationException: No technique 'Default' on material 'VegetationShader' is supported by the video hardware. The capabilities [GLSL400, GeometryShader, TesselationShader] are required

so second question: Since the app runs fine using AppSettings.LWJGL_OPENGL2 my GPU obviously supports the neccessary capabilities, why does the OPENGL3 renderer not realize that?

and a last question: since i specify the OpenGL versions for each shader that i need in the matDef file, do i have to make sure i only use versions that are equal or lower than the renderer selected?
like i can select OpenGL2 renderer (as mentioned, actually HAVE TO select that one) and still set GLSL400 in the material Definition file and that would always work, as long as i check the renderers capabilities and show a custom error message or in my case if GLSL400 is not supported just disable the vegetation?

Edit: Or to sum it up: whats the recommended way to handle this in the application? like i would assume using a “newer” renderer could result in better performance, i dont see how i would check if that newer renderer supports the capabilities needed though. if it does not, check if an older renderer supports it (as in my case), and if thats true use the older renderer, otherwise use the newer one and disable the features that need the capabilities, or if its not possible to disable them, show some error message.
that does not feel like the way to go

I’m using a Notebook with an Intel HD and a Nvidia Geforce 840m (which i select to be used for the JVM) in case the GPU makes a difference

As always thanks a lot in advance and many greetings from the shire,

I almost always use GLSL450 for my material definitions since I’m too lazy to be figuring out what syntax is in what glsl version and it definitely works. :wink: That said, the current material system isn’t too well adapted to the in/out glsl syntax, especially if you’re trying to have multiple outputs.

If you do that then most likely your game will require glsl450 to run. Thus it might work on your pc but not on others who have smaller opengl version.

For your first question:
It looks like the support for the other constants is a work in progress.

For your second question:
LWJGL_OPENGL3 I think uses core OpenGL3.2 profile. It seems like one of GLSL400, GeometryShader, TesselationShader is not added to the capabilities when you used LWJGL_OPENGL3.
Thus, probably work in progress too or bug.

For you last question:

If you look at for example jmonkeyengine/PostShadowFilter.j3md at master · jMonkeyEngine/jmonkeyengine · GitHub
you’ll notice that the Technique is written twice, first for GLSL150 and later for GLSL100.
Thus, you can first define a technique for glsl400 like you wanted and after that a fallback technique if it is not supported. Most probably the order matters, so first define glsl400 then smaller one/s. Jme will then handle the rest.

Fully aware of it, but I mostly do random experiments which at best end on github. Don’t really care if those don’t work on other machines.

allright thats something, thanks both for your replies!

regarding the dublicate techniques, what is the benefit of doing that? like i try to always use the lowest version possible for the features needed, so i assume that using lower versions causes the shader to run on more devices (of course i cannot go lower than the features i use require) but using higher versions might yield better performance?
or is this more useful in cases where i can actually disble some features in the shader so it looks a little different but still works for people with older graphics cards?

I think it’s so you can branch techniques for different versions. So a low end would do a cheap way or not at all, and a higher version would do another.

I say branch, I’m pretty sure it’s an ifdef of some sort, though.

allright that makes sence, thank you too!

do you maybe know more about the missing capabilities thing? like is there some sort of lookup file for the capabilities as there is for the gamepads or how are the capabilities determined?
or is it actually correct that the OpenGL3 renderer lacks the tessellation shader calabilities for my graphics card for some reason i dont see?

I’ve personally never set the appsettings for the lwjgl version. I include either one of these:

// version 2
implementation "org.jmonkeyengine:jme3-lwjgl:$jmeVer"

// version 3
implementation "org.jmonkeyengine:jme3-lwjgl3:$jmeVer"

That’s all I do. I know it works because in lwjgl2 my game starts with a black background, and in lwjgl3 my game starts with a white background.

Not very scientific - but there it is :stuck_out_tongue:

Edit: In looking at the logs it shows, too.

LWJGL 3.2.1 build 12 context running on thread main
LWJGL 2.9.3 context running on thread jME3 Main

that was actually very helpful, i didnt even know there was a lwjgl3 version available, i still use the sdk as i got it when i downloaded it about a year ago and i never felt like moving away from it as i prefer netbeans anyway

but i guess i should redo my setup and use gradle and maybe some newer version of netbeans or something but well…

for a quick test though, should this be the same lib?
taking into account i use version 3.2.1-stable-sdk3

edit: seems like its not :smiley: ill continue searching

It’s here: Version jme3-lwjgl3/3.2.1-stable - jmonkeyengine

There is a link at the bottom for the various builds (maven/gradle/etc)


Click files → version → jar.

thanks for your effort, it seems to be the same as the one i linked though as both fail with the same exception for a missing class and i guess the problem is that it depends on other libs. i have no experience using gradle but looking at jmonkeyengine/build.gradle at master · jMonkeyEngine/jmonkeyengine · GitHub i assume i need to manually download the libs listed there?

considering my currently super poor internet connection, that is gonna take some time, so i say thanks in advance :smiley:

Gradle will automatically download dependencies if you tell it where to search for them. Dependencies are specified in a POM file. Usually one of the build scripts will have a repositories section to enumerate known repositories.

yes i see i see i should switch to gradle asap :smiley:
but seriously, i should postpone it by some days until i got better internet and then switch my setup

All the dependencies are here. I have zero experience with the SDK, sorry… But I don’t know if they have dependencies of their own… You may be going down an endless rabbit-hole.