jmonkeyengine: RendererException in PBRTerrain.frag
5th generation Mac Mini (Apple Silicon) OpenJDK 64-Bit Server VM Temurin-17.0.2+8 (build 17.0.2+8, mixed mode) JME v3.5 branch
The “HelloMav” application crashes with the message is “ERROR: ‘’ 0:1306: : syntax error: preprocessor command must not be preceded by any other statement in that line”. Googling that message led me to https://stackoverflow.com/questions/9574919/webgl-differs-from-opengl-preprocessor-on-same-graphics-stack
My conclusion: “PBRTerrain.frag” uses the ##
operator in 20+ places, but that operator isn’t supported in some versions of GLSL.
GitHub won’t allow me to post the full console output. Here’s a redacted version:
Mar 18, 2022 3:11:41 PM com.jme3.renderer.opengl.GLRenderer updateShaderSourceData
WARNING: Bad compile of:
1 #version 110
2 #define SRGB 1
3 #define FRAGMENT_SHADER 1
4 #define TRI_PLANAR_MAPPING 1
5 #define ALBEDOMAP_0 1
6 #define ALBEDOMAP_1 1
7 #define ALBEDOMAP_2 1
8 #define ALBEDOMAP_3 1
9 #define ALBEDOMAP_4 1
10 #define ALBEDOMAP_5 1
11 #define ALBEDOMAP_6 1
12 #define ALPHAMAP 1
13 #define ALPHAMAP_1 1
14 #define ALBEDOMAP_0_SCALE 0.1
15 #define ALBEDOMAP_1_SCALE 0.05
16 #define ALBEDOMAP_2_SCALE 0.1
17 #define ALBEDOMAP_3_SCALE 0.1
18 #define ALBEDOMAP_4_SCALE 0.3
19 #define ALBEDOMAP_5_SCALE 0.1
20 #define ALBEDOMAP_6_SCALE 0.5
21 #define DEBUG_VALUES_MODE 0
22 #define SINGLE_PASS_LIGHTING 1
23 #define NB_LIGHTS 3
24 #define NB_PROBES 1
25 #define USE_AMBIENT_LIGHT 1
26 #extension GL_ARB_shader_texture_lod : enable
27 // -- begin import Common/ShaderLib/GLSLCompat.glsllib --
28 #if defined GL_ES
…
1301 #ifdef ALBEDOMAP_0
1302 //NOTE! the old (phong) terrain shaders do not have an "_0" for the first diffuse map, it is just "DiffuseMap"
1303 #ifdef NORMALMAP_0
1304 BLEND_NORMAL(_0, alphaBlend.r)
1305 #else
1306 BLEND(_0, alphaBlend.r)
1307 #endif
1308
1309 #endif
1310 #ifdef ALBEDOMAP_1
1311 #ifdef NORMALMAP_1
1312 BLEND_NORMAL(_1, alphaBlend.g)
1313 #else
1314 BLEND(_1, alphaBlend.g)
1315 #endif
…
1934
1935 #endif
1936
1937 gl_FragColor.a = albedo.a;
1938
1939 }
Mar 18, 2022 3:11:41 PM com.jme3.app.LegacyApplication handleError
SEVERE: Uncaught exception thrown in Thread[jME3 Main,5,main]
com.jme3.renderer.RendererException: compile error in: ShaderSource[name=Common/MatDefs/Terrain/PBRTerrain.frag, defines, type=Fragment, language=GLSL100]
ERROR: 0:1306: '' : syntax error: preprocessor command must not be preceded by any other statement in that line
ERROR: 0:1306: 'premature EOF' : syntax error syntax error
at com.jme3.renderer.opengl.GLRenderer.updateShaderSourceData(GLRenderer.java:1539)
at com.jme3.renderer.opengl.GLRenderer.updateShaderData(GLRenderer.java:1566)
at com.jme3.renderer.opengl.GLRenderer.setShader(GLRenderer.java:1631)
at com.jme3.material.logic.SinglePassAndImageBasedLightingLogic.render(SinglePassAndImageBasedLightingLogic.java:276)
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:651)
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:928)
at com.jme3.renderer.RenderManager.flushQueue(RenderManager.java:823)
at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:1184)
at com.jme3.renderer.RenderManager.render(RenderManager.java:1248)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:278)
at com.jme3.system.lwjgl.LwjglWindow.runLoop(LwjglWindow.java:580)
at com.jme3.system.lwjgl.LwjglWindow.run(LwjglWindow.java:669)
at com.jme3.system.lwjgl.LwjglWindow.create(LwjglWindow.java:493)
at com.jme3.app.LegacyApplication.start(LegacyApplication.java:490)
at com.jme3.app.LegacyApplication.start(LegacyApplication.java:442)
at com.jme3.app.SimpleApplication.start(SimpleApplication.java:126)
at com.jayfella.jme.vehicle.simpledemo.HelloMav.main(HelloMav.java:104)
[JME ERROR] Uncaught exception thrown in Thread[jME3 Main,5,main]
RendererException: compile error in: ShaderSource[name=Common/MatDefs/Terrain/PBRTerrain.frag, defines, type=Fragment, language=GLSL100]
ERROR: 0:1306: '' : syntax error: preprocessor command must not be preceded by any other statement in that line
ERROR: 0:1306: 'premature EOF' : syntax error syntax error
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15 (15 by maintainers)
Commits related to this issue
- Refactored PBR Terrain to use new for-loops. Fix #1785 (#1901) Drastically reduced code by utilizing JME's new potential for define-compatible for-loops in shaders. Also cleaned up some other little ... — committed to jMonkeyEngine/jmonkeyengine by yaRnMcDonuts a year ago
- update (#4) * Android: Implemented AndroidNativeBufferAllocator - Deprecated AndroidBufferAllocator (#1821) * [skip ci] update natives snapshot * Add GL debug capabilities (#1790) * Add GL d... — committed to bob0bob/jmonkeyengine by bob0bob a year ago
I will give it a look as soon i worked down the queue for my own project a bit. The light dimming will not work in a default deferred pipeline since it requires additional information at the lighting stage. The pipeline alteady supports such changes if one want to add custom features by not using the shipped materials and buffer layouts.
Might take a week or two until i have time for this. thanks
I submitted a PR updating PBRTerrain.frag to use the new for-loops, so the shader no longer use any pre-processor functions with ## and should not cause any issues on mac anymore, although I did not get to test it on a mac to confirm for 100% certain.
https://github.com/jMonkeyEngine/jmonkeyengine/pull/1901
@zzuegg This should also hopefully make it easier to make a deferred version of the terrain now. The code was reduced by nearly half and I also tried to organize and clean up a lot of the remaining code so it isn’t as jumbled. However there are still some hacky things in the terrain shader that are for features exclusive to my game that may seem strange or could cause more confusion (specifically the affliction splatting and using the red channel of the vertex color buffer as an AO map for just the directionalLight so sunlight can be dimmed or entirely blocked indoors without requiring a shadow filter), so let me know if you have any trouble and I will be glad to help however I can!
I agree that if there’s ever a JMonkeyEngine 3.6 release, then PR #1758 and the fix for this issue should be included.
As long as the fix for this issue is integrated into “master” branch before the 3.6 code freeze, I don’t foresee any difficulty.
Currently there’s no 3.6 release scheduled, so I don’t know when code freeze will occur. My best guess would be summer of 2022.
Asking @stephengold since he is managing jme3.x releases
Yeah I’m not actively working on this right now but plan to soon. First I will refactor the shaders to use the for loops and get familiar with using that, then once its all working good on my windows device I’ll do testing on the remote mac instance to make sure its working.
It looks like your PR to add the shader loop support is merged to master but not the latest 3.5 release (if I’m seeing things correctly), so it could also be a good idea to include that in the next (3.6?) release, so then I could plan to have the updated terrain shaders ready for that release too.
Yeah, me too, but it doesn’t seem very easy to adapt to our problem
I think this is the way to solve the issue, it will also make the code more readable.
@yaRnMcDonuts if you are working on this, i can send you the credentials to access a remote macos instance for testing