-
Notifications
You must be signed in to change notification settings - Fork 5
/
nohup.out
15322 lines (9402 loc) · 779 KB
/
nohup.out
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
lib: 1
lic: 1
CoppeliaSim Edu V4.0.0. (rev. 4)
Using the default Lua library.
Loaded the video compression library.
Add-on script 'simAddOnScript-addOnScriptDemo.lua' was loaded.
Add-on script 'simAddOnScript-b0RemoteApiServer.lua' was loaded.
Add-on script 'simAddOnScript_PyRep.lua' was loaded.
If CoppeliaSim crashes now, try to install libgl1-mesa-dev on your system:
>sudo apt install libgl1-mesa-dev
OpenGL: Parallels and ATI Technologies Inc., Renderer: Parallels using AMD Radeon Pro 560X OpenGL Engine, Version: 2.1 ATI-3.5.5
...did not crash.
Simulator launched.
Plugin 'Geometric': loading...
Plugin 'Geometric': load succeeded.
Plugin 'Assimp': loading...
Plugin 'Assimp': warning: replaced variable 'simAssimp'
Plugin 'Assimp': load succeeded.
Plugin 'BlueZero': loading...
Plugin 'BlueZero': warning: replaced variable 'simB0'
Plugin 'BlueZero': load succeeded.
Plugin 'BubbleRob': loading...
Plugin 'BubbleRob': load succeeded.
Plugin 'Bwf': loading...
Plugin 'Bwf': load succeeded.
Plugin 'CodeEditor': loading...
Plugin 'CodeEditor': load succeeded.
Plugin 'Collada': loading...
Plugin 'Collada': load succeeded.
Plugin 'ConvexDecompose': loading...
Plugin 'ConvexDecompose': load succeeded.
Plugin 'CustomUI': loading...
Plugin 'CustomUI': warning: replaced variable 'simUI'
Plugin 'CustomUI': warning: replaced function 'simUI.insertTableRow@CustomUI'
Plugin 'CustomUI': warning: replaced function 'simUI.removeTableRow@CustomUI'
Plugin 'CustomUI': warning: replaced function 'simUI.insertTableColumn@CustomUI'
Plugin 'CustomUI': warning: replaced function 'simUI.removeTableColumn@CustomUI'
Plugin 'CustomUI': warning: replaced function 'simUI.setScene3DNodeParam@CustomUI'
Plugin 'CustomUI': load succeeded.
Plugin 'DynamicsBullet-2-78': loading...
Plugin 'DynamicsBullet-2-78': load succeeded.
Plugin 'DynamicsBullet-2-83': loading...
Plugin 'DynamicsBullet-2-83': load succeeded.
Plugin 'DynamicsNewton': loading...
Plugin 'DynamicsNewton': load succeeded.
Plugin 'DynamicsOde': loading...
Plugin 'DynamicsOde': load succeeded.
Plugin 'DynamicsVortex': loading...
Plugin 'DynamicsVortex': load succeeded.
Plugin 'ExternalRenderer': loading...
Plugin 'ExternalRenderer': load succeeded.
Plugin 'ICP': loading...
Plugin 'ICP': warning: replaced variable 'simICP'
Plugin 'ICP': load succeeded.
Plugin 'Image': loading...
Plugin 'Image': warning: replaced variable 'simIM'
Plugin 'Image': load succeeded.
Plugin 'K3': loading...
Plugin 'K3': load succeeded.
Plugin 'Lic': loading...
Plugin 'Lic': load succeeded.
Plugin 'LuaCommander': loading...
Plugin 'LuaCommander': warning: replaced variable 'simLuaCmd'
Plugin 'LuaCommander': load succeeded.
Plugin 'LuaRemoteApiClient': loading...
Plugin 'LuaRemoteApiClient': load succeeded.
Plugin 'Mtb': loading...
Plugin 'Mtb': load succeeded.
Plugin 'OMPL': loading...
Plugin 'OMPL': warning: replaced variable 'simOMPL'
Plugin 'OMPL': load succeeded.
Plugin 'OpenGL3Renderer': loading...
Plugin 'OpenGL3Renderer': load succeeded.
Plugin 'OpenMesh': loading...
Plugin 'OpenMesh': load succeeded.
Plugin 'Qhull': loading...
Plugin 'Qhull': load succeeded.
Plugin 'RRS1': loading...
Plugin 'RRS1': load succeeded.
Plugin 'ReflexxesTypeII': loading...
Plugin 'ReflexxesTypeII': load succeeded.
Plugin 'RemoteApi': loading...
Starting a remote API server on port 19997
Plugin 'RemoteApi': load succeeded.
Plugin 'SDF': loading...
Plugin 'SDF': warning: replaced variable 'simSDF'
Plugin 'SDF': load succeeded.
Plugin 'SurfaceReconstruction': loading...
Plugin 'SurfaceReconstruction': warning: replaced variable 'simSurfRec'
Plugin 'SurfaceReconstruction': load succeeded.
Plugin 'Urdf': loading...
Plugin 'Urdf': load succeeded.
Plugin 'Vision': loading...
Plugin 'Vision': load succeeded.
Using the 'Geometric' plugin.
Initializing the Bullet physics engine in plugin 'DynamicsBullet_2_83'...
Engine version: 2.83.7
Plugin version: 11
Initialization successful.
This renderer requires atleast OpenGL 3.2. The version available is: 2.1 ATI-3.5.5
QOpenGLShader::compile(Vertex): ERROR: 0:1: '' : version '330' is not supported
ERROR: 0:1: '' : syntax error: #version
ERROR: 0:2: 'layout' : syntax error: syntax error
*** Problematic Vertex shader source code ***
#version 330 core
#define lowp
#define mediump
#define highp
#line 1
layout (location = 0) in vec3 aPos;
layout (location = 1) in vec3 aNormal;
layout (location = 2) in vec2 aTexCoords;
out vec3 FragPos;
out vec3 Normal;
out vec2 TexCoords;
uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;
void main()
{
FragPos = vec3(model * vec4(aPos, 1.0));
Normal = mat3(transpose(inverse(model))) * aNormal;
TexCoords = aTexCoords;
gl_Position = projection * view * model * vec4(aPos, 1.0);
}
***
"ERROR: 0:1: '' : version '330' is not supported\nERROR: 0:1: '' : syntax error: #version\nERROR: 0:2: 'layout' : syntax error: syntax error\n"
QOpenGLShader::compile(Fragment): ERROR: 0:1: '' : version '330' is not supported
ERROR: 0:1: '' : syntax error: #version
ERROR: 0:108: '(' : syntax error: Array size must appear after variable name
*** Problematic Fragment shader source code ***
#version 330 core
#ifdef GL_KHR_blend_equation_advanced
#extension GL_ARB_fragment_coord_conventions : enable
#extension GL_KHR_blend_equation_advanced : enable
#endif
#define lowp
#define mediump
#define highp
#line 1
struct Material {
vec4 ambient;
vec3 diffuse;
vec3 specular;
float shininess;
};
struct DirLight {
vec3 position; // specifically for shadows
vec3 direction;
// vec3 ambient;
vec3 diffuse;
vec3 specular;
mat4 lightSpaceMatrix;
sampler2D shadowMap;
float bias;
float normalBias;
};
struct PointLight {
vec3 position;
float constant;
float linear;
float quadratic;
// vec3 ambient;
vec3 diffuse;
vec3 specular;
float farPlane;
float bias;
float normalBias;
};
struct SpotLight {
vec3 position;
vec3 direction;
float cutOff;
float outerCutOff;
float constant;
float linear;
float quadratic;
// vec3 ambient;
vec3 diffuse;
vec3 specular;
mat4 lightSpaceMatrix;
sampler2D shadowMap;
float bias;
float normalBias;
};
out vec4 FragColor;
in vec3 FragPos;
in vec3 Normal;
in vec2 TexCoords;
uniform sampler2D texture0;
uniform int textureApplyMode;
uniform vec3 sceneAmbient;
uniform vec3 viewPos;
// Some graphics cards appear not to support arrays. One way around this is to explicitly roll out the array.
#define MAX_LIGHTS 5
uniform DirLight dirLight0;
uniform DirLight dirLight1;
uniform DirLight dirLight2;
uniform DirLight dirLight3;
uniform DirLight dirLight4;
uniform PointLight pointLight0;
uniform PointLight pointLight1;
uniform PointLight pointLight2;
uniform PointLight pointLight3;
uniform PointLight pointLight4;
uniform SpotLight spotLight0;
uniform SpotLight spotLight1;
uniform SpotLight spotLight2;
uniform SpotLight spotLight3;
uniform SpotLight spotLight4;
// For some reason, we are not allowed to store samplerCube in structs or arrays
// So allow a max of 5
uniform samplerCube depthCubeMap0;
uniform samplerCube depthCubeMap1;
uniform samplerCube depthCubeMap2;
uniform samplerCube depthCubeMap3;
uniform samplerCube depthCubeMap4;
uniform int dirLightLen;
uniform int pointLightLen;
uniform int spotLightLen;
uniform Material material;
// array of offset direction for sampling in pointlight shadows
vec3 gridSamplingDisk[20] = vec3[]
(
vec3(1, 1, 1), vec3( 1, -1, 1), vec3(-1, -1, 1), vec3(-1, 1, 1),
vec3(1, 1, -1), vec3( 1, -1, -1), vec3(-1, -1, -1), vec3(-1, 1, -1),
vec3(1, 1, 0), vec3( 1, -1, 0), vec3(-1, -1, 0), vec3(-1, 1, 0),
vec3(1, 0, 1), vec3(-1, 0, 1), vec3( 1, 0, -1), vec3(-1, 0, -1),
vec3(0, 1, 1), vec3( 0, -1, 1), vec3( 0, -1, -1), vec3( 0, 1, -1)
);
// function prototypes
vec3 CalcDirLight(DirLight light, vec3 normal, vec3 viewDir);
vec3 CalcPointLight(PointLight light, vec3 normal, vec3 fragPos, vec3 viewDir);
vec3 CalcSpotLight(SpotLight light, vec3 normal, vec3 fragPos, vec3 viewDir);
float ShadowCalculation(mat4 lightSpaceMatrix, vec3 lightPos, sampler2D shadowMap, float bias, float normalBias);
float PointShadowCalculation(vec3 lightPos, samplerCube cubeMap, float farPlane, float bias, float normalBias);
void main()
{
// Lighting properties
vec3 norm = normalize(Normal);
vec3 viewDir = normalize(viewPos - FragPos);
// Give it some intial ambient light
vec4 ambient = texture(texture0, TexCoords);
// textureApplyMode 1 (GL_DECAL) gets applied later.
if (textureApplyMode == 2) // ADD
ambient = (ambient + material.ambient, 1.0) * vec4(sceneAmbient, 1.0);
else if (textureApplyMode == 1)
ambient = material.ambient;
else if (textureApplyMode != 1)
// In this case, we either have no texture, or we want to use GL_BLEND.
ambient *= material.ambient * vec4(sceneAmbient, 1.0);
vec3 result = vec3(0.0);
// phase 1: directional lighting
for(int i = 0; i < dirLightLen && i < MAX_LIGHTS; i++)
{
vec3 lresult;
float shadow = 0.0;
// We are not allowed to store the struct in a temp, apparently.
if (i == 0){
lresult = CalcDirLight(dirLight0, norm, viewDir);
shadow = ShadowCalculation(dirLight0.lightSpaceMatrix, dirLight0.position, dirLight0.shadowMap, dirLight0.bias, dirLight0.normalBias);
} else if (i == 1){
lresult = CalcDirLight(dirLight1, norm, viewDir);
shadow = ShadowCalculation(dirLight1.lightSpaceMatrix, dirLight1.position, dirLight1.shadowMap, dirLight1.bias, dirLight1.normalBias);
} else if (i == 2){
lresult = CalcDirLight(dirLight2, norm, viewDir);
shadow = ShadowCalculation(dirLight2.lightSpaceMatrix, dirLight2.position, dirLight2.shadowMap, dirLight2.bias, dirLight2.normalBias);
} else if (i == 3){
lresult = CalcDirLight(dirLight3, norm, viewDir);
shadow = ShadowCalculation(dirLight3.lightSpaceMatrix, dirLight3.position, dirLight3.shadowMap, dirLight3.bias, dirLight3.normalBias);
} else if (i == 4){
lresult = CalcDirLight(dirLight4, norm, viewDir);
shadow = ShadowCalculation(dirLight4.lightSpaceMatrix, dirLight4.position, dirLight4.shadowMap, dirLight4.bias, dirLight4.normalBias);
}
result += lresult * (1.0 - shadow);
}
// phase 2: point lights
for(int i = 0; i < pointLightLen && i < MAX_LIGHTS; i++)
{
vec3 lresult;
float shadow = 0.0;
if (i == 0){
lresult = CalcPointLight(pointLight0, norm, FragPos, viewDir);
shadow = PointShadowCalculation(pointLight0.position, depthCubeMap0, pointLight0.farPlane, pointLight0.bias, pointLight0.normalBias);
}else if (i == 1){
lresult = CalcPointLight(pointLight1, norm, FragPos, viewDir);
shadow = PointShadowCalculation(pointLight1.position, depthCubeMap1, pointLight1.farPlane, pointLight1.bias, pointLight1.normalBias);
}else if (i == 2){
lresult = CalcPointLight(pointLight2, norm, FragPos, viewDir);
shadow = PointShadowCalculation(pointLight2.position, depthCubeMap2, pointLight2.farPlane, pointLight2.bias, pointLight2.normalBias);
}else if (i == 3){
lresult = CalcPointLight(pointLight3, norm, FragPos, viewDir);
shadow = PointShadowCalculation(pointLight3.position, depthCubeMap3, pointLight3.farPlane, pointLight3.bias, pointLight3.normalBias);
}else if (i == 4){
lresult = CalcPointLight(pointLight4, norm, FragPos, viewDir);
shadow = PointShadowCalculation(pointLight4.position, depthCubeMap4, pointLight4.farPlane, pointLight4.bias, pointLight4.normalBias);
}
result += lresult * (1.0 - shadow);
}
// phase 3: spot light
for(int i = 0; i < spotLightLen && i < MAX_LIGHTS; i++)
{
vec3 lresult;
float shadow = 0.0;
// We are not allowed to store the struct in a temp, apparently.
if (i == 0){
lresult = CalcSpotLight(spotLight0, norm, FragPos, viewDir);
shadow = ShadowCalculation(spotLight0.lightSpaceMatrix, spotLight0.position, spotLight0.shadowMap, spotLight0.bias, spotLight0.normalBias);
} else if (i == 1){
lresult = CalcSpotLight(spotLight1, norm, FragPos, viewDir);
shadow = ShadowCalculation(spotLight1.lightSpaceMatrix, spotLight1.position, spotLight1.shadowMap, spotLight1.bias, spotLight1.normalBias);
} else if (i == 2){
lresult = CalcSpotLight(spotLight2, norm, FragPos, viewDir);
shadow = ShadowCalculation(spotLight2.lightSpaceMatrix, spotLight2.position, spotLight2.shadowMap, spotLight2.bias, spotLight2.normalBias);
} else if (i == 3){
lresult = CalcSpotLight(spotLight3, norm, FragPos, viewDir);
shadow = ShadowCalculation(spotLight3.lightSpaceMatrix, spotLight3.position, spotLight3.shadowMap, spotLight3.bias, spotLight3.normalBias);
} else if (i == 4){
lresult = CalcSpotLight(spotLight4, norm, FragPos, viewDir);
shadow = ShadowCalculation(spotLight4.lightSpaceMatrix, spotLight4.position, spotLight4.shadowMap, spotLight4.bias, spotLight4.normalBias);
}
result += lresult * (1.0 - shadow);
}
FragColor = ambient + vec4(result, 0.0);
if (textureApplyMode == 1){
// textureApplyMode == 1 is DECAL
vec4 coltex = texture(texture0, TexCoords.st);
vec3 col = FragColor.rgb * (1.0-coltex.a) + coltex.rgb * coltex.a;
FragColor = vec4(col, FragColor.a);
}
}
// calculates the color when using a directional light.
vec3 CalcDirLight(DirLight light, vec3 normal, vec3 viewDir)
{
vec3 lightDir = normalize(-light.direction);
// diffuse shading
float diff = max(dot(normal, lightDir), 0.0);
// specular shading (Phong)
vec3 reflectDir = reflect(-lightDir, normal);
float spec = pow(max(dot(viewDir, reflectDir), 0.0), material.shininess);
// specular shading (Blinn-Phong)
// vec3 halfwayDir = normalize(lightDir + viewDir);
// float spec = pow(max(dot(normal, halfwayDir), 0.0), material.shininess);
// combine results
vec3 diffuse = light.diffuse * (diff * (vec3(texture(texture0, TexCoords)) * material.diffuse));
vec3 specular = light.specular * (spec * (vec3(texture(texture0, TexCoords)) * material.specular));
return (diffuse + specular);
}
// calculates the color when using a point light.
vec3 CalcPointLight(PointLight light, vec3 normal, vec3 fragPos, vec3 viewDir)
{
vec3 lightDir = normalize(light.position - fragPos);
// diffuse shading
float diff = max(dot(normal, lightDir), 0.0);
// specular shading
vec3 reflectDir = reflect(-lightDir, normal);
float spec = pow(max(dot(viewDir, reflectDir), 0.0), material.shininess);
// attenuation
float distance = length(light.position - fragPos);
float attenuation = 1.0 / (light.constant + light.linear * distance + light.quadratic * (distance * distance));
// combine results
vec3 diffuse = light.diffuse * (diff * material.diffuse);
vec3 specular = light.specular * (spec * material.specular);
diffuse *= attenuation;
specular *= attenuation;
return (diffuse + specular);
}
// calculates the color when using a spot light.
vec3 CalcSpotLight(SpotLight light, vec3 normal, vec3 fragPos, vec3 viewDir)
{
vec3 lightDir = normalize(light.position - fragPos);
// diffuse shading
float diff = max(dot(normal, lightDir), 0.0);
// specular shading
vec3 reflectDir = reflect(-lightDir, normal);
float spec = pow(max(dot(viewDir, reflectDir), 0.0), material.shininess);
// attenuation
float distance = length(light.position - fragPos);
float attenuation = 1.0 / (light.constant + light.linear * distance + light.quadratic * (distance * distance));
// spotlight intensity
float theta = dot(lightDir, normalize(-light.direction));
float epsilon = light.cutOff - light.outerCutOff;
float intensity = clamp((theta - light.outerCutOff) / epsilon, 0.0, 1.0);
// combine results
vec3 diffuse = light.diffuse * (diff * material.diffuse);
vec3 specular = light.specular * (spec * material.specular);
diffuse *= attenuation * intensity;
specular *= attenuation * intensity;
return (diffuse + specular);
}
float ShadowCalculation(mat4 lightSpaceMatrix, vec3 lightPos, sampler2D shadowMap, float bias, float normalBias)
{
vec4 fragPosLightSpace = lightSpaceMatrix * vec4(FragPos, 1.0);
// perform perspective divide
vec3 projCoords = fragPosLightSpace.xyz / fragPosLightSpace.w;
// transform to [0,1] range
projCoords = projCoords * 0.5 + 0.5;
// get closest depth value from light's perspective (using [0,1] range fragPosLight as coords)
float closestDepth = texture(shadowMap, projCoords.xy).r;
// get depth of current fragment from light's perspective
float currentDepth = projCoords.z;
// calculate bias (based on depth map resolution and slope)
vec3 normal = normalize(Normal);
vec3 lightDir = normalize(lightPos - FragPos);
bias = max(normalBias * (1.0 - dot(normal, lightDir)), bias);
// check whether current frag pos is in shadow
// PCF
float shadow = 0.0;
vec2 texelSize = 1.0 / textureSize(shadowMap, 0);
for(int x = -1; x <= 1; ++x)
{
for(int y = -1; y <= 1; ++y)
{
float pcfDepth = texture(shadowMap, projCoords.xy + vec2(x, y) * texelSize).r;
shadow += currentDepth - bias > pcfDepth ? 1.0 : 0.0;
}
}
shadow /= 9.0;
// keep the shadow at 0.0 when outside the far_plane region of the light's frustum.
if(projCoords.z > 1.0)
shadow = 0.0;
return shadow;
}
float PointShadowCalculation(vec3 lightPos, samplerCube cubeMap, float farPlane, float bias, float normalBias)
{
// get vector between fragment position and light position
vec3 fragToLight = FragPos - lightPos;
float currentDepth = length(fragToLight);
float shadow = 0.0;
// Bias calc
vec3 normal = normalize(Normal);
vec3 lightDir = normalize(lightPos - FragPos);
bias = max(normalBias * (1.0 - dot(normal, lightDir)), bias);
int samples = 20;
float viewDistance = length(viewPos - FragPos);
float diskRadius = (1.0 + (viewDistance / farPlane)) / 500.0;
for(int i = 0; i < samples; i++)
{
float closestDepth = texture(cubeMap, fragToLight + gridSamplingDisk[i] * diskRadius).r;
closestDepth *= farPlane; // undo mapping [0;1]
if((currentDepth - bias) > closestDepth){
shadow += 1.0;
}
}
shadow /= float(samples);
return shadow;
}
***
"ERROR: 0:1: '' : version '330' is not supported\nERROR: 0:1: '' : syntax error: #version\nERROR: 0:108: '(' : syntax error: Array size must appear after variable name\n"
QOpenGLShader::compile(Vertex): ERROR: 0:1: '' : version '330' is not supported
ERROR: 0:1: '' : syntax error: #version
ERROR: 0:2: 'layout' : syntax error: syntax error
*** Problematic Vertex shader source code ***
#version 330 core
#define lowp
#define mediump
#define highp
#line 1
layout (location = 0) in vec3 aPos;
layout (location = 1) in vec3 aNormal;
layout (location = 2) in vec2 aTexCoords;
uniform mat4 lightSpaceMatrix;
uniform mat4 model;
void main()
{
gl_Position = lightSpaceMatrix * model * vec4(aPos, 1.0);
}
***
"ERROR: 0:1: '' : version '330' is not supported\nERROR: 0:1: '' : syntax error: #version\nERROR: 0:2: 'layout' : syntax error: syntax error\n"
QOpenGLShader::compile(Fragment): ERROR: 0:1: '' : version '330' is not supported
ERROR: 0:1: '' : syntax error: #version
*** Problematic Fragment shader source code ***
#version 330 core
#ifdef GL_KHR_blend_equation_advanced
#extension GL_ARB_fragment_coord_conventions : enable
#extension GL_KHR_blend_equation_advanced : enable
#endif
#define lowp
#define mediump
#define highp
#line 1
void main(void)
{
}
***
"ERROR: 0:1: '' : version '330' is not supported\nERROR: 0:1: '' : syntax error: #version\n"
QOpenGLShader::compile(Vertex): ERROR: 0:1: '' : version '330' is not supported
ERROR: 0:1: '' : syntax error: #version
ERROR: 0:2: 'layout' : syntax error: syntax error
*** Problematic Vertex shader source code ***
#version 330 core
#define lowp
#define mediump
#define highp
#line 1
layout (location = 0) in vec3 aPos;
uniform mat4 model;
out vec3 FragPos;
uniform mat4 lightSpaceMatrix;
void main()
{
gl_Position = lightSpaceMatrix * model * vec4(aPos, 1.0);
FragPos = vec3(model * vec4(aPos, 1.0));
}
***
"ERROR: 0:1: '' : version '330' is not supported\nERROR: 0:1: '' : syntax error: #version\nERROR: 0:2: 'layout' : syntax error: syntax error\n"
QOpenGLShader::compile(Fragment): ERROR: 0:1: '' : version '330' is not supported
ERROR: 0:1: '' : syntax error: #version
*** Problematic Fragment shader source code ***
#version 330 core
#ifdef GL_KHR_blend_equation_advanced
#extension GL_ARB_fragment_coord_conventions : enable
#extension GL_KHR_blend_equation_advanced : enable
#endif
#define lowp
#define mediump
#define highp
#line 1
in vec3 FragPos;
uniform vec3 lightPos;
uniform float far_plane;
void main()
{
float lightDistance = length(FragPos - lightPos);
// map to [0;1] range by dividing by far_plane
lightDistance = lightDistance / far_plane;
gl_FragDepth = lightDistance;
}
***
"ERROR: 0:1: '' : version '330' is not supported\nERROR: 0:1: '' : syntax error: #version\n"
This renderer requires atleast OpenGL 3.2. The version available is: 2.1 ATI-3.5.5
QOpenGLShader::compile(Vertex): ERROR: 0:1: '' : version '330' is not supported
ERROR: 0:1: '' : syntax error: #version
ERROR: 0:2: 'layout' : syntax error: syntax error
*** Problematic Vertex shader source code ***
#version 330 core
#define lowp
#define mediump
#define highp
#line 1
layout (location = 0) in vec3 aPos;
layout (location = 1) in vec3 aNormal;
layout (location = 2) in vec2 aTexCoords;
out vec3 FragPos;
out vec3 Normal;
out vec2 TexCoords;
uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;
void main()
{
FragPos = vec3(model * vec4(aPos, 1.0));
Normal = mat3(transpose(inverse(model))) * aNormal;
TexCoords = aTexCoords;
gl_Position = projection * view * model * vec4(aPos, 1.0);
}
***
"ERROR: 0:1: '' : version '330' is not supported\nERROR: 0:1: '' : syntax error: #version\nERROR: 0:2: 'layout' : syntax error: syntax error\n"
QOpenGLShader::compile(Fragment): ERROR: 0:1: '' : version '330' is not supported
ERROR: 0:1: '' : syntax error: #version
ERROR: 0:108: '(' : syntax error: Array size must appear after variable name
*** Problematic Fragment shader source code ***
#version 330 core
#ifdef GL_KHR_blend_equation_advanced
#extension GL_ARB_fragment_coord_conventions : enable
#extension GL_KHR_blend_equation_advanced : enable
#endif
#define lowp
#define mediump
#define highp
#line 1
struct Material {
vec4 ambient;
vec3 diffuse;
vec3 specular;
float shininess;
};
struct DirLight {
vec3 position; // specifically for shadows
vec3 direction;
// vec3 ambient;
vec3 diffuse;
vec3 specular;
mat4 lightSpaceMatrix;
sampler2D shadowMap;
float bias;
float normalBias;
};
struct PointLight {
vec3 position;
float constant;
float linear;
float quadratic;
// vec3 ambient;
vec3 diffuse;
vec3 specular;
float farPlane;
float bias;
float normalBias;
};
struct SpotLight {
vec3 position;
vec3 direction;
float cutOff;
float outerCutOff;
float constant;
float linear;
float quadratic;
// vec3 ambient;
vec3 diffuse;
vec3 specular;
mat4 lightSpaceMatrix;
sampler2D shadowMap;
float bias;
float normalBias;
};
out vec4 FragColor;
in vec3 FragPos;
in vec3 Normal;
in vec2 TexCoords;
uniform sampler2D texture0;
uniform int textureApplyMode;
uniform vec3 sceneAmbient;
uniform vec3 viewPos;
// Some graphics cards appear not to support arrays. One way around this is to explicitly roll out the array.
#define MAX_LIGHTS 5
uniform DirLight dirLight0;
uniform DirLight dirLight1;
uniform DirLight dirLight2;
uniform DirLight dirLight3;
uniform DirLight dirLight4;
uniform PointLight pointLight0;
uniform PointLight pointLight1;
uniform PointLight pointLight2;
uniform PointLight pointLight3;
uniform PointLight pointLight4;
uniform SpotLight spotLight0;
uniform SpotLight spotLight1;
uniform SpotLight spotLight2;
uniform SpotLight spotLight3;
uniform SpotLight spotLight4;
// For some reason, we are not allowed to store samplerCube in structs or arrays
// So allow a max of 5
uniform samplerCube depthCubeMap0;
uniform samplerCube depthCubeMap1;
uniform samplerCube depthCubeMap2;
uniform samplerCube depthCubeMap3;
uniform samplerCube depthCubeMap4;
uniform int dirLightLen;
uniform int pointLightLen;
uniform int spotLightLen;
uniform Material material;
// array of offset direction for sampling in pointlight shadows
vec3 gridSamplingDisk[20] = vec3[]
(
vec3(1, 1, 1), vec3( 1, -1, 1), vec3(-1, -1, 1), vec3(-1, 1, 1),
vec3(1, 1, -1), vec3( 1, -1, -1), vec3(-1, -1, -1), vec3(-1, 1, -1),
vec3(1, 1, 0), vec3( 1, -1, 0), vec3(-1, -1, 0), vec3(-1, 1, 0),
vec3(1, 0, 1), vec3(-1, 0, 1), vec3( 1, 0, -1), vec3(-1, 0, -1),
vec3(0, 1, 1), vec3( 0, -1, 1), vec3( 0, -1, -1), vec3( 0, 1, -1)
);
// function prototypes
vec3 CalcDirLight(DirLight light, vec3 normal, vec3 viewDir);
vec3 CalcPointLight(PointLight light, vec3 normal, vec3 fragPos, vec3 viewDir);
vec3 CalcSpotLight(SpotLight light, vec3 normal, vec3 fragPos, vec3 viewDir);
float ShadowCalculation(mat4 lightSpaceMatrix, vec3 lightPos, sampler2D shadowMap, float bias, float normalBias);
float PointShadowCalculation(vec3 lightPos, samplerCube cubeMap, float farPlane, float bias, float normalBias);
void main()
{
// Lighting properties
vec3 norm = normalize(Normal);
vec3 viewDir = normalize(viewPos - FragPos);
// Give it some intial ambient light
vec4 ambient = texture(texture0, TexCoords);
// textureApplyMode 1 (GL_DECAL) gets applied later.
if (textureApplyMode == 2) // ADD
ambient = (ambient + material.ambient, 1.0) * vec4(sceneAmbient, 1.0);
else if (textureApplyMode == 1)
ambient = material.ambient;
else if (textureApplyMode != 1)
// In this case, we either have no texture, or we want to use GL_BLEND.
ambient *= material.ambient * vec4(sceneAmbient, 1.0);
vec3 result = vec3(0.0);
// phase 1: directional lighting
for(int i = 0; i < dirLightLen && i < MAX_LIGHTS; i++)
{
vec3 lresult;
float shadow = 0.0;
// We are not allowed to store the struct in a temp, apparently.
if (i == 0){
lresult = CalcDirLight(dirLight0, norm, viewDir);
shadow = ShadowCalculation(dirLight0.lightSpaceMatrix, dirLight0.position, dirLight0.shadowMap, dirLight0.bias, dirLight0.normalBias);
} else if (i == 1){
lresult = CalcDirLight(dirLight1, norm, viewDir);
shadow = ShadowCalculation(dirLight1.lightSpaceMatrix, dirLight1.position, dirLight1.shadowMap, dirLight1.bias, dirLight1.normalBias);
} else if (i == 2){
lresult = CalcDirLight(dirLight2, norm, viewDir);
shadow = ShadowCalculation(dirLight2.lightSpaceMatrix, dirLight2.position, dirLight2.shadowMap, dirLight2.bias, dirLight2.normalBias);
} else if (i == 3){
lresult = CalcDirLight(dirLight3, norm, viewDir);
shadow = ShadowCalculation(dirLight3.lightSpaceMatrix, dirLight3.position, dirLight3.shadowMap, dirLight3.bias, dirLight3.normalBias);
} else if (i == 4){
lresult = CalcDirLight(dirLight4, norm, viewDir);
shadow = ShadowCalculation(dirLight4.lightSpaceMatrix, dirLight4.position, dirLight4.shadowMap, dirLight4.bias, dirLight4.normalBias);
}
result += lresult * (1.0 - shadow);
}
// phase 2: point lights
for(int i = 0; i < pointLightLen && i < MAX_LIGHTS; i++)
{
vec3 lresult;
float shadow = 0.0;
if (i == 0){
lresult = CalcPointLight(pointLight0, norm, FragPos, viewDir);
shadow = PointShadowCalculation(pointLight0.position, depthCubeMap0, pointLight0.farPlane, pointLight0.bias, pointLight0.normalBias);
}else if (i == 1){
lresult = CalcPointLight(pointLight1, norm, FragPos, viewDir);
shadow = PointShadowCalculation(pointLight1.position, depthCubeMap1, pointLight1.farPlane, pointLight1.bias, pointLight1.normalBias);
}else if (i == 2){
lresult = CalcPointLight(pointLight2, norm, FragPos, viewDir);
shadow = PointShadowCalculation(pointLight2.position, depthCubeMap2, pointLight2.farPlane, pointLight2.bias, pointLight2.normalBias);
}else if (i == 3){
lresult = CalcPointLight(pointLight3, norm, FragPos, viewDir);
shadow = PointShadowCalculation(pointLight3.position, depthCubeMap3, pointLight3.farPlane, pointLight3.bias, pointLight3.normalBias);
}else if (i == 4){
lresult = CalcPointLight(pointLight4, norm, FragPos, viewDir);
shadow = PointShadowCalculation(pointLight4.position, depthCubeMap4, pointLight4.farPlane, pointLight4.bias, pointLight4.normalBias);
}
result += lresult * (1.0 - shadow);
}
// phase 3: spot light
for(int i = 0; i < spotLightLen && i < MAX_LIGHTS; i++)
{
vec3 lresult;
float shadow = 0.0;
// We are not allowed to store the struct in a temp, apparently.
if (i == 0){
lresult = CalcSpotLight(spotLight0, norm, FragPos, viewDir);
shadow = ShadowCalculation(spotLight0.lightSpaceMatrix, spotLight0.position, spotLight0.shadowMap, spotLight0.bias, spotLight0.normalBias);
} else if (i == 1){
lresult = CalcSpotLight(spotLight1, norm, FragPos, viewDir);
shadow = ShadowCalculation(spotLight1.lightSpaceMatrix, spotLight1.position, spotLight1.shadowMap, spotLight1.bias, spotLight1.normalBias);
} else if (i == 2){
lresult = CalcSpotLight(spotLight2, norm, FragPos, viewDir);
shadow = ShadowCalculation(spotLight2.lightSpaceMatrix, spotLight2.position, spotLight2.shadowMap, spotLight2.bias, spotLight2.normalBias);
} else if (i == 3){
lresult = CalcSpotLight(spotLight3, norm, FragPos, viewDir);
shadow = ShadowCalculation(spotLight3.lightSpaceMatrix, spotLight3.position, spotLight3.shadowMap, spotLight3.bias, spotLight3.normalBias);
} else if (i == 4){
lresult = CalcSpotLight(spotLight4, norm, FragPos, viewDir);
shadow = ShadowCalculation(spotLight4.lightSpaceMatrix, spotLight4.position, spotLight4.shadowMap, spotLight4.bias, spotLight4.normalBias);
}
result += lresult * (1.0 - shadow);
}
FragColor = ambient + vec4(result, 0.0);
if (textureApplyMode == 1){
// textureApplyMode == 1 is DECAL
vec4 coltex = texture(texture0, TexCoords.st);
vec3 col = FragColor.rgb * (1.0-coltex.a) + coltex.rgb * coltex.a;
FragColor = vec4(col, FragColor.a);
}
}
// calculates the color when using a directional light.
vec3 CalcDirLight(DirLight light, vec3 normal, vec3 viewDir)
{
vec3 lightDir = normalize(-light.direction);
// diffuse shading
float diff = max(dot(normal, lightDir), 0.0);
// specular shading (Phong)
vec3 reflectDir = reflect(-lightDir, normal);
float spec = pow(max(dot(viewDir, reflectDir), 0.0), material.shininess);
// specular shading (Blinn-Phong)
// vec3 halfwayDir = normalize(lightDir + viewDir);
// float spec = pow(max(dot(normal, halfwayDir), 0.0), material.shininess);
// combine results
vec3 diffuse = light.diffuse * (diff * (vec3(texture(texture0, TexCoords)) * material.diffuse));
vec3 specular = light.specular * (spec * (vec3(texture(texture0, TexCoords)) * material.specular));
return (diffuse + specular);
}
// calculates the color when using a point light.
vec3 CalcPointLight(PointLight light, vec3 normal, vec3 fragPos, vec3 viewDir)
{
vec3 lightDir = normalize(light.position - fragPos);
// diffuse shading
float diff = max(dot(normal, lightDir), 0.0);
// specular shading
vec3 reflectDir = reflect(-lightDir, normal);
float spec = pow(max(dot(viewDir, reflectDir), 0.0), material.shininess);
// attenuation
float distance = length(light.position - fragPos);
float attenuation = 1.0 / (light.constant + light.linear * distance + light.quadratic * (distance * distance));
// combine results
vec3 diffuse = light.diffuse * (diff * material.diffuse);
vec3 specular = light.specular * (spec * material.specular);
diffuse *= attenuation;
specular *= attenuation;
return (diffuse + specular);
}
// calculates the color when using a spot light.
vec3 CalcSpotLight(SpotLight light, vec3 normal, vec3 fragPos, vec3 viewDir)
{
vec3 lightDir = normalize(light.position - fragPos);
// diffuse shading
float diff = max(dot(normal, lightDir), 0.0);
// specular shading
vec3 reflectDir = reflect(-lightDir, normal);
float spec = pow(max(dot(viewDir, reflectDir), 0.0), material.shininess);
// attenuation
float distance = length(light.position - fragPos);
float attenuation = 1.0 / (light.constant + light.linear * distance + light.quadratic * (distance * distance));
// spotlight intensity
float theta = dot(lightDir, normalize(-light.direction));
float epsilon = light.cutOff - light.outerCutOff;
float intensity = clamp((theta - light.outerCutOff) / epsilon, 0.0, 1.0);
// combine results
vec3 diffuse = light.diffuse * (diff * material.diffuse);
vec3 specular = light.specular * (spec * material.specular);
diffuse *= attenuation * intensity;
specular *= attenuation * intensity;
return (diffuse + specular);
}
float ShadowCalculation(mat4 lightSpaceMatrix, vec3 lightPos, sampler2D shadowMap, float bias, float normalBias)
{
vec4 fragPosLightSpace = lightSpaceMatrix * vec4(FragPos, 1.0);
// perform perspective divide
vec3 projCoords = fragPosLightSpace.xyz / fragPosLightSpace.w;
// transform to [0,1] range
projCoords = projCoords * 0.5 + 0.5;
// get closest depth value from light's perspective (using [0,1] range fragPosLight as coords)
float closestDepth = texture(shadowMap, projCoords.xy).r;
// get depth of current fragment from light's perspective
float currentDepth = projCoords.z;
// calculate bias (based on depth map resolution and slope)
vec3 normal = normalize(Normal);
vec3 lightDir = normalize(lightPos - FragPos);
bias = max(normalBias * (1.0 - dot(normal, lightDir)), bias);
// check whether current frag pos is in shadow
// PCF
float shadow = 0.0;
vec2 texelSize = 1.0 / textureSize(shadowMap, 0);
for(int x = -1; x <= 1; ++x)
{
for(int y = -1; y <= 1; ++y)
{
float pcfDepth = texture(shadowMap, projCoords.xy + vec2(x, y) * texelSize).r;
shadow += currentDepth - bias > pcfDepth ? 1.0 : 0.0;
}
}
shadow /= 9.0;
// keep the shadow at 0.0 when outside the far_plane region of the light's frustum.
if(projCoords.z > 1.0)
shadow = 0.0;
return shadow;
}
float PointShadowCalculation(vec3 lightPos, samplerCube cubeMap, float farPlane, float bias, float normalBias)
{
// get vector between fragment position and light position
vec3 fragToLight = FragPos - lightPos;
float currentDepth = length(fragToLight);