-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhouse.cpp
1578 lines (1416 loc) · 58.9 KB
/
house.cpp
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
// CS370 Final Project
// Fall 2023
#define STB_IMAGE_IMPLEMENTATION
#include "../common/stb_image.h" // Sean Barrett's image loader - http://nothings.org/
#include <stdio.h>
#include <vector>
#include "../common/vgl.h"
#include "../common/objloader.h"
#include "../common/tangentspace.h"
#include "../common/utils.h"
#include "../common/vmath.h"
#include "lighting.h"
#define DEG2RAD (M_PI/180.0)
using namespace vmath;
using namespace std;
// Vertex array and buffer names
enum VAO_IDs {Cube, TexCube, Cylinder, Cone, Mug, Frame, Mirror, NumVAOs};
enum ObjBuffer_IDs {PosBuffer, NormBuffer, TexBuffer, TangBuffer, BiTangBuffer, NumObjBuffers};
enum Color_Buffer_IDs {WhiteCube, Switch, Walls, BlackMat, BlackCone, WoodFrame, NumColorBuffers};
enum LightBuffer_IDs {LightBuffer, NumLightBuffers};
enum MaterialBuffer_IDs {MaterialBuffer, NumMaterialBuffers};
enum MaterialNames {White, OffWhite, Blue, StandingLight, WoodLining, Glass, Liquid, Tin};
enum Textures {Blank, Wood, Carpet, Roof, Door, Widow, CarpetNorm, RoofNorm, DoorNorm, WoodNorm, ShadowTex, MirrorTex, NumTextures};
enum LightNames {WhitePointLight, WhiteSpotLight};
// Vertex array and buffer objects
GLuint VAOs[NumVAOs];
GLuint ObjBuffers[NumVAOs][NumObjBuffers];
GLuint ColorBuffers[NumColorBuffers];
GLuint LightBuffers[NumLightBuffers];
GLuint MaterialBuffers[NumMaterialBuffers];
GLuint TextureIDs[NumTextures];
GLuint ShadowBuffer;
// Number of vertices in each object
GLint numVertices[NumVAOs];
// Number of component coordinates
GLint posCoords = 4;
GLint normCoords = 3;
GLint texCoords = 2;
GLint tangCoords = 3;
GLint bitangCoords = 3;
GLint colCoords = 4;
// Model files
const char * cubeFile = "../models/unitcube.obj";
const char * cylinderFile = "../models/cylinder.obj";
const char * coneFile = "../models/cone.obj";
const char * mugFile = "../models/mug.obj";
const char * planeFile = "../models/plane.obj";
// Texture files
const char * blankFile = "../textures/blank.png";
const char * woodFile = "../textures/wood.png";
const char * carpetFile = "../textures/carpet.jpg";
const char * roofFile = "../textures/roof.jpg";
const char * doorFile = "../textures/door.jpg";
const char * windowFile = "../textures/landscape.jpg";
const char * carpetNormFile = "../textures/CarpetMap.png";
const char * roofNormFile = "../textures/RoofMap.png";
const char * doorNormFile = "../textures/DoorMap.png";
const char * woodNormFile = "../textures/FloorMap.png";
// Camera
vec3 eye = {-3.0f, 2.0f, 0.0f};
vec3 center = {0.0f, 0.0f, 0.0f};
vec3 up = {0.0f, 1.0f, 0.0f};
vec3 dir = {1.0f, 1.0f, 1.0f};
vec3 mirror_eye = {0.0f, 2.0f, 5.1f};
vec3 mirror_center = {0.0f, 0.0f, 0.0f};
vec3 mirror_up = {0.0f, 1.0f, 0.0f};
GLfloat azimuth = 0.0f;
GLfloat daz = 2.0f;
GLfloat elevation = 90.0f;
GLfloat del = 2.0f;
GLfloat radius = 2.0f;
GLfloat dr = 0.1f;
GLfloat camera_angle = 0.0f;
GLfloat stepSize = 0.5f;
GLboolean spin = true;
GLboolean blinds = false;
GLfloat swtich1_ang = 45.0f;
GLfloat swtich2_ang = 45.0f;
GLfloat swtich3_ang = 45.0f;
GLfloat blade_ang = 0.0f;
GLfloat blade_dps = 2.0f;
GLfloat blinds_ang = 0.0f;
GLfloat blinds_dps = 360.0f;
GLfloat spin_dir = 1.0f;
GLdouble elTime = 0.0;
// Shader variables
// Default (color) shader program references
GLuint default_program;
GLuint default_vPos;
GLuint default_vCol;
GLuint default_proj_mat_loc;
GLuint default_cam_mat_loc;
GLuint default_model_mat_loc;
const char *default_vertex_shader = "../default.vert";
const char *default_frag_shader = "../default.frag";
// Lighting shader program reference
GLuint lighting_program;
GLuint lighting_vPos;
GLuint lighting_vNorm;
GLuint lighting_camera_mat_loc;
GLuint lighting_model_mat_loc;
GLuint lighting_proj_mat_loc;
GLuint lighting_norm_mat_loc;
GLuint lighting_lights_block_idx;
GLuint lighting_materials_block_idx;
GLuint lighting_material_loc;
GLuint lighting_num_lights_loc;
GLuint lighting_light_on_loc;
GLuint lighting_eye_loc;
const char *lighting_vertex_shader = "../lighting.vert";
const char *lighting_frag_shader = "../lighting.frag";
// Light shader program with shadows reference
GLuint phong_shadow_program;
GLuint phong_shadow_vPos;
GLuint phong_shadow_vNorm;
GLuint phong_shadow_proj_mat_loc;
GLuint phong_shadow_camera_mat_loc;
GLuint phong_shadow_norm_mat_loc;
GLuint phong_shadow_model_mat_loc;
GLuint phong_shadow_shad_proj_mat_loc;
GLuint phong_shadow_shad_cam_mat_loc;
GLuint phong_shadow_lights_block_idx;
GLuint phong_shadow_materials_block_idx;
GLuint phong_shadow_material_loc;
GLuint phong_shadow_num_lights_loc;
GLuint phong_shadow_light_on_loc;
GLuint phong_shadow_eye_loc;
const char *phong_shadow_vertex_shader = "../phongShadow.vert";
const char *phong_shadow_frag_shader = "../phongShadow.frag";
// Texture shader program reference
GLuint texture_program;
GLuint texture_vPos;
GLuint texture_vTex;
GLuint texture_proj_mat_loc;
GLuint texture_camera_mat_loc;
GLuint texture_model_mat_loc;
const char *texture_vertex_shader = "../texture.vert";
const char *texture_frag_shader = "../texture.frag";
// Shadow shader program reference
GLuint shadow_program;
GLuint shadow_vPos;
GLuint shadow_proj_mat_loc;
GLuint shadow_camera_mat_loc;
GLuint shadow_model_mat_loc;
const char *shadow_vertex_shader = "../shadow.vert";
const char *shadow_frag_shader = "../shadow.frag";
// Bumpmapping shader program reference
GLuint bump_program;
GLuint bump_proj_mat_loc;
GLuint bump_camera_mat_loc;
GLuint bump_norm_mat_loc;
GLuint bump_model_mat_loc;
GLuint bump_vPos;
GLuint bump_vNorm;
GLuint bump_vTex;
GLuint bump_vTang;
GLuint bump_vBiTang;
GLuint bump_lights_block_idx;
GLuint bump_num_lights_loc;
GLuint bump_light_on_loc;
GLuint bump_eye_loc;
GLuint bump_base_loc;
GLuint bump_norm_loc;
const char *bump_vertex_shader = "../bumpTex.vert";
const char *bump_frag_shader = "../bumpTex.frag";
// BumpShadow shader program reference
GLuint bumpShadow_program;
GLuint bumpShadow_proj_mat_loc;
GLuint bumpShadow_camera_mat_loc;
GLuint bumpShadow_norm_mat_loc;
GLuint bumpShadow_model_mat_loc;
GLuint bumpShadow_vPos;
GLuint bumpShadow_vNorm;
GLuint bumpShadow_vTex;
GLuint bumpShadow_vTang;
GLuint bumpShadow_vBiTang;
GLuint bumpShadow_lights_block_idx;
GLuint bumpShadow_num_lights_loc;
GLuint bumpShadow_light_on_loc;
GLuint bumpShadow_eye_loc;
GLuint bumpShadow_base_loc;
GLuint bumpShadow_norm_loc;
GLuint bumpShadow_shadow_loc;
GLuint bumpShadow_shad_proj_mat_loc;
GLuint bumpShadow_shad_cam_mat_loc;
GLuint bumpShadow_materials_block_idx;
GLuint bumpShadow_material_loc;
const char *bumpShadow_vertex_shader = "../bumpShadow.vert";
const char *bumpShadow_frag_shader = "../bumpShadow.frag";
// Debug shadow program reference
GLuint debug_program;
const char *debug_shadow_vertex_shader = "../debugShadow.vert";
const char *debug_shadow_frag_shader = "../debugShadow.frag";
// Shadow flag
GLuint shadow = false;
// Mirror flag
GLboolean mirror = false;
// Generic shader variables references
GLuint vPos;
GLuint vNorm;
GLuint model_mat_loc;
// Global state
mat4 proj_matrix;
mat4 camera_matrix;
mat4 normal_matrix;
mat4 model_matrix;
mat4 shadow_proj_matrix;
mat4 shadow_camera_matrix;
vector<LightProperties> Lights;
vector<MaterialProperties> Materials;
GLuint numLights = 0;
GLint lightOn[8] = {0, 0, 0, 0, 0, 0, 0, 0};
// Global screen dimensions
GLint ww,hh;
void display();
void render_scene();
void create_shadows( );
void create_mirror( );
void build_geometry();
void build_solid_color_buffer(GLuint num_vertices, vec4 color, GLuint buffer);
void build_materials( );
void build_lights( );
void build_mirror(GLuint m_textid);
void build_frame(GLuint obj);
void build_textures();
void build_texture_cube(GLuint obj);
void build_shadows( );
void load_model(const char * filename, GLuint obj);
void load_texture(const char * filename, GLuint texID, GLint magFilter, GLint minFilter, GLint sWrap, GLint tWrap, bool mipMap, bool invert);
void draw_color_obj(GLuint obj, GLuint color);
void draw_mat_object(GLuint obj, GLuint material);
void draw_tex_object(GLuint obj, GLuint texture);
void draw_bump_object(GLuint obj, GLuint base_texture, GLuint normal_map);
void draw_bump_shadow_object(GLuint obj, GLuint base_texture, GLuint normal_map);
void draw_frame(GLuint obj);
void framebuffer_size_callback(GLFWwindow *window, int width, int height);
void key_callback(GLFWwindow *window, int key, int scancode, int action, int mods);
void mouse_callback(GLFWwindow *window, int button, int action, int mods);
void renderQuad();
int main(int argc, char**argv)
{
// Create OpenGL window
GLFWwindow* window = CreateWindow("Think Inside The Box");
if (!window) {
fprintf(stderr, "ERROR: could not open window with GLFW3\n");
glfwTerminate();
return 1;
} else {
printf("OpenGL window successfully created\n");
}
// Store initial window size
glfwGetFramebufferSize(window, &ww, &hh);
// Register callbacks
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
glfwSetKeyCallback(window,key_callback);
glfwSetMouseButtonCallback(window, mouse_callback);
// Load shaders and associate variables
ShaderInfo default_shaders[] = { {GL_VERTEX_SHADER, default_vertex_shader},{GL_FRAGMENT_SHADER, default_frag_shader},{GL_NONE, NULL} };
default_program = LoadShaders(default_shaders);
default_vPos = glGetAttribLocation(default_program, "vPosition");
default_vCol = glGetAttribLocation(default_program, "vColor");
default_proj_mat_loc = glGetUniformLocation(default_program, "proj_matrix");
default_cam_mat_loc = glGetUniformLocation(default_program, "camera_matrix");
default_model_mat_loc = glGetUniformLocation(default_program, "model_matrix");
// Load shaders
// Load light shader
ShaderInfo lighting_shaders[] = { {GL_VERTEX_SHADER, lighting_vertex_shader},{GL_FRAGMENT_SHADER, lighting_frag_shader},{GL_NONE, NULL} };
lighting_program = LoadShaders(lighting_shaders);
lighting_vPos = glGetAttribLocation(lighting_program, "vPosition");
lighting_vNorm = glGetAttribLocation(lighting_program, "vNormal");
lighting_proj_mat_loc = glGetUniformLocation(lighting_program, "proj_matrix");
lighting_camera_mat_loc = glGetUniformLocation(lighting_program, "camera_matrix");
lighting_norm_mat_loc = glGetUniformLocation(lighting_program, "normal_matrix");
lighting_model_mat_loc = glGetUniformLocation(lighting_program, "model_matrix");
lighting_lights_block_idx = glGetUniformBlockIndex(lighting_program, "LightBuffer");
lighting_materials_block_idx = glGetUniformBlockIndex(lighting_program, "MaterialBuffer");
lighting_material_loc = glGetUniformLocation(lighting_program, "Material");
lighting_num_lights_loc = glGetUniformLocation(lighting_program, "NumLights");
lighting_light_on_loc = glGetUniformLocation(lighting_program, "LightOn");
lighting_eye_loc = glGetUniformLocation(lighting_program, "EyePosition");
// Load light shader with shadows
ShaderInfo phong_shadow_shaders[] = { {GL_VERTEX_SHADER, phong_shadow_vertex_shader},{GL_FRAGMENT_SHADER, phong_shadow_frag_shader},{GL_NONE, NULL} };
phong_shadow_program = LoadShaders(phong_shadow_shaders);
phong_shadow_vPos = glGetAttribLocation(phong_shadow_program, "vPosition");
phong_shadow_vNorm = glGetAttribLocation(phong_shadow_program, "vNormal");
phong_shadow_camera_mat_loc = glGetUniformLocation(phong_shadow_program, "camera_matrix");
phong_shadow_proj_mat_loc = glGetUniformLocation(phong_shadow_program, "proj_matrix");
phong_shadow_norm_mat_loc = glGetUniformLocation(phong_shadow_program, "normal_matrix");
phong_shadow_model_mat_loc = glGetUniformLocation(phong_shadow_program, "model_matrix");
phong_shadow_shad_proj_mat_loc = glGetUniformLocation(phong_shadow_program, "light_proj_matrix");
phong_shadow_shad_cam_mat_loc = glGetUniformLocation(phong_shadow_program, "light_cam_matrix");
phong_shadow_lights_block_idx = glGetUniformBlockIndex(phong_shadow_program, "LightBuffer");
phong_shadow_materials_block_idx = glGetUniformBlockIndex(phong_shadow_program, "MaterialBuffer");
phong_shadow_material_loc = glGetUniformLocation(phong_shadow_program, "Material");
phong_shadow_num_lights_loc = glGetUniformLocation(phong_shadow_program, "NumLights");
phong_shadow_light_on_loc = glGetUniformLocation(phong_shadow_program, "LightOn");
phong_shadow_eye_loc = glGetUniformLocation(phong_shadow_program, "EyePosition");
// Load shadow shader
ShaderInfo shadow_shaders[] = { {GL_VERTEX_SHADER, shadow_vertex_shader},{GL_FRAGMENT_SHADER, shadow_frag_shader},{GL_NONE, NULL} };
shadow_program = LoadShaders(shadow_shaders);
shadow_vPos = glGetAttribLocation(shadow_program, "vPosition");
shadow_proj_mat_loc = glGetUniformLocation(shadow_program, "light_proj_matrix");
shadow_camera_mat_loc = glGetUniformLocation(shadow_program, "light_cam_matrix");
shadow_model_mat_loc = glGetUniformLocation(shadow_program, "model_matrix");
// Load texture shaders
ShaderInfo texture_shaders[] = { {GL_VERTEX_SHADER, texture_vertex_shader},{GL_FRAGMENT_SHADER, texture_frag_shader},{GL_NONE, NULL} };
texture_program = LoadShaders(texture_shaders);
texture_vPos = glGetAttribLocation(texture_program, "vPosition");
texture_vTex = glGetAttribLocation(texture_program, "vTexCoord");
texture_proj_mat_loc = glGetUniformLocation(texture_program, "proj_matrix");
texture_camera_mat_loc = glGetUniformLocation(texture_program, "camera_matrix");
texture_model_mat_loc = glGetUniformLocation(texture_program, "model_matrix");
// Load bump shader
ShaderInfo bump_shaders[] = { {GL_VERTEX_SHADER, bump_vertex_shader},{GL_FRAGMENT_SHADER, bump_frag_shader},{GL_NONE, NULL} };
bump_program = LoadShaders(bump_shaders);
bump_vPos = glGetAttribLocation(bump_program, "vPosition");
bump_vNorm = glGetAttribLocation(bump_program, "vNormal");
bump_vTex = glGetAttribLocation(bump_program, "vTexCoord");
bump_vTang = glGetAttribLocation(bump_program, "vTangent");
bump_vBiTang = glGetAttribLocation(bump_program, "vBiTangent");
bump_proj_mat_loc = glGetUniformLocation(bump_program, "proj_matrix");
bump_camera_mat_loc = glGetUniformLocation(bump_program, "camera_matrix");
bump_norm_mat_loc = glGetUniformLocation(bump_program, "normal_matrix");
bump_model_mat_loc = glGetUniformLocation(bump_program, "model_matrix");
bump_lights_block_idx = glGetUniformBlockIndex(bump_program, "LightBuffer");
bump_num_lights_loc = glGetUniformLocation(bump_program, "NumLights");
bump_light_on_loc = glGetUniformLocation(bump_program, "LightOn");
bump_eye_loc = glGetUniformLocation(bump_program, "EyePosition");
bump_base_loc = glGetUniformLocation(bump_program, "baseMap");
bump_norm_loc = glGetUniformLocation(bump_program, "normalMap");
ShaderInfo bumpShadow_shaders[] = { {GL_VERTEX_SHADER, bumpShadow_vertex_shader},{GL_FRAGMENT_SHADER, bumpShadow_frag_shader},{GL_NONE, NULL} };
bumpShadow_program = LoadShaders(bumpShadow_shaders);
bumpShadow_proj_mat_loc = glGetAttribLocation(bumpShadow_program, "proj_matrix");
bumpShadow_camera_mat_loc = glGetAttribLocation(bumpShadow_program, "camera_matrix");
bumpShadow_norm_mat_loc = glGetAttribLocation(bumpShadow_program, "normal_matrix");
bumpShadow_model_mat_loc = glGetAttribLocation(bumpShadow_program, "model_matrix");
bumpShadow_vPos = glGetAttribLocation(bumpShadow_program, "vPosition");
bumpShadow_vNorm = glGetAttribLocation(bumpShadow_program, "vNorm");
bumpShadow_vTex = glGetAttribLocation(bumpShadow_program, "vTexCoord");
bumpShadow_vTang = glGetAttribLocation(bumpShadow_program, "vTangent");
bumpShadow_vBiTang = glGetAttribLocation(bumpShadow_program, "vBiTangent");
bumpShadow_lights_block_idx = glGetAttribLocation(bumpShadow_program, "LightBuffer");
bumpShadow_num_lights_loc = glGetAttribLocation(bumpShadow_program, "NumLights");
bumpShadow_light_on_loc = glGetAttribLocation(bumpShadow_program, "LightOn");
bumpShadow_eye_loc = glGetAttribLocation(bumpShadow_program, "EyePosition");
bumpShadow_base_loc = glGetAttribLocation(bumpShadow_program, "baseMap");
bumpShadow_norm_loc = glGetAttribLocation(bumpShadow_program, "normalMap");
bumpShadow_norm_loc = glGetAttribLocation(bumpShadow_program, "shadowMap");
bumpShadow_shad_proj_mat_loc = glGetAttribLocation(bumpShadow_program, "light_proj_matrix");
bumpShadow_shad_cam_mat_loc = glGetAttribLocation(bumpShadow_program, "light_cam_matrix");
bumpShadow_materials_block_idx = glGetAttribLocation(bumpShadow_program, "MaterialBuffer");
bumpShadow_material_loc = glGetAttribLocation(bumpShadow_program, "Material");
// Load debug shadow shader
ShaderInfo debug_shaders[] = { {GL_VERTEX_SHADER, debug_shadow_vertex_shader},{GL_FRAGMENT_SHADER, debug_shadow_frag_shader},{GL_NONE, NULL} };
debug_program = LoadShaders(debug_shaders);
// Create geometry buffers
build_geometry();
// Create material buffers
build_materials();
// Create light buffers
build_lights();
// Create textures
build_textures();
// Create shadow buffer
build_shadows();
// Create mirror texture
build_mirror(MirrorTex);
// Enable depth test
glEnable(GL_CULL_FACE);
glEnable(GL_DEPTH_TEST);
// Alpha Blending
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// Start loop
while ( !glfwWindowShouldClose( window ) ) {
glCullFace(GL_FRONT);
create_shadows();
glCullFace(GL_BACK);
center[0] = eye[0] + cos(camera_angle);
center[1] = eye[1];
center[2] = eye[2] + sin(camera_angle);
create_mirror();
// Draw graphics
// renderQuad();
display();
// Update other events like input handling
glfwPollEvents();
//animation
GLdouble curTime = glfwGetTime();
if (spin) {
blade_ang += (curTime - elTime) * (blade_dps / 60.0) * 360.0f;
}
if (blinds) {
blinds_ang += spin_dir * (curTime - elTime) * (blinds_dps);
if (blinds_ang <= 0.0f || blinds_ang >= 55.0f) {
blinds = false;
spin_dir *= -1;
}
}
elTime = curTime;
// Swap buffer onto screen
glfwSwapBuffers( window );
}
// Close window
glfwTerminate();
return 0;
}
void display( )
{
// Declare projection and camera matrices
proj_matrix = mat4().identity();
camera_matrix = mat4().identity();
// Clear window and depth buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Compute anisotropic scaling
GLfloat xratio = 1.0f;
GLfloat yratio = 1.0f;
// If taller than wide adjust y
if (ww <= hh)
{
yratio = (GLfloat)hh / (GLfloat)ww;
}
// If wider than tall adjust x
else if (hh <= ww)
{
xratio = (GLfloat)ww / (GLfloat)hh;
}
// DEFAULT ORTHOGRAPHIC PROJECTION
proj_matrix = frustum(-0.1f*xratio, 0.1f*xratio, -0.1f*yratio, 0.1f*yratio, 0.1f, 20.0f);
// Set camera matrix
camera_matrix = lookat(eye, center, up);
// Render objects
render_scene();
// Flush pipeline
glFlush();
}
void render_scene( ) {
// Declare transformation matrices
model_matrix = mat4().identity();
mat4 scale_matrix = mat4().identity();
mat4 rot_matrix = mat4().identity();
mat4 trans_matrix = mat4().identity();
// Set cube transformation matrix
// floor
scale_matrix = scale(11.0f, 0.5f, 11.0f);
model_matrix = scale_matrix;
if (!shadow) {
// Set normal matrix for phong shadow shader
normal_matrix = model_matrix.inverse().transpose();
}
draw_bump_object(TexCube, Carpet, CarpetNorm);
//walls
trans_matrix = translate(5.5f, 2.0f, 0.0f);
scale_matrix = scale(0.5f, 4.0f, 11.0f);
model_matrix = trans_matrix*scale_matrix;
if (!shadow) {
// Set normal matrix for phong shadow shader
normal_matrix = model_matrix.inverse().transpose();
}
draw_mat_object(Cube, Blue);
trans_matrix = translate(-5.5f, 2.0f, 0.0f);
model_matrix = trans_matrix*scale_matrix;
if (!shadow) {
// Set normal matrix for phong shadow shader
normal_matrix = model_matrix.inverse().transpose();
}
draw_mat_object(Cube, Blue);
trans_matrix = translate(0.0f, 2.0f, 5.5f);
scale_matrix = scale(11.0f, 4.0f, 0.5f);
model_matrix = trans_matrix*scale_matrix;
if (!shadow) {
// Set normal matrix for phong shadow shader
normal_matrix = model_matrix.inverse().transpose();
}
draw_mat_object(Cube, Blue);
trans_matrix = translate(0.0f, 2.0f, -5.5f);
model_matrix = trans_matrix*scale_matrix;
if (!shadow) {
// Set normal matrix for phong shadow shader
normal_matrix = model_matrix.inverse().transpose();
}
draw_mat_object(Cube, Blue);
// roof
trans_matrix = translate(0.0f, 4.0f, 0.0f);
scale_matrix = scale(11.0f, 0.5f, 11.0f);
model_matrix = trans_matrix*scale_matrix;
if (!shadow) {
// Set normal matrix for phong shadow shader
normal_matrix = model_matrix.inverse().transpose();
}
draw_bump_object(TexCube, Roof, RoofNorm);
//table
trans_matrix = translate(0.0f, 1.5f, 0.0f);
scale_matrix = scale(2.0f, 0.3f, 2.0f);
model_matrix = trans_matrix*scale_matrix;
if (!shadow) {
// Set normal matrix for phong shadow shader
normal_matrix = model_matrix.inverse().transpose();
}
draw_bump_object(TexCube, Wood, WoodNorm);
trans_matrix = translate(0.85f, 1.0f, 0.85f);
scale_matrix = scale(0.3f, 1.0f, 0.3f);
model_matrix = trans_matrix*scale_matrix;
if (!shadow) {
// Set normal matrix for phong shadow shader
normal_matrix = model_matrix.inverse().transpose();
}
draw_bump_object(TexCube, Wood, WoodNorm);
trans_matrix = translate(-0.85f, 1.0f, 0.85f);
model_matrix = trans_matrix*scale_matrix;
if (!shadow) {
// Set normal matrix for phong shadow shader
normal_matrix = model_matrix.inverse().transpose();
}
draw_bump_object(TexCube, Wood, WoodNorm);
trans_matrix = translate(-0.85f, 1.0f, -0.85f);
model_matrix = trans_matrix*scale_matrix;
if (!shadow) {
// Set normal matrix for phong shadow shader
normal_matrix = model_matrix.inverse().transpose();
}
draw_bump_object(TexCube, Wood, WoodNorm);
trans_matrix = translate(0.85f, 1.0f, -0.85f);
model_matrix = trans_matrix*scale_matrix;
if (!shadow) {
// Set normal matrix for phong shadow shader
normal_matrix = model_matrix.inverse().transpose();
}
draw_bump_object(TexCube, Wood, WoodNorm);
//can
trans_matrix = translate(0.5f, 1.9f, 0.5f);
scale_matrix = scale(0.2f, 0.23f, 0.2f);
model_matrix = trans_matrix*scale_matrix;
if (!shadow) {
// Set normal matrix for phong shadow shader
normal_matrix = model_matrix.inverse().transpose();
}
draw_mat_object(Cylinder, Tin);
//draw chair
trans_matrix = translate(0.9f, 1.0f, 0.0f);
scale_matrix = scale(1.0f, 0.1f, 1.0f);
model_matrix = trans_matrix*scale_matrix;
if (!shadow) {
// Set normal matrix for phong shadow shader
normal_matrix = model_matrix.inverse().transpose();
}
draw_bump_object(TexCube, Wood, WoodNorm);
trans_matrix = translate(1.35f, 1.0f, 0.45f);
scale_matrix = scale(0.1f, 2.0f, 0.1f);
model_matrix = trans_matrix*scale_matrix;
if (!shadow) {
// Set normal matrix for phong shadow shader
normal_matrix = model_matrix.inverse().transpose();
}
draw_bump_object(TexCube, Wood, WoodNorm);
trans_matrix = translate(1.35f, 1.0f, -0.45f);
model_matrix = trans_matrix*scale_matrix;
if (!shadow) {
// Set normal matrix for phong shadow shader
normal_matrix = model_matrix.inverse().transpose();
}
draw_bump_object(TexCube, Wood, WoodNorm);
trans_matrix = translate(0.45f, 0.7f, 0.45f);
scale_matrix = scale(0.1f, 0.5f, 0.1f);
model_matrix = trans_matrix*scale_matrix;
if (!shadow) {
// Set normal matrix for phong shadow shader
normal_matrix = model_matrix.inverse().transpose();
}
draw_bump_object(TexCube, Wood, WoodNorm);
trans_matrix = translate(0.45f, 0.7f, -0.45f);
model_matrix = trans_matrix*scale_matrix;
if (!shadow) {
// Set normal matrix for phong shadow shader
normal_matrix = model_matrix.inverse().transpose();
}
draw_bump_object(TexCube, Wood, WoodNorm);
trans_matrix = translate(1.35f, 1.7f, 0.0f);
scale_matrix = scale(0.0f, 0.6f, 1.0f);
model_matrix = trans_matrix*scale_matrix;
if (!shadow) {
// Set normal matrix for phong shadow shader
normal_matrix = model_matrix.inverse().transpose();
}
draw_bump_object(TexCube, Wood, WoodNorm);
//standing light
trans_matrix = translate(3.0f, 1.0f, 3.0f);
scale_matrix = scale(0.15f, 1.0f, 0.15f);
model_matrix = trans_matrix*scale_matrix;
if (!shadow) {
// Set normal matrix for phong shadow shader
normal_matrix = model_matrix.inverse().transpose();
}
draw_mat_object(Cylinder, StandingLight);
trans_matrix = translate(3.0f, 1.9f, 3.0f);
rot_matrix = rotate(180.0f, vec3(0.0f, 0.0f, 1.0f));
scale_matrix = scale(0.3f, 0.3f, 0.3f);
model_matrix = trans_matrix*rot_matrix*scale_matrix;
rot_matrix = rotate(90.0f, 1.0f, 0.0f, 1.0f);
model_matrix *= rot_matrix;
if (!shadow) {
// Set normal matrix for phong shadow shader
normal_matrix = model_matrix.inverse().transpose();
}
draw_mat_object(Cone, StandingLight);
trans_matrix = translate(3.0f, 0.45f, 3.0f);
scale_matrix = scale(0.4f, 0.1f, 0.4f);
model_matrix = trans_matrix*scale_matrix;
if (!shadow) {
// Set normal matrix for phong shadow shader
normal_matrix = model_matrix.inverse().transpose();
}
draw_mat_object(Cone, StandingLight);
//light switch
trans_matrix = translate(-5.2f, 2.0f, -3.3f);
scale_matrix = scale(0.2f, 1.0f, 1.7f);
model_matrix = trans_matrix*scale_matrix;
if (!shadow) {
// Set normal matrix for phong shadow shader
normal_matrix = model_matrix.inverse().transpose();
}
draw_mat_object(Cube, White);
trans_matrix = translate(-5.1f, 2.1f, -3.3f);
rot_matrix = rotate(swtich1_ang, vec3(0.0f, 0.0f, 1.0f));
scale_matrix = scale(0.7f, 0.3f, 0.3f);
model_matrix = trans_matrix*rot_matrix*scale_matrix;
if (!shadow) {
// Set normal matrix for phong shadow shader
normal_matrix = model_matrix.inverse().transpose();
}
draw_mat_object(Cube, OffWhite);
trans_matrix = translate(-5.1f, 2.1f, -2.7f);
rot_matrix = rotate(swtich2_ang, vec3(0.0f, 0.0f, 1.0f));
scale_matrix = scale(0.7f, 0.3f, 0.3f);
model_matrix = trans_matrix*rot_matrix*scale_matrix;
if (!shadow) {
// Set normal matrix for phong shadow shader
normal_matrix = model_matrix.inverse().transpose();
}
draw_mat_object(Cube, OffWhite);
trans_matrix = translate(-5.1f, 2.1f, -3.9f);
rot_matrix = rotate(swtich3_ang, vec3(0.0f, 0.0f, 1.0f));
scale_matrix = scale(0.7f, 0.3f, 0.3f);
model_matrix = trans_matrix*rot_matrix*scale_matrix;
if (!shadow) {
// Set normal matrix for phong shadow shader
normal_matrix = model_matrix.inverse().transpose();
}
draw_mat_object(Cube, OffWhite);
//door
trans_matrix = translate(-5.1f, 1.5f, 0.0f);
rot_matrix = rotate(180.0f, 1.0f, 0.0f, 0.0f);
scale_matrix = scale(0.1f, 4.0f, 2.0f);
model_matrix = trans_matrix*rot_matrix*scale_matrix;
if (!shadow) {
// Set normal matrix for phong shadow shader
normal_matrix = model_matrix.inverse().transpose();
}
draw_bump_object(TexCube, Door, DoorNorm);
//window
trans_matrix = translate(0.0f, 2.0f, -5.25f);
rot_matrix = rotate(180.0f, 0.0f, 0.0f, 1.0f);
scale_matrix = scale(2.0f, 2.0f, 0.1f);
model_matrix = trans_matrix*rot_matrix*scale_matrix;
if (!shadow) {
// Set normal matrix for phong shadow shader
normal_matrix = model_matrix.inverse().transpose();
}
draw_tex_object(TexCube, Widow);
trans_matrix = translate(1.0f, 2.0f, -5.25f);
scale_matrix = scale(0.3f, 2.3f, 0.5f);
model_matrix = trans_matrix*scale_matrix;
if (!shadow) {
// Set normal matrix for phong shadow shader
normal_matrix = model_matrix.inverse().transpose();
}
draw_mat_object(Cube, WoodLining);
trans_matrix = translate(-1.0f, 2.0f, -5.25f);
scale_matrix = scale(0.3f, 2.3f, 0.5f);
model_matrix = trans_matrix*scale_matrix;
if (!shadow) {
// Set normal matrix for phong shadow shader
normal_matrix = model_matrix.inverse().transpose();
}
draw_mat_object(Cube, WoodLining);
trans_matrix = translate(0.0f, 3.0f, -5.25f);
scale_matrix = scale(2.0f, 0.3f, 0.5f);
model_matrix = trans_matrix*scale_matrix;
if (!shadow) {
// Set normal matrix for phong shadow shader
normal_matrix = model_matrix.inverse().transpose();
}
draw_mat_object(Cube, WoodLining);
trans_matrix = translate(0.0f, 1.0f, -5.25f);
scale_matrix = scale(2.0f, 0.3f, 0.5f);
model_matrix = trans_matrix*scale_matrix;
if (!shadow) {
// Set normal matrix for phong shadow shader
normal_matrix = model_matrix.inverse().transpose();
}
draw_mat_object(Cube, WoodLining);
//blinds
for (float i = 3.0f; i > 1.0f; i -= 0.1f) {
trans_matrix = translate(0.0f, i, -5.1f);
scale_matrix = scale(1.68f, 0.05f, 0.1f);
rot_matrix = rotate(blinds_ang, 1.0f, 0.0f, 0.0f);
model_matrix = trans_matrix*rot_matrix*scale_matrix;
if (!shadow) {
// Set normal matrix for phong shadow shader
normal_matrix = model_matrix.inverse().transpose();
}
draw_mat_object(Cube, White);
}
//fan
trans_matrix = translate(0.0f, 3.3f, 0.0f);
scale_matrix = scale(0.15f, 0.1f, 0.15f);
model_matrix = trans_matrix*scale_matrix;
if (!shadow) {
// Set normal matrix for phong shadow shader
normal_matrix = model_matrix.inverse().transpose();
}
draw_mat_object(Cylinder, StandingLight);
trans_matrix = translate(0.0f, 3.1f, 0.0f);
scale_matrix = scale(0.5f, 0.05f, 0.5f);
model_matrix = trans_matrix*scale_matrix;
if (!shadow) {
// Set normal matrix for phong shadow shader
normal_matrix = model_matrix.inverse().transpose();
}
draw_mat_object(Cylinder, StandingLight);
//fan blade
for (int i = 0; i < 2; i++) {
scale_matrix = scale(2.65f, 0.05f, 0.4f);
rot_matrix = rotate((90.0f * i) + blade_ang, 0.0f, 1.0f, 0.0f);
model_matrix = trans_matrix*rot_matrix*scale_matrix;
if (!shadow) {
// Set normal matrix for phong shadow shader
normal_matrix = model_matrix.inverse().transpose();
}
draw_mat_object(Cube, WoodLining);
}
//mirror
if (!mirror) {
draw_frame(Frame);
trans_matrix = translate(mirror_eye);
rot_matrix = rotate(-90.0f, vec3(1.0f, 0.0f, 0.0f));
scale_matrix = scale(1.5f, 1.0f, 1.5f);
model_matrix = trans_matrix*rot_matrix*scale_matrix;
draw_tex_object(Mirror, MirrorTex);
}
//drink
trans_matrix = translate(0.0f, 1.6f, 0.0f);
scale_matrix = scale(0.25f, 0.25f, 0.25f);
model_matrix = trans_matrix*scale_matrix;
if (!shadow) {
// Set normal matrix for phong shadow shader
normal_matrix = model_matrix.inverse().transpose();
}
glDepthMask(GL_FALSE);
draw_mat_object(Mug, Glass);
trans_matrix = translate(0.0f, 1.9f, 0.0f);
scale_matrix = scale(0.2f, 0.2f, 0.2f);
model_matrix = trans_matrix*scale_matrix;
if (!shadow) {
// Set normal matrix for phong shadow shader
normal_matrix = model_matrix.inverse().transpose();
}
draw_mat_object(Cylinder, Liquid);
glDepthMask(GL_TRUE);
}
void create_shadows( ){
shadow_proj_matrix = frustum(-1.0, 1.0, -1.0, 1.0, 1.0, 20.0);
vec3 leye = {Lights[0].position[0], Lights[0].position[1], Lights[0].position[2]};
vec3 ldir = {Lights[0].direction[0], Lights[0].direction[1], Lights[0].direction[2]};
vec3 lup = {0.0f, 1.0f, 0.0f};
vec3 lcenter = leye + ldir;
shadow_camera_matrix = lookat(leye, lcenter, lup);
// Change viewport to match shadow framebuffer size
glViewport(0, 0, 1024, 1024);
glBindFramebuffer(GL_FRAMEBUFFER, ShadowBuffer);
glClear(GL_DEPTH_BUFFER_BIT);
shadow = true;
render_scene();
shadow = false;
glBindFramebuffer(GL_FRAMEBUFFER, 0);
// Reset viewport
glViewport(0, 0, ww, hh);
}
void create_mirror( ) {
// Clear framebuffer for mirror rendering pass
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
proj_matrix = frustum(-0.2f, 0.2f, -0.2f, 0.2f, 0.2f, 100.0f);
camera_matrix = lookat(mirror_eye, mirror_center, mirror_up);
// Render mirror scene (without mirror)
mirror = true;
render_scene();
glFlush();
mirror = false;
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, TextureIDs[MirrorTex]);
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, ww, hh, 0);
}
void draw_bump_object(GLuint obj, GLuint base_texture, GLuint normal_map){
// Select shader program
glUseProgram(bump_program);
// Pass projection and camera matrices to shader
glUniformMatrix4fv(bump_proj_mat_loc, 1, GL_FALSE, proj_matrix);
glUniformMatrix4fv(bump_camera_mat_loc, 1, GL_FALSE, camera_matrix);
// Bind lights
glUniformBlockBinding(bump_program, bump_lights_block_idx, 0);
glBindBufferRange(GL_UNIFORM_BUFFER, 0, LightBuffers[LightBuffer], 0, Lights.size() * sizeof(LightProperties));
// Set camera position
glUniform3fv(bump_eye_loc, 1, eye);
// Set num lights and lightOn
glUniform1i(bump_num_lights_loc, numLights);
glUniform1iv(bump_light_on_loc, numLights, lightOn);
// Pass model matrix and normal matrix to shader
glUniformMatrix4fv(bump_model_mat_loc, 1, GL_FALSE, model_matrix);
glUniformMatrix4fv(bump_norm_mat_loc, 1, GL_FALSE, normal_matrix);
// Set base texture to texture unit 0 and make it active
glUniform1i(bump_base_loc, 0);
glActiveTexture(GL_TEXTURE0);
// Bind base texture (to unit 0)
glBindTexture(GL_TEXTURE_2D, TextureIDs[base_texture]);
// Set normal map texture to texture unit 1 and make it active
glUniform1i(bump_norm_loc, 1);
glActiveTexture(GL_TEXTURE1);
// Bind normal map texture (to unit 1)
glBindTexture(GL_TEXTURE_2D, TextureIDs[normal_map]);
// Bind vertex array
glBindVertexArray(VAOs[obj]);
// Bind position object buffer and set attributes
glBindBuffer(GL_ARRAY_BUFFER, ObjBuffers[obj][PosBuffer]);
glVertexAttribPointer(bump_vPos, posCoords, GL_FLOAT, GL_FALSE, 0, NULL);
glEnableVertexAttribArray(bump_vPos);
// Bind normal object buffer and set attributes
glBindBuffer(GL_ARRAY_BUFFER, ObjBuffers[obj][NormBuffer]);
glVertexAttribPointer(bump_vNorm, normCoords, GL_FLOAT, GL_FALSE, 0, NULL);
glEnableVertexAttribArray(bump_vNorm);
// Bind texture object buffer and set attributes
glBindBuffer(GL_ARRAY_BUFFER, ObjBuffers[obj][TexBuffer]);
glVertexAttribPointer(bump_vTex, texCoords, GL_FLOAT, GL_FALSE, 0, NULL);
glEnableVertexAttribArray(bump_vTex);
// Bind tangent object buffer and set attributes
glBindBuffer(GL_ARRAY_BUFFER, ObjBuffers[obj][TangBuffer]);
glVertexAttribPointer(bump_vTang, tangCoords, GL_FLOAT, GL_FALSE, 0, NULL);
glEnableVertexAttribArray(bump_vTang);
// Bind bitangent object buffer and set attributes
glBindBuffer(GL_ARRAY_BUFFER, ObjBuffers[obj][BiTangBuffer]);
glVertexAttribPointer(bump_vBiTang, bitangCoords, GL_FLOAT, GL_FALSE, 0, NULL);
glEnableVertexAttribArray(bump_vBiTang);
// Draw object
glDrawArrays(GL_TRIANGLES, 0, numVertices[obj]);
}
void draw_bump_shadow_object(GLuint obj, GLuint base_texture, GLuint normal_map){
if (shadow) {
// Use shadow shader
glUseProgram(shadow_program);
// Pass shadow projection and camera matrices to shader
glUniformMatrix4fv(shadow_proj_mat_loc, 1, GL_FALSE, shadow_proj_matrix);
glUniformMatrix4fv(shadow_camera_mat_loc, 1, GL_FALSE, shadow_camera_matrix);
// Set object attributes to shadow shader
vPos = shadow_vPos;
model_mat_loc = shadow_model_mat_loc;
} else {
// Select shader program
glUseProgram(bumpShadow_program);
// Pass projection and camera matrices to shader
glUniformMatrix4fv(bumpShadow_proj_mat_loc, 1, GL_FALSE, proj_matrix);
glUniformMatrix4fv(bumpShadow_camera_mat_loc, 1, GL_FALSE, camera_matrix);
// Bind lights
glUniformBlockBinding(bumpShadow_program, bump_lights_block_idx, 0);
glBindBufferRange(GL_UNIFORM_BUFFER, 0, LightBuffers[LightBuffer], 0, Lights.size() * sizeof(LightProperties));
// Set camera position
glUniform3fv(bumpShadow_eye_loc, 1, eye);
// Set num lights and lightOn
glUniform1i(bumpShadow_num_lights_loc, numLights);
glUniform1iv(bumpShadow_light_on_loc, numLights, lightOn);
// Pass model matrix and normal matrix to shader
glUniformMatrix4fv(bumpShadow_norm_mat_loc, 1, GL_FALSE, normal_matrix);
// Set base texture to texture unit 0 and make it active
glUniform1i(bumpShadow_base_loc, 0);
glActiveTexture(GL_TEXTURE0);
// Bind base texture (to unit 0)
glBindTexture(GL_TEXTURE_2D, TextureIDs[base_texture]);
// Set normal map texture to texture unit 1 and make it active
glUniform1i(bumpShadow_norm_loc, 1);
glActiveTexture(GL_TEXTURE1);
// Bind normal map texture (to unit 1)
glBindTexture(GL_TEXTURE_2D, TextureIDs[normal_map]);
glUniform1i(bumpShadow_shadow_loc, 2);
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, TextureIDs[ShadowTex]);
glUniformMatrix4fv(bumpShadow_shad_proj_mat_loc, 1, GL_FALSE, shadow_proj_matrix);
glUniformMatrix4fv(bumpShadow_shad_cam_mat_loc, 1, GL_FALSE, shadow_camera_matrix);