-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Milestone
Description
When I upgraded my FC3D application to from JME v3.10.0-alpha1 to JME v3.10.0-alpha3, it began crashing at runtime:
JAVA_HOME="/usr/lib/jvm/java-21-openjdk-amd64"
cd /mnt/virginia/home/sgold/NetBeansProjects/FuzeCreek/FC3D; ../gradlew run
> Task :FCCommon:compileJava UP-TO-DATE
> Task :FCCommon:processResources NO-SOURCE
> Task :FCCommon:classes UP-TO-DATE
> Task :FCCommon:jar UP-TO-DATE
> Task :FC3D:compileJava UP-TO-DATE
> Task :FC3D:processResources UP-TO-DATE
> Task :FC3D:classes UP-TO-DATE
> Task :FC3D:run
Mar 26, 2026 10:44:24 PM com.jme3.renderer.opengl.GLRenderer updateShaderSourceData
WARNING: Bad compile of:
1 #version 150 core
2 #define SRGB 1
3 #define FRAGMENT_SHADER 1
4 #define BOUND_DRAW_BUFFER 0
5 #define MATERIAL_COLORS 1
6 #define USE_FOG 1
7 #define FOG_LINEAR 1
8 #define SINGLE_PASS_LIGHTING 1
9 #define NB_LIGHTS 3
10 // -- begin import Common/ShaderLib/GLSLCompat.glsllib --
11 #ifdef GL_ES
12 #ifdef FRAGMENT_SHADER
13 precision highp float;
14 precision highp int;
15 #if __VERSION__ >= 130
16 precision highp sampler2DArray;
17 #endif
18 precision highp sampler2DShadow;
19 precision highp samplerCube;
20 precision highp sampler3D;
21 precision highp sampler2D;
22 #if __VERSION__ >= 310
23 precision highp sampler2DMS;
24 #endif
25 #endif
26 #endif
27
28 #if defined GL_ES
29 # define hfloat highp float
30 # define hvec2 highp vec2
31 # define hvec3 highp vec3
32 # define hvec4 highp vec4
33 # define lfloat lowp float
34 # define lvec2 lowp vec2
35 # define lvec3 lowp vec3
36 # define lvec4 lowp vec4
37 #else
38 # define hfloat float
39 # define hvec2 vec2
40 # define hvec3 vec3
41 # define hvec4 vec4
42 # define lfloat float
43 # define lvec2 vec2
44 # define lvec3 vec3
45 # define lvec4 vec4
46 #endif
47
48 #if __VERSION__ >= 130
49
50 #ifdef FRAGMENT_SHADER
51 #ifdef GL_ES
52 #ifdef BOUND_DRAW_BUFFER
53
54 #if 0<=BOUND_DRAW_BUFFER
55 #if BOUND_DRAW_BUFFER == 0
56 layout( location = 0 ) out highp vec4 outFragColor;
57 #else
58 layout( location = 0 ) out highp vec4 outNOP0;
59 #endif
60 #endif
61
62 #if 1<=BOUND_DRAW_BUFFER
63 #if BOUND_DRAW_BUFFER == 1
64 layout( location = 1 ) out highp vec4 outFragColor;
65 #else
66 layout( location = 1 ) out highp vec4 outNOP1;
67 #endif
68 #endif
69
70 #if 2<=BOUND_DRAW_BUFFER
71 #if BOUND_DRAW_BUFFER == 2
72 layout( location = 2 ) out highp vec4 outFragColor;
73 #else
74 layout( location = 2 ) out highp vec4 outNOP2;
75 #endif
76 #endif
77
78 #if 3<=BOUND_DRAW_BUFFER
79 #if BOUND_DRAW_BUFFER == 3
80 layout( location = 3 ) out highp vec4 outFragColor;
81 #else
82 layout( location = 3 ) out highp vec4 outNOP3;
83 #endif
84 #endif
85
86 #if 4<=BOUND_DRAW_BUFFER
87 #if BOUND_DRAW_BUFFER == 4
88 layout( location = 4 ) out highp vec4 outFragColor;
89 #else
90 layout( location = 4 ) out highp vec4 outNOP4;
91 #endif
92 #endif
93
94 #if 5<=BOUND_DRAW_BUFFER
95 #if BOUND_DRAW_BUFFER == 5
96 layout( location = 5 ) out highp vec4 outFragColor;
97 #else
98 layout( location = 5 ) out highp vec4 outNOP5;
99 #endif
100 #endif
101
102 #if 6<=BOUND_DRAW_BUFFER
103 #if BOUND_DRAW_BUFFER == 6
104 layout( location = 6 ) out highp vec4 outFragColor;
105 #else
106 layout( location = 6 ) out highp vec4 outNOP6;
107 #endif
108 #endif
109
110 #if 7<=BOUND_DRAW_BUFFER
111 #if BOUND_DRAW_BUFFER == 7
112 layout( location = 7 ) out highp vec4 outFragColor;
113 #else
114 layout( location = 7 ) out highp vec4 outNOP7;
115 #endif
116 #endif
117
118 #if 8<=BOUND_DRAW_BUFFER
119 #if BOUND_DRAW_BUFFER == 8
120 layout( location = 8 ) out highp vec4 outFragColor;
121 #else
122 layout( location = 8 ) out highp vec4 outNOP8;
123 #endif
124 #endif
125
126 #if 9<=BOUND_DRAW_BUFFER
127 #if BOUND_DRAW_BUFFER == 9
128 layout( location = 9 ) out highp vec4 outFragColor;
129 #else
130 layout( location = 9 ) out highp vec4 outNOP9;
131 #endif
132 #endif
133
134 #if 10<=BOUND_DRAW_BUFFER
135 #if BOUND_DRAW_BUFFER == 10
136 layout( location = 10 ) out highp vec4 outFragColor;
137 #else
138 layout( location = 10 ) out highp vec4 outNOP10;
139 #endif
140 #endif
141
142 #if 11<=BOUND_DRAW_BUFFER
143 #if BOUND_DRAW_BUFFER == 11
144 layout( location = 11 ) out highp vec4 outFragColor;
145 #else
146 layout( location = 11 ) out highp vec4 outNOP11;
147 #endif
148 #endif
149
150 #if 12<=BOUND_DRAW_BUFFER
151 #if BOUND_DRAW_BUFFER == 12
152 layout( location = 12 ) out highp vec4 outFragColor;
153 #else
154 layout( location = 12 ) out highp vec4 outNOP12;
155 #endif
156 #endif
157
158 #if 13<=BOUND_DRAW_BUFFER
159 #if BOUND_DRAW_BUFFER == 13
160 layout( location = 13 ) out highp vec4 outFragColor;
161 #else
162 layout( location = 13 ) out highp vec4 outNOP13;
163 #endif
164 #endif
165
166 #if 14<=BOUND_DRAW_BUFFER
167 #if BOUND_DRAW_BUFFER == 14
168 layout( location = 14 ) out highp vec4 outFragColor;
169 #else
170 layout( location = 14 ) out highp vec4 outNOP14;
171 #endif
172 #endif
173 #else
174 out highp vec4 outFragColor;
175 #endif
176 #else
177 out vec4 outFragColor;
178 #endif
179 #endif
180
181 # define texture1D texture
182 # define texture2D texture
183 # define texture3D texture
184 # define textureCube texture
185 # define texture2DLod textureLod
186 # define textureCubeLod textureLod
187 # define texture2DArray texture
188 # if defined VERTEX_SHADER
189 # define varying out
190 # define attribute in
191 # elif defined FRAGMENT_SHADER
192 # define varying in
193 # define gl_FragColor outFragColor
194 # endif
195 #else
196 # define isnan(val) !(val<0.0||val>0.0||val==0.0)
197 #endif
198
199 #if __VERSION__ == 110
200 mat3 mat3_sub(mat4 m) {
201 return mat3(m[0].xyz, m[1].xyz, m[2].xyz);
202 }
203 #else
204 #define mat3_sub mat3
205 #endif
206
207 #if __VERSION__ <= 140
208 float determinant(mat2 m) {
209 return m[0][0] * m[1][1] - m[1][0] * m[0][1];
210 }
211
212 float determinant(mat3 m) {
213 return + m[0][0] * (m[1][1] * m[2][2] - m[1][2] * m[2][1])
214 - m[0][1] * (m[1][0] * m[2][2] - m[1][2] * m[2][0])
215 + m[0][2] * (m[1][0] * m[2][1] - m[1][1] * m[2][0]);
216 }
217 #endif
218
219 #if __VERSION__ <= 130
220 mat2 inverse(mat2 m) {
221 return mat2(m[1][1], -m[0][1], -m[1][0], m[0][0]) / determinant(m);
222 }
223
224 mat3 inverse(mat3 m) {
225 return mat3(
226 + (m[1][1] * m[2][2] - m[2][1] * m[1][2]),
227 - (m[1][0] * m[2][2] - m[2][0] * m[1][2]),
228 + (m[1][0] * m[2][1] - m[2][0] * m[1][1]),
229 - (m[0][1] * m[2][2] - m[2][1] * m[0][2]),
230 + (m[0][0] * m[2][2] - m[2][0] * m[0][2]),
231 - (m[0][0] * m[2][1] - m[2][0] * m[0][1]),
232 + (m[0][1] * m[1][2] - m[1][1] * m[0][2]),
233 - (m[0][0] * m[1][2] - m[1][0] * m[0][2]),
234 + (m[0][0] * m[1][1] - m[1][0] * m[0][1])) / determinant(m);
235 }
236 #endif
237 // -- end import Common/ShaderLib/GLSLCompat.glsllib --
238 // -- begin import Common/ShaderLib/Parallax.glsllib --
239 #if (defined(PARALLAXMAP) || (defined(NORMALMAP_PARALLAX) && defined(NORMALMAP))) && !defined(VERTEX_LIGHTING)
240 vec2 steepParallaxOffset(sampler2D parallaxMap, vec3 vViewDir,vec2 texCoord,float parallaxScale){
241 vec2 vParallaxDirection = normalize( vViewDir.xy );
242
243 // The length of this vector determines the furthest amount of displacement: (Ati's comment)
244 float fLength = length( vViewDir );
245 float fParallaxLength = sqrt( fLength * fLength - vViewDir.z * vViewDir.z ) / vViewDir.z;
246
247 // Compute the actual reverse parallax displacement vector: (Ati's comment)
248 vec2 vParallaxOffsetTS = vParallaxDirection * fParallaxLength;
249
250 // Need to scale the amount of displacement to account for different height ranges
251 // in height maps. This is controlled by an artist-editable parameter: (Ati's comment)
252 parallaxScale *=0.3;
253 vParallaxOffsetTS *= parallaxScale;
254
255 vec3 eyeDir = normalize(vViewDir).xyz;
256
257 float nMinSamples = 6.0;
258 float nMaxSamples = 1000.0 * parallaxScale;
259 float nNumSamples = mix( nMinSamples, nMaxSamples, 1.0 - eyeDir.z ); //In reference shader: int nNumSamples = (int)(lerp( nMinSamples, nMaxSamples, dot( eyeDirWS, N ) ));
260 float fStepSize = 1.0 / nNumSamples;
261 float fCurrHeight = 0.0;
262 float fPrevHeight = 1.0;
263 float fNextHeight = 0.0;
264 float nStepIndex = 0.0;
265 vec2 vTexOffsetPerStep = fStepSize * vParallaxOffsetTS;
266 vec2 vTexCurrentOffset = texCoord;
267 float fCurrentBound = 1.0;
268 float fParallaxAmount = 0.0;
269
270 while ( nStepIndex < nNumSamples && fCurrHeight <= fCurrentBound ) {
271 vTexCurrentOffset -= vTexOffsetPerStep;
272 fPrevHeight = fCurrHeight;
273
274
275 #ifdef NORMALMAP_PARALLAX
276 //parallax map is stored in the alpha channel of the normal map
277 fCurrHeight = texture2D( parallaxMap, vTexCurrentOffset).a;
278 #else
279 //parallax map is a texture
280 fCurrHeight = texture2D( parallaxMap, vTexCurrentOffset).r;
281 #endif
282
283 fCurrentBound -= fStepSize;
284 nStepIndex+=1.0;
285 }
286 vec2 pt1 = vec2( fCurrentBound, fCurrHeight );
287 vec2 pt2 = vec2( fCurrentBound + fStepSize, fPrevHeight );
288
289 float fDelta2 = pt2.x - pt2.y;
290 float fDelta1 = pt1.x - pt1.y;
291
292 float fDenominator = fDelta2 - fDelta1;
293
294 fParallaxAmount = (pt1.x * fDelta2 - pt2.x * fDelta1 ) / fDenominator;
295
296 vec2 vParallaxOffset = vParallaxOffsetTS * (1.0 - fParallaxAmount );
297 return texCoord - vParallaxOffset;
298 }
299
300 vec2 classicParallaxOffset(sampler2D parallaxMap, vec3 vViewDir,vec2 texCoord,float parallaxScale){
301 float h;
302 #ifdef NORMALMAP_PARALLAX
303 //parallax map is stored in the alpha channel of the normal map
304 h = texture2D(parallaxMap, texCoord).a;
305 #else
306 //parallax map is a texture
307 h = texture2D(parallaxMap, texCoord).r;
308 #endif
309 float heightScale = parallaxScale;
310 float heightBias = heightScale* -0.6;
311 vec3 normView = normalize(vViewDir);
312 h = (h * heightScale + heightBias) * normView.z;
313 return texCoord + (h * normView.xy);
314 }
315 #endif
316 // -- end import Common/ShaderLib/Parallax.glsllib --
317 // -- begin import Common/ShaderLib/Optics.glsllib --
318 #if defined(SPHERE_MAP) || defined(EQUIRECT_MAP)
319 #define ENVMAP sampler2D
320 #define TEXENV texture2D
321 #else
322 #define ENVMAP samplerCube
323 #define TEXENV textureCube
324 #endif
325
326 // converts a normalized direction vector
327 // into a texture coordinate for fetching
328 // texel from a sphere map
329 vec2 Optics_SphereCoord(in vec3 dir){
330 float dzplus1 = dir.z + 1.0;
331
332 // compute 1/2p
333 // NOTE: this simplification only works if dir is normalized.
334 float inv_two_p = 1.414 * sqrt(dzplus1);
335 //float inv_two_p = sqrt(dir.x * dir.x + dir.y * dir.y + dzplus1 * dzplus1);
336 inv_two_p *= 2.0;
337 inv_two_p = 1.0 / inv_two_p;
338
339 // compute texcoord
340 return (dir.xy * vec2(inv_two_p)) + vec2(0.5);
341 }
342
343 #ifndef PI
344 #define PI 3.14159265358979323846264
345 #endif
346 //should be vec2(1.0 / (PI * 2.0), 1.0 / PI) but it's precomputed.
347 const vec2 Optics_Glsllib_Rads = vec2(0.159154943091895, 0.318309886183790);
348 vec2 Optics_LonLatCoords(in ENVMAP envMap, in vec3 dir){
349 float lon = atan(dir.z, dir.x)+ PI;
350 float lat = acos(dir.y);
351 return vec2(lon, lat) * Optics_Glsllib_Rads;
352 }
353
354 vec4 Optics_GetEnvColor(in ENVMAP envMap, in vec3 dir){
355 #ifdef SPHERE_MAP
356 return texture2D(envMap, Optics_SphereCoord(dir));
357 #else
358 #ifdef EQUIRECT_MAP
359 return texture2D(envMap, Optics_LonLatCoords(envMap,dir));
360 #else
361 return textureCube(envMap, dir);
362 #endif
363 #endif
364 }
365 // -- end import Common/ShaderLib/Optics.glsllib --
366 #ifndef VERTEX_LIGHTING
367 // -- begin import Common/ShaderLib/BlinnPhongLighting.glsllib --
368 /*Blinn Phong lighting*/
369
370 /*
371 * Computes diffuse factor (Lambert)
372 */
373 float lightComputeDiffuse(in vec3 norm, in vec3 lightdir){
374 return max(0.0, dot(norm, lightdir));
375 }
376
377 /*
378 * Computes specular factor (blinn phong)
379 */
380 float lightComputeSpecular(in vec3 norm, in vec3 viewdir, in vec3 lightdir, in float shiny){
381 vec3 H = normalize(viewdir + lightdir);
382 float HdotN = max(0.0, dot(H, norm));
383 return pow(HdotN, shiny);
384 }
385
386 /*
387 *Computes standard phong specular lighting
388 */
389 float lightComputeSpecularPhong(in vec3 norm, in vec3 viewdir, in vec3 lightdir, in float shiny){
390 vec3 R = reflect(-lightdir, norm);
391 return pow(max(dot(R, viewdir), 0.0), shiny);
392 }
393
394
395 /*
396 * Computes diffuse and specular factors and pack them in a vec2 (x=diffuse, y=specular)
397 */
398 vec2 computeLighting(in vec3 norm, in vec3 viewDir, in vec3 lightDir, in float attenuation, in float shininess){
399 float diffuseFactor = lightComputeDiffuse(norm, lightDir);
400 float specularFactor = lightComputeSpecular(norm, viewDir, lightDir, shininess);
401 if (shininess <= 1.0) {
402 specularFactor = 0.0; // should be one instruction on most cards ..
403 }
404 specularFactor *= diffuseFactor;
405 return vec2(diffuseFactor, specularFactor) * vec2(attenuation);
406 }
407 // -- end import Common/ShaderLib/BlinnPhongLighting.glsllib --
408 // -- begin import Common/ShaderLib/Lighting.glsllib --
409 /*Common function for light calculations*/
410
411
412 /*
413 * Computes light direction
414 * lightType should be 0.0,1.0,2.0, respectively for Directional, point and spot lights.
415 * Outputs the light direction and the light half vector.
416 */
417 void lightComputeDir(in vec3 worldPos, in float lightType, in vec4 position, out vec4 lightDir, out vec3 lightVec){
418 float posLight = step(0.5, lightType);
419 vec3 tempVec = position.xyz * sign(posLight - 0.5) - (worldPos * posLight);
420 lightVec = tempVec;
421 float dist = length(tempVec);
422 if (dist <= 0.0) {
423 lightDir = vec4(0.0);
424 return;
425 }
426 #ifdef SRGB
427 lightDir.w = (1.0 - position.w * dist) / (1.0 + position.w * dist * dist);
428 lightDir.w = clamp(lightDir.w, 1.0 - posLight, 1.0);
429 #else
430 lightDir.w = clamp(1.0 - position.w * dist * posLight, 0.0, 1.0);
431 #endif
432 lightDir.xyz = tempVec / vec3(dist);
433 }
434
435 /*
436 * Computes the spot falloff for a spotlight
437 */
438 float computeSpotFalloff(in vec4 lightDirection, in vec3 lightVector){
439 vec3 L=normalize(lightVector);
440 vec3 spotdir = normalize(lightDirection.xyz);
441 float curAngleCos = dot(-L, spotdir);
442 float innerAngleCos = floor(lightDirection.w) * 0.001;
443 float outerAngleCos = fract(lightDirection.w);
444 float innerMinusOuter = innerAngleCos - outerAngleCos;
445 float falloff = clamp((curAngleCos - outerAngleCos) / innerMinusOuter, step(lightDirection.w, 0.001), 1.0);
446
447 #ifdef SRGB
448 // Use quadratic falloff (notice the ^4)
449 return pow(clamp((curAngleCos - outerAngleCos) / innerMinusOuter, 0.0, 1.0), 4.0);
450 #else
451 // Use linear falloff
452 return falloff;
453 #endif
454 }
455
456 // -- end import Common/ShaderLib/Lighting.glsllib --
457 #endif
458
459 // fog - jayfella
460 #ifdef USE_FOG
461 // -- begin import Common/ShaderLib/MaterialFog.glsllib --
462 //author @jayfella
463 #ifndef __MATERIAL_FOG_UTIL__
464 #define __MATERIAL_FOG_UTIL__
465
466 vec4 getFogLinear(in vec4 diffuseColor, in vec4 fogColor, in float start, in float end, in float distance) {
467
468 float fogFactor = (end - distance) / (end - start);
469 fogFactor = clamp(fogFactor, 0.0, 1.0);
470
471 return mix(fogColor, diffuseColor, fogFactor);
472 }
473
474 vec4 getFogExp(in vec4 diffuseColor, in vec4 fogColor, in float fogDensity, in float distance) {
475
476 float fogFactor = 1.0 / exp(distance * fogDensity);
477 fogFactor = clamp( fogFactor, 0.0, 1.0 );
478
479 return mix(fogColor, diffuseColor, fogFactor);
480 }
481
482 vec4 getFogExpSquare(in vec4 diffuseColor, in vec4 fogColor, in float fogDensity, in float distance) {
483
484 float fogFactor = 1.0 / exp( (distance * fogDensity) * (distance * fogDensity));
485 fogFactor = clamp( fogFactor, 0.0, 1.0 );
486
487 vec4 finalColor = mix(fogColor, diffuseColor, fogFactor);
488 return finalColor;
489 }
490
491 #if defined(USE_FOG)
492 uniform vec4 m_FogColor;
493 varying float fogDistance;
494
495 uniform vec2 m_LinearFog;
496
497 #ifdef FOG_EXP
498 uniform float m_ExpFog;
499 #endif
500
501 #ifdef FOG_EXPSQ
502 uniform float m_ExpSqFog;
503 #endif
504
505 vec4 MaterialFog_calculateFogColor(in vec4 fragColor){
506 #ifdef FOG_LINEAR
507 fragColor = getFogLinear(fragColor, m_FogColor, m_LinearFog.x, m_LinearFog.y, fogDistance);
508 #endif
509 #ifdef FOG_EXP
510 fragColor = getFogExp(fragColor, m_FogColor, m_ExpFog, fogDistance);
511 #endif
512 #ifdef FOG_EXPSQ
513 fragColor = getFogExpSquare(fragColor, m_FogColor, m_ExpSqFog, fogDistance);
514 #endif
515
516 return fragColor;
517 }
518
519 #endif
520 #endif
521 // -- end import Common/ShaderLib/MaterialFog.glsllib --
522 varying float fog_distance;
523 uniform vec4 m_FogColor;
524
525 #ifdef FOG_LINEAR
526 uniform vec2 m_LinearFog;
527 #endif
528
529 #ifdef FOG_EXP
530 uniform float m_ExpFog;
531 #endif
532
533 #ifdef FOG_EXPSQ
534 uniform float m_ExpSqFog;
535 #endif
536
537 #endif // end fog
538
539 varying vec2 texCoord;
540 #ifdef SEPARATE_TEXCOORD
541 varying vec2 texCoord2;
542 #endif
543
544 varying vec3 AmbientSum;
545 varying vec4 DiffuseSum;
546 varying vec3 SpecularSum;
547
548 #ifndef VERTEX_LIGHTING
549 uniform mat4 g_ViewMatrix;
550 uniform vec4 g_LightData[NB_LIGHTS];
551 uniform int g_LightCount;
552 varying vec3 vPos;
553 #endif
554
555 #ifdef DIFFUSEMAP
556 uniform sampler2D m_DiffuseMap;
557 #endif
558
559 #ifdef SPECULARMAP
560 uniform sampler2D m_SpecularMap;
561 #endif
562
563 #ifdef PARALLAXMAP
564 uniform sampler2D m_ParallaxMap;
565 #endif
566 #if (defined(PARALLAXMAP) || (defined(NORMALMAP_PARALLAX) && defined(NORMALMAP))) && !defined(VERTEX_LIGHTING)
567 uniform float m_ParallaxHeight;
568 #endif
569
570 #ifdef LIGHTMAP
571 uniform sampler2D m_LightMap;
572 #endif
573
574 #ifdef NORMALMAP
575 uniform sampler2D m_NormalMap;
576 varying vec4 vTangent;
577 #endif
578 varying vec3 vNormal;
579
580 #ifdef ALPHAMAP
581 uniform sampler2D m_AlphaMap;
582 #endif
583
584 #ifdef COLORRAMP
585 uniform sampler2D m_ColorRamp;
586 #endif
587
588 uniform float m_AlphaDiscardThreshold;
589
590 #ifndef VERTEX_LIGHTING
591 uniform float m_Shininess;
592
593 #ifdef USE_REFLECTION
594 uniform float m_ReflectionPower;
595 uniform float m_ReflectionIntensity;
596 varying vec4 refVec;
597
598 uniform ENVMAP m_EnvMap;
599 #endif
600 #endif
601
602 #ifndef NORMAL_TYPE
603 #define NORMAL_TYPE -1.0
604 #endif
605
606 void main(){
607 #if !defined(VERTEX_LIGHTING)
608 #if defined(NORMALMAP)
609 vec3 tbnNormal = normalize(vNormal.xyz);
610 vec3 tbnTangent = normalize(vTangent.xyz - tbnNormal * dot(vTangent.xyz, tbnNormal));
611 vec3 tbnBinormal = normalize(cross(tbnNormal, tbnTangent)) * vTangent.w;
612 mat3 tbnMat = mat3(tbnTangent, tbnBinormal, tbnNormal);
613
614 if (!gl_FrontFacing)
615 {
616 tbnMat[2] = -tbnMat[2];
617 }
618
619 vec3 viewDir = normalize(-vPos.xyz * tbnMat);
620 #else
621 vec3 viewDir = normalize(-vPos.xyz);
622 #endif
623 #endif
624
625 vec2 newTexCoord;
626
627 #if (defined(PARALLAXMAP) || (defined(NORMALMAP_PARALLAX) && defined(NORMALMAP))) && !defined(VERTEX_LIGHTING)
628
629 #ifdef STEEP_PARALLAX
630 #ifdef NORMALMAP_PARALLAX
631 //parallax map is stored in the alpha channel of the normal map
632 newTexCoord = steepParallaxOffset(m_NormalMap, viewDir, texCoord, m_ParallaxHeight);
633 #else
634 //parallax map is a texture
635 newTexCoord = steepParallaxOffset(m_ParallaxMap, viewDir, texCoord, m_ParallaxHeight);
636 #endif
637 #else
638 #ifdef NORMALMAP_PARALLAX
639 //parallax map is stored in the alpha channel of the normal map
640 newTexCoord = classicParallaxOffset(m_NormalMap, viewDir, texCoord, m_ParallaxHeight);
641 #else
642 //parallax map is a texture
643 newTexCoord = classicParallaxOffset(m_ParallaxMap, viewDir, texCoord, m_ParallaxHeight);
644 #endif
645 #endif
646 #else
647 newTexCoord = texCoord;
648 #endif
649
650 #ifdef DIFFUSEMAP
651 vec4 diffuseColor = texture2D(m_DiffuseMap, newTexCoord);
652 #else
653 vec4 diffuseColor = vec4(1.0);
654 #endif
655
656 float alpha = DiffuseSum.a * diffuseColor.a;
657
658 #ifdef ALPHAMAP
659 alpha = alpha * texture2D(m_AlphaMap, newTexCoord).r;
660 #endif
661
662 #ifdef DISCARD_ALPHA
663 if(alpha < m_AlphaDiscardThreshold){
664 discard;
665 }
666 #endif
667
668 // ***********************
669 // Read from textures
670 // ***********************
671 #if defined(NORMALMAP) && !defined(VERTEX_LIGHTING)
672 vec4 normalHeight = texture2D(m_NormalMap, newTexCoord);
673 vec3 normal = normalize((normalHeight.xyz * vec3(2.0, NORMAL_TYPE * 2.0 ,2.0) - vec3(1.0, NORMAL_TYPE * 1.0,1.0)));
674 #elif !defined(VERTEX_LIGHTING)
675 vec3 normal = normalize(vNormal);
676
677 if (!gl_FrontFacing)
678 {
679 normal = -normal;
680 }
681 #endif
682
683 #ifdef SPECULARMAP
684 vec4 specularColor = texture2D(m_SpecularMap, newTexCoord);
685 #else
686 vec4 specularColor = vec4(1.0);
687 #endif
688
689 #ifdef LIGHTMAP
690 vec3 lightMapColor;
691 #ifdef SEPARATE_TEXCOORD
692 lightMapColor = texture2D(m_LightMap, texCoord2).rgb;
693 #else
694 lightMapColor = texture2D(m_LightMap, texCoord).rgb;
695 #endif
696 specularColor.rgb *= lightMapColor;
697 diffuseColor.rgb *= lightMapColor;
698 #endif
699
700 #ifdef VERTEX_LIGHTING
701 gl_FragColor.rgb = AmbientSum.rgb * diffuseColor.rgb
702 + DiffuseSum.rgb * diffuseColor.rgb
703 + SpecularSum.rgb * specularColor.rgb;
704 #else
705
706 int i = 0;
707 gl_FragColor.rgb = AmbientSum * diffuseColor.rgb;
708
709 #ifdef USE_REFLECTION
710 vec4 refColor = Optics_GetEnvColor(m_EnvMap, refVec.xyz);
711 #endif
712
713 for( int i = 0;i < NB_LIGHTS; i+=3){
714 #if (defined(GL_ES) && __VERSION__ >= 300) || (!defined(GL_ES) && __VERSION__ >= 150)
715 if(i >= g_LightCount * 3){
716 break;
717 }
718 #endif
719 vec4 lightColor = g_LightData[i];
720 vec4 lightData1 = g_LightData[i+1];
721 vec4 lightDir;
722 vec3 lightVec;
723 lightComputeDir(vPos, lightColor.w, lightData1, lightDir,lightVec);
724
725 float spotFallOff = 1.0;
726 #if __VERSION__ >= 110
727 // allow use of control flow
728 if(lightColor.w > 1.0){
729 #endif
730 spotFallOff = computeSpotFalloff(g_LightData[i+2], lightVec);
731 #if __VERSION__ >= 110
732 }
733 #endif
734
735 #ifdef NORMALMAP
736 //Normal map -> lighting is computed in tangent space
737 lightDir.xyz = normalize(lightDir.xyz * tbnMat);
738 #else
739 //no Normal map -> lighting is computed in view space
740 lightDir.xyz = normalize(lightDir.xyz);
741 #endif
742
743 vec2 light = computeLighting(normal, viewDir, lightDir.xyz, lightDir.w * spotFallOff , m_Shininess);
744
745 // Workaround, since it is not possible to modify varying variables
746 vec4 SpecularSum2 = vec4(SpecularSum, 1.0);
747 #ifdef USE_REFLECTION
748 // Interpolate light specularity toward reflection color
749 // Multiply result by specular map
750 specularColor = mix(SpecularSum2 * light.y, refColor, refVec.w) * specularColor;
751
752 SpecularSum2 = vec4(1.0);
753 light.y = 1.0;
754 #endif
755
756 vec3 DiffuseSum2 = DiffuseSum.rgb;
757 #ifdef COLORRAMP
758 DiffuseSum2.rgb *= texture2D(m_ColorRamp, vec2(light.x, 0.0)).rgb;
759 SpecularSum2.rgb *= texture2D(m_ColorRamp, vec2(light.y, 0.0)).rgb;
760 light.xy = vec2(1.0);
761 #endif
762
763 gl_FragColor.rgb += DiffuseSum2.rgb * lightColor.rgb * diffuseColor.rgb * vec3(light.x) +
764 SpecularSum2.rgb * lightColor.rgb * specularColor.rgb * vec3(light.y);
765 }
766
767 #endif
768
769 // add fog after the lighting because shadows will cause the fog to darken
770 // which just results in the geometry looking like it's changed color
771 #ifdef USE_FOG
772 #ifdef FOG_LINEAR
773 gl_FragColor = getFogLinear(gl_FragColor, m_FogColor, m_LinearFog.x, m_LinearFog.y, fog_distance);
774 #endif
775 #ifdef FOG_EXP
776 gl_FragColor = getFogExp(gl_FragColor, m_FogColor, m_ExpFog, fog_distance);
777 #endif
778 #ifdef FOG_EXPSQ
779 gl_FragColor = getFogExpSquare(gl_FragColor, m_FogColor, m_ExpSqFog, fog_distance);
780 #endif
781 #endif // end fog
782
783 gl_FragColor.a = alpha;
784 }
Mar 26, 2026 10:44:24 PM com.jme3.app.LegacyApplication handleError
SEVERE: Uncaught exception thrown in Thread[#21,jME3 Main,5,main]
com.jme3.renderer.RendererException: compile error in: ShaderSource[name=Common/MatDefs/Light/SPLighting.frag, defines, type=Fragment, language=GLSL150]
0(523) : error C1038: declaration of "m_FogColor" conflicts with previous declaration at 0(492)
0(526) : error C1038: declaration of "m_LinearFog" conflicts with previous declaration at 0(495)
at com.jme3.renderer.opengl.GLRenderer.updateShaderSourceData(GLRenderer.java:1662)
at com.jme3.renderer.opengl.GLRenderer.updateShaderData(GLRenderer.java:1689)
at com.jme3.renderer.opengl.GLRenderer.setShader(GLRenderer.java:1754)
at com.jme3.material.logic.SinglePassLightingLogic.render(SinglePassLightingLogic.java:223)
at com.jme3.material.Technique.render(Technique.java:168)
at com.jme3.material.Material.render(Material.java:1122)
at com.jme3.renderer.RenderManager.renderGeometry(RenderManager.java:874)
at com.jme3.renderer.RenderManager.renderGeometry(RenderManager.java:780)
at com.jme3.renderer.queue.RenderQueue.renderGeometryList(RenderQueue.java:273)
at com.jme3.renderer.queue.RenderQueue.renderQueue(RenderQueue.java:315)
at com.jme3.renderer.RenderManager.renderViewPortQueues(RenderManager.java:1209)
at com.jme3.renderer.RenderManager.flushQueue(RenderManager.java:1046)
at com.jme3.renderer.pipeline.ForwardPipeline.pipelineRender(ForwardPipeline.java:117)
at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:1406)
at com.jme3.renderer.RenderManager.render(RenderManager.java:1448)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:354)
at com.jme3.system.lwjgl.LwjglWindow.runLoop(LwjglWindow.java:729)
at com.jme3.system.lwjgl.LwjglWindow.run(LwjglWindow.java:819)
at java.base/java.lang.Thread.run(Thread.java:1583)
Mar 26, 2026 10:44:24 PM com.jme3.system.JmeSystemDelegate lambda$new$0
WARNING: JmeDialogsFactory implementation not found.
Uncaught exception thrown in Thread[#21,jME3 Main,5,main]
RendererException: compile error in: ShaderSource[name=Common/MatDefs/Light/SPLighting.frag, defines, type=Fragment, language=GLSL150]
0(523) : error C1038: declaration of "m_FogColor" conflicts with previous declaration at 0(492)
0(526) : error C1038: declaration of "m_LinearFog" conflicts with previous declaration at 0(495)Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
tracked