Hi, I’ve created a very simple subclass of SimpleApplication but I’m getting a very strange error with no idea what’s causing it. What’s more, this used to work just fine, but it seems something has changed on my system that is breaking it. A new workspace runs this code just fine on a coworker’s computer.
I get a ‘bad compile’ message which prints out a concatenation of the files Common/ShaderLib/Skinning.glsllib and Common/MatDefs/Misc/Unshaded.vert. (As a result of preprocessor copy-pasting).
The error says I’m missing a ‘#version’ at the top of the file. Of course, I haven’t changed the file. My understanding is that the GLSL compiler should interpret files with no specified version as being version 110.
The second complaint is about a syntax error on ‘attribute,’ line 76. I don’t see anything wrong here.
I’ve tried specifying the version of OpenGL to use via AppSettings, but that seems to have no effect.
When I run the code through the debugger I see that there is a string ‘language’ set to “GLSL100” but also an int ‘version’ set to 150. This is in LwjglRenderer.
Any help on this would be much appreciated. I’m pretty well stumped.
[java]
Jun 03, 2014 9:03:29 AM com.jme3.renderer.lwjgl.LwjglRenderer updateShaderSourceData
WARNING: Bad compile of:
1 #define HAS_COLOR 1
2 #ifdef NUM_BONES
3
4 #if NUM_BONES < 1 || NUM_BONES > 255
5 #error NUM_BONES must be between 1 and 255.
6 #endif
7
8 #define NUM_WEIGHTS_PER_VERT 4
9
10 attribute vec4 inHWBoneWeight;
11 attribute vec4 inHWBoneIndex;
12 uniform mat4 m_BoneMatrices[NUM_BONES];
13
14 void Skinning_Compute(inout vec4 position){
15 if (inHWBoneWeight.x != 0.0) {
16 #if NUM_WEIGHTS_PER_VERT == 1
17 position = m_BoneMatrices[int(inHWBoneIndex.x)] * position;
18 #else
19 mat4 mat = mat4(0.0);
20 mat += m_BoneMatrices[int(inHWBoneIndex.x)] * inHWBoneWeight.x;
21 mat += m_BoneMatrices[int(inHWBoneIndex.y)] * inHWBoneWeight.y;
22 mat += m_BoneMatrices[int(inHWBoneIndex.z)] * inHWBoneWeight.z;
23 mat += m_BoneMatrices[int(inHWBoneIndex.w)] * inHWBoneWeight.w;
24 position = mat * position;
25 #endif
26 }
27 }
28
29 void Skinning_Compute(inout vec4 position, inout vec3 normal){
30 if (inHWBoneWeight.x != 0.0) {
31 #if NUM_WEIGHTS_PER_VERT == 1
32 position = m_BoneMatrices[int(inHWBoneIndex.x)] * position;
33 normal = (mat3(m_BoneMatrices[int(inHWBoneIndex.x)][0].xyz,
34 m_BoneMatrices[int(inHWBoneIndex.x)][1].xyz,
35 m_BoneMatrices[int(inHWBoneIndex.x)][2].xyz) * normal);
36 #else
37 mat4 mat = mat4(0.0);
38 mat += m_BoneMatrices[int(inHWBoneIndex.x)] * inHWBoneWeight.x;
39 mat += m_BoneMatrices[int(inHWBoneIndex.y)] * inHWBoneWeight.y;
40 mat += m_BoneMatrices[int(inHWBoneIndex.z)] * inHWBoneWeight.z;
41 mat += m_BoneMatrices[int(inHWBoneIndex.w)] * inHWBoneWeight.w;
42 position = mat * position;
43
44 mat3 rotMat = mat3(mat[0].xyz, mat[1].xyz, mat[2].xyz);
45 normal = rotMat * normal;
46 #endif
47 }
48 }
49
50 void Skinning_Compute(inout vec4 position, inout vec3 tangent, inout vec3 normal){
51 if (inHWBoneWeight.x != 0.0) {
52 #if NUM_WEIGHTS_PER_VERT == 1
53 position = m_BoneMatrices[int(inHWBoneIndex.x)] * position;
54 tangent = m_BoneMatrices[int(inHWBoneIndex.x)] * tangent;
55 normal = (mat3(m_BoneMatrices[int(inHWBoneIndex.x)][0].xyz,
56 m_BoneMatrices[int(inHWBoneIndex.x)][1].xyz,
57 m_BoneMatrices[int(inHWBoneIndex.x)][2].xyz) * normal);
58 #else
59 mat4 mat = mat4(0.0);
60 mat += m_BoneMatrices[int(inHWBoneIndex.x)] * inHWBoneWeight.x;
61 mat += m_BoneMatrices[int(inHWBoneIndex.y)] * inHWBoneWeight.y;
62 mat += m_BoneMatrices[int(inHWBoneIndex.z)] * inHWBoneWeight.z;
63 mat += m_BoneMatrices[int(inHWBoneIndex.w)] * inHWBoneWeight.w;
64 position = mat * position;
65
66 mat3 rotMat = mat3(mat[0].xyz, mat[1].xyz, mat[2].xyz);
67 tangent = rotMat * tangent;
68 normal = rotMat * normal;
69 #endif
70 }
71 }
72
73 #endif
74
75 uniform mat4 g_WorldViewProjectionMatrix;
76 attribute vec3 inPosition;
77
78 #if defined(HAS_COLORMAP) || (defined(HAS_LIGHTMAP) && !defined(SEPARATE_TEXCOORD))
79 #define NEED_TEXCOORD1
80 #endif
81
82 attribute vec2 inTexCoord;
83 attribute vec2 inTexCoord2;
84 attribute vec4 inColor;
85
86 varying vec2 texCoord1;
87 varying vec2 texCoord2;
88
89 varying vec4 vertColor;
90
91 void main(){
92 #ifdef NEED_TEXCOORD1
93 texCoord1 = inTexCoord;
94 #endif
95
96 #ifdef SEPARATE_TEXCOORD
97 texCoord2 = inTexCoord2;
98 #endif
99
100 #ifdef HAS_VERTEXCOLOR
101 vertColor = inColor;
102 #endif
103
104 vec4 modelSpacePos = vec4(inPosition, 1.0);
105 #ifdef NUM_BONES
106 Skinning_Compute(modelSpacePos);
107 #endif
108 gl_Position = g_WorldViewProjectionMatrix * modelSpacePos;
109 }
Jun 03, 2014 9:03:29 AM com.jme3.app.Application handleError
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
com.jme3.renderer.RendererException: compile error in:ShaderSource[name=Common/MatDefs/Misc/Unshaded.vert, defines, type=Vertex, language=GLSL100] error:ERROR: 0:1: ‘’ : #version required and missing.
ERROR: 0:76: ‘attribute’ : syntax error syntax error