question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RendererException in TerrainLighting.frag

See original GitHub issue

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.0-stable setRenderer(AppSettings.LWJGL_OPENGL32)

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

Mar 07, 2022 10:10:34 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/TerrainLighting.frag, defines, type=Fragment, language=GLSL100]
ERROR: 0:1: '' :  version '110' is not supported
ERROR: 0:2: '' :  #version required and missing.
ERROR: 0:105: 'varying' : 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.MultiPassLightingLogic.render(MultiPassLightingLogic.java:158)
        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 jme3utilities.sky.test.CubeMapExample.main(CubeMapExample.java:85)

[JME ERROR] Uncaught exception thrown in Thread[jME3 Main,5,main]
RendererException: compile error in: ShaderSource[name=Common/MatDefs/Terrain/TerrainLighting.frag, defines, type=Fragment, language=GLSL100]
ERROR: 0:1: '' :  version '110' is not supported
ERROR: 0:2: '' :  #version required and missing.
ERROR: 0:105: 'varying' : syntax error: syntax error

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:15 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
stephengoldcommented, Mar 8, 2022

Will do.

Btw I obtained my Mac solely on the basis of the Libbulletjme project. It’s not associated with JME, so I’m certain you could obtain a 2nd one for JME if you wanted to.

1reaction
riccardoblcommented, Mar 8, 2022

It seems opengl 3.2 is not supported(?) can you get some info regarding the drivers and the opengl version they support?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Renderer Exception in TerrainLighting.frag - graphics ...
My suspicion is that Macs don't like the older OpenGL glsl110 and only support newer shader versions… because Apple. sgold ...
Read more >
59b2e6871c65f58fdad78cd7229c292f6a177578 - platform/external ...
... engine/src/blender/Common/MatDefs/Texture3D/tex3D.frag[Added - diff] ... engine/src/core/com/jme3/renderer/RendererException.java[Added - diff] ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found