Skip to content

compile error in Common/MatDefs/Light/Lighting.frag #2363

@stephengold

Description

@stephengold

Here's another regression in JME v3.8.0-alpha3. I discovered it while running the FC3D application in the Fuze Creek project. Immediately after starting the application, it crashes with the following console output:

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

Feb 05, 2025 9:11:04 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/Light/Lighting.frag, defines, type=Fragment, language=GLSL150]
0(519) : error C1038: declaration of "m_FogColor" conflicts with previous declaration at 0(487)
0(522) : error C1038: declaration of "m_LinearFog" conflicts with previous declaration at 0(490)

	at com.jme3.renderer.opengl.GLRenderer.updateShaderSourceData(GLRenderer.java:1659)
	at com.jme3.renderer.opengl.GLRenderer.updateShaderData(GLRenderer.java:1686)
	at com.jme3.renderer.opengl.GLRenderer.setShader(GLRenderer.java:1751)
	at com.jme3.material.logic.MultiPassLightingLogic.render(MultiPassLightingLogic.java:159)
	at com.jme3.material.Technique.render(Technique.java:168)
	at com.jme3.material.Material.render(Material.java:1099)
	at com.jme3.renderer.RenderManager.renderGeometry(RenderManager.java:842)
	at com.jme3.renderer.RenderManager.renderGeometry(RenderManager.java:772)
	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:1117)
	at com.jme3.renderer.RenderManager.flushQueue(RenderManager.java:1012)
	at com.jme3.renderer.pipeline.ForwardPipeline.pipelineRender(ForwardPipeline.java:117)
	at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:1313)
	at com.jme3.renderer.RenderManager.render(RenderManager.java:1355)
	at com.jme3.app.SimpleApplication.update(SimpleApplication.java:283)
	at com.jme3.system.lwjgl.LwjglWindow.runLoop(LwjglWindow.java:707)
	at com.jme3.system.lwjgl.LwjglWindow.run(LwjglWindow.java:797)
	at java.base/java.lang.Thread.run(Thread.java:840)

Feb 05, 2025 9:11:04 PM com.jme3.system.JmeSystemDelegate lambda$new$0
WARNING: JmeDialogsFactory implementation not found.
Uncaught exception thrown in Thread[jME3 Main,5,main]
RendererException: compile error in: ShaderSource[name=Common/MatDefs/Light/Lighting.frag, defines, type=Fragment, language=GLSL150]
0(519) : error C1038: declaration of "m_FogColor" conflicts with previous declaration at 0(487)
0(522) : error C1038: declaration of "m_LinearFog" conflicts with previous declaration at 0(490)

If I rebuild using v3.8.0-alpha2, the application runs correctly and does not crash.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething that is supposed to work, but doesn't. More severe than a "defect".

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions