LWJGL error with TerrianLighting.j3md

Hi,
I am attempting to blend a couple of textures. I notice a lot of this links in the wiki and forum either are broken or refer to pre version 3. However, I came across TerrianLighting.j3md which seems to fit the task.

Here is my code…


    private void setTexture(Geometry _g,String _textureName,int _color,float _alpha,float _shininess)
     {
     alpha=_alpha;
     Material m=new Material(getAssetManager(),"Common/MatDefs/Terrain/TerrainLighting.j3md");
     ColorRGBA c=getColor(_color,alpha);
     m.setColor("Ambient",c);
     m.setColor("Diffuse",c);
     m.setColor("Specular",ColorRGBA.White);
     m.setFloat("Shininess",_shininess);
     m.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
     m.setTexture("DiffuseMap",getDiffuseMap(_textureName));
     m.setTexture("DiffuseMap_1",getDiffuseMap1(_textureName));
     m.setTexture("NormalMap_1",getNormalMap1(_textureName));
     m.setTexture("SpecularMap",getSpecularMap(_textureName));
     _g.setMaterial(m);
     if(alpha<1f)_g.setQueueBucket(Bucket.Transparent);
     }

I get an error which I have pasted at the end because I have a few questions.

Is using TerrainLighting.j3md the best way to blend 2 or more textures?

Is it possible to blend textures using a separate alpha map for each texture?

What is causing the error?..

HERE IS THE ERROR…

Jun 16, 2015 1:23:55 PM com.jme3.renderer.lwjgl.LwjglRenderer updateShaderSourceData
WARNING: Bad compile of:
1	#define DIFFUSEMAP 1
2	#define DIFFUSEMAP_1 1
3	#define NORMALMAP_1 1
4	#define SPECULARMAP 1
5	
6	uniform float m_Shininess;
7	uniform vec4 g_LightDirection;
8	
9	varying vec4 AmbientSum;
10	varying vec4 DiffuseSum;
11	varying vec4 SpecularSum;
12	
13	varying vec3 vNormal;
14	varying vec2 texCoord;
15	varying vec3 vPosition;
16	varying vec3 vnPosition;
17	varying vec3 vViewDir;
18	varying vec4 vLightDir;
19	varying vec4 vnLightDir;
20	varying vec3 lightVec;
21	
22	
23	#ifdef DIFFUSEMAP
24	  uniform sampler2D m_DiffuseMap;
25	#endif
26	#ifdef DIFFUSEMAP_1
27	  uniform sampler2D m_DiffuseMap_1;
28	#endif
29	#ifdef DIFFUSEMAP_2
30	  uniform sampler2D m_DiffuseMap_2;
31	#endif
32	#ifdef DIFFUSEMAP_3
33	  uniform sampler2D m_DiffuseMap_3;
34	#endif
35	#ifdef DIFFUSEMAP_4
36	  uniform sampler2D m_DiffuseMap_4;
37	#endif
38	#ifdef DIFFUSEMAP_5
39	  uniform sampler2D m_DiffuseMap_5;
40	#endif
41	#ifdef DIFFUSEMAP_6
42	  uniform sampler2D m_DiffuseMap_6;
43	#endif
44	#ifdef DIFFUSEMAP_7
45	  uniform sampler2D m_DiffuseMap_7;
46	#endif
47	#ifdef DIFFUSEMAP_8
48	  uniform sampler2D m_DiffuseMap_8;
49	#endif
50	#ifdef DIFFUSEMAP_9
51	  uniform sampler2D m_DiffuseMap_9;
52	#endif
53	#ifdef DIFFUSEMAP_10
54	  uniform sampler2D m_DiffuseMap_10;
55	#endif
56	#ifdef DIFFUSEMAP_11
57	  uniform sampler2D m_DiffuseMap_11;
58	#endif
59	
60	
61	#ifdef DIFFUSEMAP_0_SCALE
62	  uniform float m_DiffuseMap_0_scale;
63	#endif
64	#ifdef DIFFUSEMAP_1_SCALE
65	  uniform float m_DiffuseMap_1_scale;
66	#endif
67	#ifdef DIFFUSEMAP_2_SCALE
68	  uniform float m_DiffuseMap_2_scale;
69	#endif
70	#ifdef DIFFUSEMAP_3_SCALE
71	  uniform float m_DiffuseMap_3_scale;
72	#endif
73	#ifdef DIFFUSEMAP_4_SCALE
74	  uniform float m_DiffuseMap_4_scale;
75	#endif
76	#ifdef DIFFUSEMAP_5_SCALE
77	  uniform float m_DiffuseMap_5_scale;
78	#endif
79	#ifdef DIFFUSEMAP_6_SCALE
80	  uniform float m_DiffuseMap_6_scale;
81	#endif
82	#ifdef DIFFUSEMAP_7_SCALE
83	  uniform float m_DiffuseMap_7_scale;
84	#endif
85	#ifdef DIFFUSEMAP_8_SCALE
86	  uniform float m_DiffuseMap_8_scale;
87	#endif
88	#ifdef DIFFUSEMAP_9_SCALE
89	  uniform float m_DiffuseMap_9_scale;
90	#endif
91	#ifdef DIFFUSEMAP_10_SCALE
92	  uniform float m_DiffuseMap_10_scale;
93	#endif
94	#ifdef DIFFUSEMAP_11_SCALE
95	  uniform float m_DiffuseMap_11_scale;
96	#endif
97	
98	
99	#ifdef ALPHAMAP
100	  uniform sampler2D m_AlphaMap;
101	#endif
102	#ifdef ALPHAMAP_1
103	  uniform sampler2D m_AlphaMap_1;
104	#endif
105	#ifdef ALPHAMAP_2
106	  uniform sampler2D m_AlphaMap_2;
107	#endif
108	
109	#ifdef NORMALMAP
110	  uniform sampler2D m_NormalMap;
111	#endif
112	#ifdef NORMALMAP_1
113	  uniform sampler2D m_NormalMap_1;
114	#endif
115	#ifdef NORMALMAP_2
116	  uniform sampler2D m_NormalMap_2;
117	#endif
118	#ifdef NORMALMAP_3
119	  uniform sampler2D m_NormalMap_3;
120	#endif
121	#ifdef NORMALMAP_4
122	  uniform sampler2D m_NormalMap_4;
123	#endif
124	#ifdef NORMALMAP_5
125	  uniform sampler2D m_NormalMap_5;
126	#endif
127	#ifdef NORMALMAP_6
128	  uniform sampler2D m_NormalMap_6;
129	#endif
130	#ifdef NORMALMAP_7
131	  uniform sampler2D m_NormalMap_7;
132	#endif
133	#ifdef NORMALMAP_8
134	  uniform sampler2D m_NormalMap_8;
135	#endif
136	#ifdef NORMALMAP_9
137	  uniform sampler2D m_NormalMap_9;
138	#endif
139	#ifdef NORMALMAP_10
140	  uniform sampler2D m_NormalMap_10;
141	#endif
142	#ifdef NORMALMAP_11
143	  uniform sampler2D m_NormalMap_11;
144	#endif
145	
146	
147	#ifdef TRI_PLANAR_MAPPING
148	  varying vec4 wVertex;
149	  varying vec3 wNormal;
150	#endif
151	
152	
153	
154	float tangDot(in vec3 v1, in vec3 v2){
155	    float d = dot(v1,v2);
156	    #ifdef V_TANGENT
157	        d = 1.0 - d*d;
158	        return step(0.0, d) * sqrt(d);
159	    #else
160	        return d;
161	    #endif
162	}
163	
164	
165	float lightComputeDiffuse(in vec3 norm, in vec3 lightdir, in vec3 viewdir){
166	    return max(0.0, dot(norm, lightdir));
167	}
168	
169	float lightComputeSpecular(in vec3 norm, in vec3 viewdir, in vec3 lightdir, in float shiny){
170	    #ifdef WARDISO
171	        // Isotropic Ward
172	        vec3 halfVec = normalize(viewdir + lightdir);
173	        float NdotH  = max(0.001, tangDot(norm, halfVec));
174	        float NdotV  = max(0.001, tangDot(norm, viewdir));
175	        float NdotL  = max(0.001, tangDot(norm, lightdir));
176	        float a      = tan(acos(NdotH));
177	        float p      = max(shiny/128.0, 0.001);
178	        return NdotL * (1.0 / (4.0*3.14159265*p*p)) * (exp(-(a*a)/(p*p)) / (sqrt(NdotV * NdotL)));
179	    #else
180	       // Standard Phong
181	       vec3 R = reflect(-lightdir, norm);
182	       return pow(max(tangDot(R, viewdir), 0.0), shiny);
183	    #endif
184	}
185	
186	vec2 computeLighting(in vec3 wvPos, in vec3 wvNorm, in vec3 wvViewDir, in vec3 wvLightDir){
187	   float diffuseFactor = lightComputeDiffuse(wvNorm, wvLightDir, wvViewDir);
188	   float specularFactor = lightComputeSpecular(wvNorm, wvViewDir, wvLightDir, m_Shininess);
189	
190	   if (m_Shininess <= 1.0) {
191	       specularFactor = 0.0; // should be one instruction on most cards ..
192	   }
193	
194	   float att = vLightDir.w;
195	
196	   return vec2(diffuseFactor, specularFactor) * vec2(att);
197	}
198	
199	
200	#ifdef ALPHAMAP
201	
202	  vec4 calculateDiffuseBlend(in vec2 texCoord) {
203	    vec4 alphaBlend   = texture2D( m_AlphaMap, texCoord.xy );
204	    
205	    #ifdef ALPHAMAP_1
206	      vec4 alphaBlend1   = texture2D( m_AlphaMap_1, texCoord.xy );
207	    #endif
208	    #ifdef ALPHAMAP_2
209	      vec4 alphaBlend2   = texture2D( m_AlphaMap_2, texCoord.xy );
210	    #endif
211	
212	    vec4 diffuseColor = texture2D(m_DiffuseMap, texCoord * m_DiffuseMap_0_scale);
213	    diffuseColor *= alphaBlend.r;
214	    #ifdef DIFFUSEMAP_1
215	      vec4 diffuseColor1 = texture2D(m_DiffuseMap_1, texCoord * m_DiffuseMap_1_scale);
216	      diffuseColor = mix( diffuseColor, diffuseColor1, alphaBlend.g );
217	      #ifdef DIFFUSEMAP_2
218	        vec4 diffuseColor2 = texture2D(m_DiffuseMap_2, texCoord * m_DiffuseMap_2_scale);
219	        diffuseColor = mix( diffuseColor, diffuseColor2, alphaBlend.b );
220	        #ifdef DIFFUSEMAP_3
221	          vec4 diffuseColor3 = texture2D(m_DiffuseMap_3, texCoord * m_DiffuseMap_3_scale);
222	          diffuseColor = mix( diffuseColor, diffuseColor3, alphaBlend.a );
223	          #ifdef ALPHAMAP_1
224	              #ifdef DIFFUSEMAP_4
225	                vec4 diffuseColor4 = texture2D(m_DiffuseMap_4, texCoord * m_DiffuseMap_4_scale);
226	                diffuseColor = mix( diffuseColor, diffuseColor4, alphaBlend1.r );
227	                #ifdef DIFFUSEMAP_5
228	                  vec4 diffuseColor5 = texture2D(m_DiffuseMap_5, texCoord * m_DiffuseMap_5_scale);
229	                  diffuseColor = mix( diffuseColor, diffuseColor5, alphaBlend1.g );
230	                  #ifdef DIFFUSEMAP_6
231	                    vec4 diffuseColor6 = texture2D(m_DiffuseMap_6, texCoord * m_DiffuseMap_6_scale);
232	                    diffuseColor = mix( diffuseColor, diffuseColor6, alphaBlend1.b );
233	                    #ifdef DIFFUSEMAP_7
234	                      vec4 diffuseColor7 = texture2D(m_DiffuseMap_7, texCoord * m_DiffuseMap_7_scale);
235	                      diffuseColor = mix( diffuseColor, diffuseColor7, alphaBlend1.a );
236	                      #ifdef ALPHAMAP_2
237	                          #ifdef DIFFUSEMAP_8
238	                            vec4 diffuseColor8 = texture2D(m_DiffuseMap_8, texCoord * m_DiffuseMap_8_scale);
239	                            diffuseColor = mix( diffuseColor, diffuseColor8, alphaBlend2.r );
240	                            #ifdef DIFFUSEMAP_9
241	                              vec4 diffuseColor9 = texture2D(m_DiffuseMap_9, texCoord * m_DiffuseMap_9_scale);
242	                              diffuseColor = mix( diffuseColor, diffuseColor9, alphaBlend2.g );
243	                              #ifdef DIFFUSEMAP_10
244	                                vec4 diffuseColor10 = texture2D(m_DiffuseMap_10, texCoord * m_DiffuseMap_10_scale);
245	                                diffuseColor = mix( diffuseColor, diffuseColor10, alphaBlend2.b );
246	                                #ifdef DIFFUSEMAP_11
247	                                  vec4 diffuseColor11 = texture2D(m_DiffuseMap_11, texCoord * m_DiffuseMap_11_scale);
248	                                  diffuseColor = mix( diffuseColor, diffuseColor11, alphaBlend2.a );
249	                                #endif
250	                              #endif
251	                            #endif
252	                          #endif
253	                      #endif
254	                    #endif
255	                  #endif
256	                #endif
257	              #endif
258	          #endif
259	        #endif
260	      #endif
261	    #endif
262	    return diffuseColor;
263	  }
264	
265	  vec3 calculateNormal(in vec2 texCoord) {
266	    vec3 normal = vec3(0,0,1);
267	    vec3 n = vec3(0,0,0);
268	
269	    vec4 alphaBlend = texture2D( m_AlphaMap, texCoord.xy );
270	
271	    #ifdef ALPHAMAP_1
272	      vec4 alphaBlend1 = texture2D( m_AlphaMap_1, texCoord.xy );
273	    #endif
274	    #ifdef ALPHAMAP_2
275	      vec4 alphaBlend2 = texture2D( m_AlphaMap_2, texCoord.xy );
276	    #endif
277	
278	    #ifdef NORMALMAP
279	      n = texture2D(m_NormalMap, texCoord * m_DiffuseMap_0_scale).xyz;
280	      normal += n * alphaBlend.r;
281	    #else
282	      normal += vec3(0.5,0.5,1) * alphaBlend.r;
283	    #endif
284	
285	    #ifdef NORMALMAP_1
286	      n = texture2D(m_NormalMap_1, texCoord * m_DiffuseMap_1_scale).xyz;
287	      normal += n * alphaBlend.g;
288	    #else
289	      normal += vec3(0.5,0.5,1) * alphaBlend.g;
290	    #endif
291	
292	    #ifdef NORMALMAP_2
293	      n = texture2D(m_NormalMap_2, texCoord * m_DiffuseMap_2_scale).xyz;
294	      normal += n * alphaBlend.b;
295	    #else
296	      normal += vec3(0.5,0.5,1) * alphaBlend.b;
297	    #endif
298	
299	    #ifdef NORMALMAP_3
300	      n = texture2D(m_NormalMap_3, texCoord * m_DiffuseMap_3_scale).xyz;
301	      normal += n * alphaBlend.a;
302	    #else
303	      normal += vec3(0.5,0.5,1) * alphaBlend.a;
304	    #endif
305	
306	    #ifdef ALPHAMAP_1
307	        #ifdef NORMALMAP_4
308	          n = texture2D(m_NormalMap_4, texCoord * m_DiffuseMap_4_scale).xyz;
309	          normal += n * alphaBlend1.r;
310	        #endif
311	
312	        #ifdef NORMALMAP_5
313	          n = texture2D(m_NormalMap_5, texCoord * m_DiffuseMap_5_scale).xyz;
314	          normal += n * alphaBlend1.g;
315	        #endif
316	
317	        #ifdef NORMALMAP_6
318	          n = texture2D(m_NormalMap_6, texCoord * m_DiffuseMap_6_scale).xyz;
319	          normal += n * alphaBlend1.b;
320	        #endif
321	
322	        #ifdef NORMALMAP_7
323	          n = texture2D(m_NormalMap_7, texCoord * m_DiffuseMap_7_scale).xyz;
324	          normal += n * alphaBlend1.a;
325	        #endif
326	    #endif
327	
328	    #ifdef ALPHAMAP_2
329	        #ifdef NORMALMAP_8
330	          n = texture2D(m_NormalMap_8, texCoord * m_DiffuseMap_8_scale).xyz;
331	          normal += n * alphaBlend2.r;
332	        #endif
333	
334	        #ifdef NORMALMAP_9
335	          n = texture2D(m_NormalMap_9, texCoord * m_DiffuseMap_9_scale);
336	          normal += n * alphaBlend2.g;
337	        #endif
338	
339	        #ifdef NORMALMAP_10
340	          n = texture2D(m_NormalMap_10, texCoord * m_DiffuseMap_10_scale);
341	          normal += n * alphaBlend2.b;
342	        #endif
343	
344	        #ifdef NORMALMAP_11
345	          n = texture2D(m_NormalMap_11, texCoord * m_DiffuseMap_11_scale);
346	          normal += n * alphaBlend2.a;
347	        #endif
348	    #endif
349	
350	    normal = (normal.xyz * vec3(2.0) - vec3(1.0));
351	    return normalize(normal);
352	  }
353	
354	  #ifdef TRI_PLANAR_MAPPING
355	
356	    vec4 getTriPlanarBlend(in vec4 coords, in vec3 blending, in sampler2D map, in float scale) {
357	      vec4 col1 = texture2D( map, coords.yz * scale);
358	      vec4 col2 = texture2D( map, coords.xz * scale);
359	      vec4 col3 = texture2D( map, coords.xy * scale);
360	      // blend the results of the 3 planar projections.
361	      vec4 tex = col1 * blending.x + col2 * blending.y + col3 * blending.z;
362	      return tex;
363	    }
364	
365	    vec4 calculateTriPlanarDiffuseBlend(in vec3 wNorm, in vec4 wVert, in vec2 texCoord) {
366	        // tri-planar texture bending factor for this fragment's normal
367	        vec3 blending = abs( wNorm );
368	        blending = (blending -0.2) * 0.7;
369	        blending = normalize(max(blending, 0.00001));      // Force weights to sum to 1.0 (very important!)
370	        float b = (blending.x + blending.y + blending.z);
371	        blending /= vec3(b, b, b);
372	
373	        // texture coords
374	        vec4 coords = wVert;
375	
376	        // blend the results of the 3 planar projections.
377	        vec4 tex0 = getTriPlanarBlend(coords, blending, m_DiffuseMap, m_DiffuseMap_0_scale);
378	
379	        #ifdef DIFFUSEMAP_1
380	          // blend the results of the 3 planar projections.
381	          vec4 tex1 = getTriPlanarBlend(coords, blending, m_DiffuseMap_1, m_DiffuseMap_1_scale);
382	        #endif
383	        #ifdef DIFFUSEMAP_2
384	          // blend the results of the 3 planar projections.
385	          vec4 tex2 = getTriPlanarBlend(coords, blending, m_DiffuseMap_2, m_DiffuseMap_2_scale);
386	        #endif
387	        #ifdef DIFFUSEMAP_3
388	          // blend the results of the 3 planar projections.
389	          vec4 tex3 = getTriPlanarBlend(coords, blending, m_DiffuseMap_3, m_DiffuseMap_3_scale);
390	        #endif
391	        #ifdef DIFFUSEMAP_4
392	          // blend the results of the 3 planar projections.
393	          vec4 tex4 = getTriPlanarBlend(coords, blending, m_DiffuseMap_4, m_DiffuseMap_4_scale);
394	        #endif
395	        #ifdef DIFFUSEMAP_5
396	          // blend the results of the 3 planar projections.
397	          vec4 tex5 = getTriPlanarBlend(coords, blending, m_DiffuseMap_5, m_DiffuseMap_5_scale);
398	        #endif
399	        #ifdef DIFFUSEMAP_6
400	          // blend the results of the 3 planar projections.
401	          vec4 tex6 = getTriPlanarBlend(coords, blending, m_DiffuseMap_6, m_DiffuseMap_6_scale);
402	        #endif
403	        #ifdef DIFFUSEMAP_7
404	          // blend the results of the 3 planar projections.
405	          vec4 tex7 = getTriPlanarBlend(coords, blending, m_DiffuseMap_7, m_DiffuseMap_7_scale);
406	        #endif
407	        #ifdef DIFFUSEMAP_8
408	          // blend the results of the 3 planar projections.
409	          vec4 tex8 = getTriPlanarBlend(coords, blending, m_DiffuseMap_8, m_DiffuseMap_8_scale);
410	        #endif
411	        #ifdef DIFFUSEMAP_9
412	          // blend the results of the 3 planar projections.
413	          vec4 tex9 = getTriPlanarBlend(coords, blending, m_DiffuseMap_9, m_DiffuseMap_9_scale);
414	        #endif
415	        #ifdef DIFFUSEMAP_10
416	          // blend the results of the 3 planar projections.
417	          vec4 tex10 = getTriPlanarBlend(coords, blending, m_DiffuseMap_10, m_DiffuseMap_10_scale);
418	        #endif
419	        #ifdef DIFFUSEMAP_11
420	          // blend the results of the 3 planar projections.
421	          vec4 tex11 = getTriPlanarBlend(coords, blending, m_DiffuseMap_11, m_DiffuseMap_11_scale);
422	        #endif
423	
424	        vec4 alphaBlend   = texture2D( m_AlphaMap, texCoord.xy );
425	
426	        #ifdef ALPHAMAP_1
427	          vec4 alphaBlend1   = texture2D( m_AlphaMap_1, texCoord.xy );
428	        #endif
429	        #ifdef ALPHAMAP_2
430	          vec4 alphaBlend2   = texture2D( m_AlphaMap_2, texCoord.xy );
431	        #endif
432	
433	        vec4 diffuseColor = tex0 * alphaBlend.r;
434	        #ifdef DIFFUSEMAP_1
435	          diffuseColor = mix( diffuseColor, tex1, alphaBlend.g );
436	          #ifdef DIFFUSEMAP_2
437	            diffuseColor = mix( diffuseColor, tex2, alphaBlend.b );
438	            #ifdef DIFFUSEMAP_3
439	              diffuseColor = mix( diffuseColor, tex3, alphaBlend.a );
440	              #ifdef ALPHAMAP_1
441	                  #ifdef DIFFUSEMAP_4
442	                    diffuseColor = mix( diffuseColor, tex4, alphaBlend1.r );
443	                    #ifdef DIFFUSEMAP_5
444	                      diffuseColor = mix( diffuseColor, tex5, alphaBlend1.g );
445	                      #ifdef DIFFUSEMAP_6
446	                        diffuseColor = mix( diffuseColor, tex6, alphaBlend1.b );
447	                        #ifdef DIFFUSEMAP_7
448	                          diffuseColor = mix( diffuseColor, tex7, alphaBlend1.a );
449	                          #ifdef ALPHAMAP_2
450	                              #ifdef DIFFUSEMAP_8
451	                                diffuseColor = mix( diffuseColor, tex8, alphaBlend2.r );
452	                                #ifdef DIFFUSEMAP_9
453	                                  diffuseColor = mix( diffuseColor, tex9, alphaBlend2.g );
454	                                  #ifdef DIFFUSEMAP_10
455	                                    diffuseColor = mix( diffuseColor, tex10, alphaBlend2.b );
456	                                    #ifdef DIFFUSEMAP_11
457	                                      diffuseColor = mix( diffuseColor, tex11, alphaBlend2.a );
458	                                    #endif
459	                                  #endif
460	                                #endif
461	                              #endif
462	                          #endif
463	                        #endif
464	                      #endif
465	                    #endif
466	                  #endif
467	              #endif
468	            #endif
469	          #endif
470	        #endif
471	
472	        return diffuseColor;
473	    }
474	
475	    vec3 calculateNormalTriPlanar(in vec3 wNorm, in vec4 wVert,in vec2 texCoord) {
476	      // tri-planar texture bending factor for this fragment's world-space normal
477	      vec3 blending = abs( wNorm );
478	      blending = (blending -0.2) * 0.7;
479	      blending = normalize(max(blending, 0.00001));      // Force weights to sum to 1.0 (very important!)
480	      float b = (blending.x + blending.y + blending.z);
481	      blending /= vec3(b, b, b);
482	
483	      // texture coords
484	      vec4 coords = wVert;
485	      vec4 alphaBlend = texture2D( m_AlphaMap, texCoord.xy );
486	
487	      #ifdef ALPHAMAP_1
488	        vec4 alphaBlend1 = texture2D( m_AlphaMap_1, texCoord.xy );
489	      #endif
490	      #ifdef ALPHAMAP_2
491	        vec4 alphaBlend2 = texture2D( m_AlphaMap_2, texCoord.xy );
492	      #endif
493	
494	      vec3 normal = vec3(0,0,1);
495	      vec3 n = vec3(0,0,0);
496	
497	      #ifdef NORMALMAP
498	          n = getTriPlanarBlend(coords, blending, m_NormalMap, m_DiffuseMap_0_scale).xyz;
499	          normal += n * alphaBlend.r;
500	      #else
501	          normal += vec3(0.5,0.5,1) * alphaBlend.r;
502	      #endif
503	
504	      #ifdef NORMALMAP_1
505	          n = getTriPlanarBlend(coords, blending, m_NormalMap_1, m_DiffuseMap_1_scale).xyz;
506	          normal += n * alphaBlend.g;
507	      #else
508	          normal += vec3(0.5,0.5,1) * alphaBlend.g;
509	      #endif
510	
511	      #ifdef NORMALMAP_2
512	          n = getTriPlanarBlend(coords, blending, m_NormalMap_2, m_DiffuseMap_2_scale).xyz;
513	          normal += n * alphaBlend.b;
514	      #else
515	          normal += vec3(0.5,0.5,1) * alphaBlend.b;
516	      #endif
517	
518	      #ifdef NORMALMAP_3
519	          n = getTriPlanarBlend(coords, blending, m_NormalMap_3, m_DiffuseMap_3_scale).xyz;
520	          normal += n * alphaBlend.a;
521	      #else
522	          normal += vec3(0.5,0.5,1) * alphaBlend.a;
523	      #endif
524	
525	      #ifdef ALPHAMAP_1
526	          #ifdef NORMALMAP_4
527	              n = getTriPlanarBlend(coords, blending, m_NormalMap_4, m_DiffuseMap_4_scale).xyz;
528	              normal += n * alphaBlend1.r;
529	          #else
530	              normal += vec3(0.5,0.5,1) * alphaBlend.r;
531	          #endif
532	
533	          #ifdef NORMALMAP_5
534	              n = getTriPlanarBlend(coords, blending, m_NormalMap_5, m_DiffuseMap_5_scale).xyz;
535	              normal += n * alphaBlend1.g;
536	          #else
537	              normal += vec3(0.5,0.5,1) * alphaBlend.g;
538	          #endif
539	
540	          #ifdef NORMALMAP_6
541	              n = getTriPlanarBlend(coords, blending, m_NormalMap_6, m_DiffuseMap_6_scale).xyz;
542	              normal += n * alphaBlend1.b;
543	          #else
544	              normal += vec3(0.5,0.5,1) * alphaBlend.b;
545	          #endif
546	
547	          #ifdef NORMALMAP_7
548	              n = getTriPlanarBlend(coords, blending, m_NormalMap_7, m_DiffuseMap_7_scale).xyz;
549	              normal += n * alphaBlend1.a;
550	          #else
551	              normal += vec3(0.5,0.5,1) * alphaBlend.a;
552	          #endif
553	      #endif
554	
555	      #ifdef ALPHAMAP_2
556	          #ifdef NORMALMAP_8
557	              n = getTriPlanarBlend(coords, blending, m_NormalMap_8, m_DiffuseMap_8_scale).xyz;
558	              normal += n * alphaBlend2.r;
559	          #else
560	              normal += vec3(0.5,0.5,1) * alphaBlend.r;
561	          #endif
562	
563	          #ifdef NORMALMAP_9
564	              n = getTriPlanarBlend(coords, blending, m_NormalMap_9, m_DiffuseMap_9_scale).xyz;
565	              normal += n * alphaBlend2.g;
566	          #else
567	              normal += vec3(0.5,0.5,1) * alphaBlend.g;
568	          #endif
569	
570	          #ifdef NORMALMAP_10
571	              n = getTriPlanarBlend(coords, blending, m_NormalMap_10, m_DiffuseMap_10_scale).xyz;
572	              normal += n * alphaBlend2.b;
573	          #else
574	              normal += vec3(0.5,0.5,1) * alphaBlend.b;
575	          #endif
576	
577	          #ifdef NORMALMAP_11
578	              n = getTriPlanarBlend(coords, blending, m_NormalMap_11, m_DiffuseMap_11_scale).xyz;
579	              normal += n * alphaBlend2.a;
580	          #else
581	              normal += vec3(0.5,0.5,1) * alphaBlend.a;
582	          #endif
583	      #endif
584	
585	      normal = (normal.xyz * vec3(2.0) - vec3(1.0));
586	      return normalize(normal);
587	    }
588	  #endif
589	
590	#endif
591	
592	
593	
594	void main(){
595	
596	    //----------------------
597	    // diffuse calculations
598	    //----------------------
599	    #ifdef DIFFUSEMAP
600	      #ifdef ALPHAMAP
601	        #ifdef TRI_PLANAR_MAPPING
602	            vec4 diffuseColor = calculateTriPlanarDiffuseBlend(wNormal, wVertex, texCoord);
603	        #else
604	            vec4 diffuseColor = calculateDiffuseBlend(texCoord);
605	        #endif
606	      #else
607	        vec4 diffuseColor = texture2D(m_DiffuseMap, texCoord);
608	      #endif
609	    #else
610	      vec4 diffuseColor = vec4(1.0);
611	    #endif
612	
613	        float spotFallOff = 1.0;
614	        if(g_LightDirection.w!=0.0){
615	              vec3 L=normalize(lightVec.xyz);
616	              vec3 spotdir = normalize(g_LightDirection.xyz);
617	              float curAngleCos = dot(-L, spotdir);             
618	              float innerAngleCos = floor(g_LightDirection.w) * 0.001;
619	              float outerAngleCos = fract(g_LightDirection.w);
620	              float innerMinusOuter = innerAngleCos - outerAngleCos;
621	
622	              spotFallOff = (curAngleCos - outerAngleCos) / innerMinusOuter;
623	
624	              if(spotFallOff <= 0.0){
625	                  gl_FragColor = AmbientSum * diffuseColor;
626	                  return;
627	              }else{
628	                  spotFallOff = clamp(spotFallOff, 0.0, 1.0);
629	              }
630	        }
631	    
632	    //---------------------
633	    // normal calculations
634	    //---------------------
635	    #if defined(NORMALMAP) || defined(NORMALMAP_1) || defined(NORMALMAP_2) || defined(NORMALMAP_3) || defined(NORMALMAP_4) || defined(NORMALMAP_5) || defined(NORMALMAP_6) || defined(NORMALMAP_7) || defined(NORMALMAP_8) || defined(NORMALMAP_9) || defined(NORMALMAP_10) || defined(NORMALMAP_11)
636	      #ifdef TRI_PLANAR_MAPPING
637	        vec3 normal = calculateNormalTriPlanar(wNormal, wVertex, texCoord);
638	      #else
639	        vec3 normal = calculateNormal(texCoord);
640	      #endif
641	    #else
642	      vec3 normal = vNormal;
643	    #endif
644	
645	
646	    //-----------------------
647	    // lighting calculations
648	    //-----------------------
649	    vec4 lightDir = vLightDir;
650	    lightDir.xyz = normalize(lightDir.xyz);
651	
652	    vec2 light = computeLighting(vPosition, normal, vViewDir.xyz, lightDir.xyz)*spotFallOff;
653	
654	    vec4 specularColor = vec4(1.0);
655	
656	    //--------------------------
657	    // final color calculations
658	    //--------------------------
659	    gl_FragColor =  AmbientSum * diffuseColor +
660	                    DiffuseSum * diffuseColor  * light.x +
661	                    SpecularSum * specularColor * light.y;
662	
663	    //gl_FragColor.a = alpha;
664	}


Jun 16, 2015 1:23:55 PM 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/Terrain/TerrainLighting.frag, defines, type=Fragment, language=GLSL100] error:Fragment shader failed to compile with the following errors:
ERROR: 0:639: error(#202) No matching overloaded function found: calculateNormal
WARNING: 0:639: warning(#402) Implicit truncation of vector from size: 1 to size: 3
ERROR: error(#273) 1 compilation errors.  No code generated

I found this page…

TerraMonkey

I now have a better understanding of how TerrainLighting.j3md works.
The error might be caused because I dont have correctly matching maps.