In a recent thread, this graphical display bug was reported to occurr when running Jmonkey’s PBR Terrain examples:
I am trying to work on figuring out the cause still, so I made this thread to see if any other JME users can try to run these 2 PBRTerrain test cases and let me know your device specs and if you experience this error or not. (unfortunately my device does not reproduce this error so I cannot troubleshoot it myself by trial/error like I normally would)
I have a few ideas as to what the issue can be, but I want to collect some more information and look into it more before I begin changing things. Right now I think the most likely cause could be that I forgot to normalize a value or something somewhere throughout the normals or tangents calculation, but in that case I’d have expected some strange display glitches on my device too.
Any ideas, as well as any help running the test cases to see if you also experience this display bug (or any similar bugs with the pbr terrains) on your device would be greatly appreciated.
Strange bug. Hard to track down without beeing able to run it. Div/0 would come i to my mind, but that should fail on most devices. Or a wrong texture access in the non triplanar path. Something subtile wrong that more culant drivers ignore. Div/int instead of Div/float. Maybe on the texture array index. Guesses in the wild
Can I hop on this thread? I just ran the PBRTerrainTest and AdvancedPBRTerrainTest on my machine and the geometry is completely black. I have confirmed that the geometry and lights all exist, by applying a simple (Lighting) material instead of the PBR one. PBR produces nothing visible.
Thanks @pspeed, really appreciate you looking into this.
I realize that if there were a defect in the test, others would have complained. I 100% expect this to be a problem on my end, I’m just not sure where to look
I’m on JME 3.6.1. See below for the renderer info and a screenshot.
Oct 09, 2024 11:07:56 A.M. com.jme3.renderer.opengl.GLRenderer loadCapabilitiesCommon
INFO: OpenGL Renderer Information
Thanks for running the tests and reporting your device specs here!
Could you also confirm if you are able to render jme’s stock PBR shader (PBRLighting.j3md)? You could confirm this by running another other Test in jme3-examples called “TestPBRLighting” (or by running any jme project that uses PBRLighting.j3md)
If that test using PBRLighthing.frag with a standard geometry works, then that should confirm that the issue is specific to the PBR terrain shaders.
Ran TestPBRLighting on my machine. Rendered textured geometry very briefly then crashed:
Oct. 09, 2024 1:02:39 P.M. com.jme3.system.lwjgl.LwjglContext initOpenCL
INFO: Initialize OpenCL with LWJGL2
Oct. 09, 2024 1:02:39 P.M. com.jme3.system.lwjgl.LwjglContext initOpenCL
INFO: Available OpenCL platforms:
Oct. 09, 2024 1:02:40 P.M. com.jme3.material.Material checkTextureParamColorSpace
WARNING: The texture Textures/Sky/Path.hdr has linear color space, but the material parameter Texture specifies no color space requirement, this may lead to unexpected behavior.
Check if the image was not set to another material parameter with a linear color space, or that you did not set the ColorSpace to Linear using texture.getImage.setColorSpace().
Oct. 09, 2024 1:02:41 P.M. com.jme3.material.Material checkTextureParamColorSpace
WARNING: The texture Models/Tank/Tank_Occ_Rough_Metal.png has linear color space, but the material parameter LightMap specifies no color space requirement, this may lead to unexpected behavior.
Check if the image was not set to another material parameter with a linear color space, or that you did not set the ColorSpace to Linear using texture.getImage.setColorSpace().
Oct. 09, 2024 1:02:41 P.M. com.jme3.renderer.opengl.GLRenderer updateShaderSourceData
WARNING: Bad compile of:
1 #version 110
2 #define SRGB 1
3 #define FRAGMENT_SHADER 1
4
5 uniform samplerCube m_CubeMap;
6
7 varying vec3 Reflect_refVec;
8
9 void main() {
10 vec4 Global_color = vec4(1.0);
11
12
13 //EnvMapping : Begin
14 vec3 EnvMapping_refVec;
15 EnvMapping_refVec = Reflect_refVec;
16 vec4 EnvMapping_color;
17
18 //@input vec3 EnvMapping_refVec the reflection vector
19 //@input samplerCube m_CubeMap the cube map
20 //@output vec4 EnvMapping_color the output EnvMapping_color
21
22 #ifdef GL_ES
23 #ifdef GL_EXT_shader_texture_lod
24 EnvMapping_color = textureCubeLodEXT(m_CubeMap, EnvMapping_refVec, 0.0);
25 #else
26 EnvMapping_color = textureCube(m_CubeMap, EnvMapping_refVec);
27 #endif
28 #else
29 EnvMapping_color = textureCubeLod(m_CubeMap, EnvMapping_refVec, 0.0);
30 #endif
31 Global_color = EnvMapping_color;
32 //EnvMapping : End
33
34 gl_FragColor = Global_color;
35 }
Oct. 09, 2024 1:02:41 P.M. com.jme3.app.LegacyApplication handleError
SEVERE: Uncaught exception thrown in Thread[jME3 Main,6,main]
com.jme3.renderer.RendererException: compile error in: ShaderSource[name=Default.frag, defines, type=Fragment, language=GLSL100]
ERROR: 0:29: Invalid call of undeclared identifier 'textureCubeLod'
at com.jme3.renderer.opengl.GLRenderer.updateShaderSourceData(GLRenderer.java:1581)
at com.jme3.renderer.opengl.GLRenderer.updateShaderData(GLRenderer.java:1608)
at com.jme3.renderer.opengl.GLRenderer.setShader(GLRenderer.java:1673)
at com.jme3.material.logic.DefaultTechniqueDefLogic.render(DefaultTechniqueDefLogic.java:96)
at com.jme3.material.Technique.render(Technique.java:167)
at com.jme3.material.Material.render(Material.java:1052)
at com.jme3.renderer.RenderManager.renderGeometry(RenderManager.java:682)
at com.jme3.renderer.queue.RenderQueue.renderGeometryList(RenderQueue.java:273)
at com.jme3.renderer.queue.RenderQueue.renderQueue(RenderQueue.java:312)
at com.jme3.renderer.RenderManager.renderViewPortQueues(RenderManager.java:961)
at com.jme3.renderer.RenderManager.flushQueue(RenderManager.java:855)
at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:1223)
at com.jme3.renderer.RenderManager.render(RenderManager.java:1287)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:278)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:160)
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:225)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:242)
at java.base/java.lang.Thread.run(Thread.java:840)
I’m guessing there’s some kind of shader incompatibility with my apple hardware. Oh well
It sounds like the PBR shader worked, and the crash error you reported is related to some other stuff related to generating LightProbes on the GPU in that test-case/example.
In hindsight I probably shouldn’t have recommended running that test-case since it also does light probe generation, however it does not appear that JME has a PBR example using a pre-generated probe. (there is one other pbr example called TestPBRSimple.java you could try, but that also appears to generate the light probe at run-time as well)
So I suspect that you could get PBRLighting.j3md to work on your apple device if you load and attach a pre-generated lightProbe (and the black rendering for the PBR terrains is likely a gpu-specific mistake I made that I will still need to fix)
But as @pspeed mentioned, apple has a tendency to cause some unexpected difficulties with jme, and I personally don’t have an apple device so I am not entirely sure how many jme features actually support apple devices or how many other issues you may run into. If possible, I’d recommend using jme with windows or linux (and for my game, personally, I kind of gave up on trying to support apple since I know it will be difficult). But hopefully someone with more experience using apple devices with jme can chime in to provide more info.
Thanks @yaRnMcDonuts ! My next step was going to be working through the PBRTerrain shader to see if I can determine where the problem may be occurring. I’ll let this thread know if I find anything.