Added Sponza scene. Updated README.md
|
Before Width: | Height: | Size: 270 KiB After Width: | Height: | Size: 770 KiB |
7
assets/sponza/README.md
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
Sponza
|
||||||
|
===================
|
||||||
|
|
||||||
|
A fixed version of the sponza obj model.
|
||||||
|
The original model was created by Frank Meinl.
|
||||||
|
More info:
|
||||||
|
http://graphics.cs.williams.edu/data/meshes/crytek-sponza-copyright.html
|
||||||
306
assets/sponza/sponza.mtl
Normal file
@@ -0,0 +1,306 @@
|
|||||||
|
# Blender MTL File: 'None'
|
||||||
|
# Material Count: 25
|
||||||
|
|
||||||
|
newmtl Material__25
|
||||||
|
Ns 7.843137
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.470400 0.470400 0.470400
|
||||||
|
Ks 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.000000
|
||||||
|
d 0.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd textures/lion.tga
|
||||||
|
map_Disp textures/lion_ddn.tga
|
||||||
|
map_Ka textures/lion.tga
|
||||||
|
|
||||||
|
newmtl Material__298
|
||||||
|
Ns 7.843137
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.470400 0.470400 0.470400
|
||||||
|
Ks 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.000000
|
||||||
|
d 0.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd textures/background.tga
|
||||||
|
map_Disp textures/background_ddn.tga
|
||||||
|
map_Ka textures/background.tga
|
||||||
|
|
||||||
|
newmtl Material__47
|
||||||
|
Ns 7.843137
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.470400 0.470400 0.470400
|
||||||
|
Ks 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.000000
|
||||||
|
d 0.000000
|
||||||
|
illum 2
|
||||||
|
|
||||||
|
|
||||||
|
newmtl Material__57
|
||||||
|
Ns 7.843137
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.470400 0.470400 0.470400
|
||||||
|
Ks 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd textures/vase_plant.tga
|
||||||
|
map_d textures/vase_plant_mask.tga
|
||||||
|
map_Ka textures/vase_plant.tga
|
||||||
|
|
||||||
|
newmtl arch
|
||||||
|
Ns 7.843137
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.470400 0.470400 0.470400
|
||||||
|
Ks 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.000000
|
||||||
|
d 0.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd textures/sponza_arch_diff.tga
|
||||||
|
map_Ka textures/sponza_arch_diff.tga
|
||||||
|
map_Disp textures/sponza_arch_ddn.tga
|
||||||
|
|
||||||
|
newmtl bricks
|
||||||
|
Ns 7.843137
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.470400 0.470400 0.470400
|
||||||
|
Ks 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.000000
|
||||||
|
d 0.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd textures/spnza_bricks_a_diff.tga
|
||||||
|
map_Disp textures/spnza_bricks_a_ddn.tga
|
||||||
|
map_Ka textures/spnza_bricks_a_diff.tga
|
||||||
|
|
||||||
|
newmtl ceiling
|
||||||
|
Ns 7.843137
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.470400 0.470400 0.470400
|
||||||
|
Ks 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.000000
|
||||||
|
d 0.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd textures/sponza_ceiling_a_diff.tga
|
||||||
|
map_Ka textures/sponza_ceiling_a_diff.tga
|
||||||
|
map_Disp textures/sponza_ceiling_a_ddn.tga
|
||||||
|
|
||||||
|
newmtl chain
|
||||||
|
Ns 7.843137
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.470400 0.470400 0.470400
|
||||||
|
Ks 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd textures/chain_texture.tga
|
||||||
|
map_d textures/chain_texture_mask.tga
|
||||||
|
map_Disp textures/chain_texture_ddn.tga
|
||||||
|
map_Ka textures/chain_texture.tga
|
||||||
|
|
||||||
|
newmtl column_a
|
||||||
|
Ns 7.843137
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.470400 0.470400 0.470400
|
||||||
|
Ks 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.000000
|
||||||
|
d 0.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd textures/sponza_column_a_diff.tga
|
||||||
|
map_Disp textures/sponza_column_a_ddn.tga
|
||||||
|
map_Ka textures/sponza_column_a_diff.tga
|
||||||
|
|
||||||
|
newmtl column_b
|
||||||
|
Ns 7.843137
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.470400 0.470400 0.470400
|
||||||
|
Ks 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.000000
|
||||||
|
d 0.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd textures/sponza_column_b_diff.tga
|
||||||
|
map_Disp textures/sponza_column_b_ddn.tga
|
||||||
|
map_Ka textures/sponza_column_b_diff.tga
|
||||||
|
|
||||||
|
newmtl column_c
|
||||||
|
Ns 7.843137
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.470400 0.470400 0.470400
|
||||||
|
Ks 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.000000
|
||||||
|
d 0.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd textures/sponza_column_c_diff.tga
|
||||||
|
map_Disp textures/sponza_column_c_ddn.tga
|
||||||
|
map_Ka textures/sponza_column_c_diff.tga
|
||||||
|
|
||||||
|
newmtl details
|
||||||
|
Ns 7.843137
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.470400 0.470400 0.470400
|
||||||
|
Ks 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.000000
|
||||||
|
d 0.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd textures/sponza_details_diff.tga
|
||||||
|
map_Ka textures/sponza_details_diff.tga
|
||||||
|
map_Disp textures/sponza_details_ddn.tga
|
||||||
|
|
||||||
|
newmtl fabric_a
|
||||||
|
Ns 7.843137
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.470400 0.470400 0.470400
|
||||||
|
Ks 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.000000
|
||||||
|
d 0.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd textures/sponza_fabric_diff.tga
|
||||||
|
map_Ka textures/sponza_fabric_diff.tga
|
||||||
|
map_Disp textures/sponza_fabric_ddn.tga
|
||||||
|
|
||||||
|
newmtl fabric_c
|
||||||
|
Ns 7.843137
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.470400 0.470400 0.470400
|
||||||
|
Ks 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.000000
|
||||||
|
d 0.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd textures/sponza_curtain_diff.tga
|
||||||
|
map_Ka textures/sponza_curtain_diff.tga
|
||||||
|
map_Disp textures/sponza_curtain_ddn.tga
|
||||||
|
|
||||||
|
|
||||||
|
newmtl fabric_d
|
||||||
|
Ns 7.843137
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.470400 0.470400 0.470400
|
||||||
|
Ks 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.000000
|
||||||
|
d 0.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd textures/sponza_fabric_blue_diff.tga
|
||||||
|
map_Ka textures/sponza_fabric_blue_diff.tga
|
||||||
|
map_Disp textures/sponza_fabric_ddn.tga
|
||||||
|
|
||||||
|
|
||||||
|
newmtl fabric_e
|
||||||
|
Ns 7.843137
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.470400 0.470400 0.470400
|
||||||
|
Ks 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.000000
|
||||||
|
d 0.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd textures/sponza_fabric_green_diff.tga
|
||||||
|
map_Ka textures/sponza_fabric_green_diff.tga
|
||||||
|
map_Disp textures/sponza_fabric_ddn.tga
|
||||||
|
|
||||||
|
|
||||||
|
newmtl fabric_f
|
||||||
|
Ns 7.843137
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.470400 0.470400 0.470400
|
||||||
|
Ks 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.000000
|
||||||
|
d 0.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd textures/sponza_curtain_green_diff.tga
|
||||||
|
map_Ka textures/sponza_curtain_green_diff.tga
|
||||||
|
map_Disp textures/sponza_curtain_ddn.tga
|
||||||
|
|
||||||
|
newmtl fabric_g
|
||||||
|
Ns 7.843137
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.470400 0.470400 0.470400
|
||||||
|
Ks 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.000000
|
||||||
|
d 0.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd textures/sponza_curtain_blue_diff.tga
|
||||||
|
map_Ka textures/sponza_curtain_blue_diff.tga
|
||||||
|
map_Disp textures/sponza_curtain_ddn.tga
|
||||||
|
|
||||||
|
|
||||||
|
newmtl flagpole
|
||||||
|
Ns 7.843137
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.470400 0.470400 0.470400
|
||||||
|
Ks 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.000000
|
||||||
|
d 0.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd textures/sponza_flagpole_diff.tga
|
||||||
|
map_Ka textures/sponza_flagpole_diff.tga
|
||||||
|
map_Disp textures/sponza_flagpole_ddn.tga
|
||||||
|
|
||||||
|
newmtl floor
|
||||||
|
Ns 7.843137
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.470400 0.470400 0.470400
|
||||||
|
Ks 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.000000
|
||||||
|
d 0.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd textures/sponza_floor_a_diff.tga
|
||||||
|
map_Ka textures/sponza_floor_a_diff.tga
|
||||||
|
map_Disp textures/sponza_floor_a_ddn.tga
|
||||||
|
|
||||||
|
newmtl leaf
|
||||||
|
Ns 7.843137
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.470400 0.470400 0.470400
|
||||||
|
Ks 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd textures/sponza_thorn_diff.tga
|
||||||
|
map_d textures/sponza_thorn_mask.tga
|
||||||
|
map_Disp textures/sponza_thorn_ddn.tga
|
||||||
|
map_Ka textures/sponza_thorn_diff.tga
|
||||||
|
|
||||||
|
newmtl roof
|
||||||
|
Ns 7.843137
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.470400 0.470400 0.470400
|
||||||
|
Ks 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.000000
|
||||||
|
d 0.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd textures/sponza_roof_diff.tga
|
||||||
|
map_Ka textures/sponza_roof_diff.tga
|
||||||
|
map_Disp textures/sponza_roof_ddn.tga
|
||||||
|
|
||||||
|
newmtl vase
|
||||||
|
Ns 7.843137
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.470400 0.470400 0.470400
|
||||||
|
Ks 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.000000
|
||||||
|
d 0.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd textures/vase_dif.tga
|
||||||
|
map_Ka textures/vase_dif.tga
|
||||||
|
map_Disp textures/vase_ddn.tga
|
||||||
|
|
||||||
|
newmtl vase_hanging
|
||||||
|
Ns 7.843137
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.470400 0.470400 0.470400
|
||||||
|
Ks 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.000000
|
||||||
|
d 0.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd textures/vase_hanging.tga
|
||||||
|
map_Ka textures/vase_hanging.tga
|
||||||
|
map_Disp textures/vase_hanging_ddn.tga
|
||||||
|
|
||||||
|
newmtl vase_round
|
||||||
|
Ns 7.843137
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.470400 0.470400 0.470400
|
||||||
|
Ks 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.000000
|
||||||
|
d 0.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd textures/vase_round.tga
|
||||||
|
map_Disp textures/vase_round_ddn.tga
|
||||||
|
map_Ka textures/vase_round.tga
|
||||||
569548
assets/sponza/sponza.obj
Normal file
BIN
assets/sponza/textures/Thumbs.db
Normal file
BIN
assets/sponza/textures/background.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
assets/sponza/textures/background_ddn.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
assets/sponza/textures/chain_texture.tga
Normal file
|
After Width: | Height: | Size: 1.0 MiB |
BIN
assets/sponza/textures/chain_texture_ddn.tga
Normal file
|
After Width: | Height: | Size: 768 KiB |
BIN
assets/sponza/textures/lion.tga
Normal file
|
After Width: | Height: | Size: 4.0 MiB |
BIN
assets/sponza/textures/lion2_ddn.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
assets/sponza/textures/lion_ddn.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
assets/sponza/textures/spnza_bricks_a_ddn.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
assets/sponza/textures/spnza_bricks_a_diff.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
assets/sponza/textures/sponza_arch_ddn.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
assets/sponza/textures/sponza_arch_diff.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
assets/sponza/textures/sponza_ceiling_a_ddn.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
assets/sponza/textures/sponza_ceiling_a_diff.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
assets/sponza/textures/sponza_column_a_ddn.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
assets/sponza/textures/sponza_column_a_diff.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
assets/sponza/textures/sponza_column_b_ddn.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
assets/sponza/textures/sponza_column_b_diff.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
assets/sponza/textures/sponza_column_c_ddn.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
assets/sponza/textures/sponza_column_c_diff.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
assets/sponza/textures/sponza_curtain_blue_diff.tga
Normal file
|
After Width: | Height: | Size: 12 MiB |
BIN
assets/sponza/textures/sponza_curtain_ddn.tga
Normal file
|
After Width: | Height: | Size: 12 MiB |
BIN
assets/sponza/textures/sponza_curtain_diff.tga
Normal file
|
After Width: | Height: | Size: 12 MiB |
BIN
assets/sponza/textures/sponza_curtain_green_diff.tga
Normal file
|
After Width: | Height: | Size: 12 MiB |
BIN
assets/sponza/textures/sponza_details_ddn.tga
Normal file
|
After Width: | Height: | Size: 4.0 MiB |
BIN
assets/sponza/textures/sponza_details_diff.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
assets/sponza/textures/sponza_fabric_blue_diff.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
assets/sponza/textures/sponza_fabric_ddn.tga
Normal file
|
After Width: | Height: | Size: 4.0 MiB |
BIN
assets/sponza/textures/sponza_fabric_diff.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
assets/sponza/textures/sponza_fabric_green_diff.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
assets/sponza/textures/sponza_flagpole_ddn.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
assets/sponza/textures/sponza_flagpole_diff.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
assets/sponza/textures/sponza_floor_a_ddn.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
assets/sponza/textures/sponza_floor_a_diff.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
assets/sponza/textures/sponza_roof_ddn.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
assets/sponza/textures/sponza_roof_diff.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
assets/sponza/textures/sponza_thorn_ddn.tga
Normal file
|
After Width: | Height: | Size: 192 KiB |
BIN
assets/sponza/textures/sponza_thorn_diff.tga
Normal file
|
After Width: | Height: | Size: 1.0 MiB |
BIN
assets/sponza/textures/vase_ddn.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
assets/sponza/textures/vase_dif.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
assets/sponza/textures/vase_hanging.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
assets/sponza/textures/vase_hanging_ddn.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
assets/sponza/textures/vase_plant.tga
Normal file
|
After Width: | Height: | Size: 4.0 MiB |
BIN
assets/sponza/textures/vase_round.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
assets/sponza/textures/vase_round_ddn.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
150
src/main.cpp
@@ -1,4 +1,5 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <random>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
#include <glm/gtc/matrix_transform.hpp>
|
#include <glm/gtc/matrix_transform.hpp>
|
||||||
@@ -35,6 +36,9 @@ void mouse_callback(double pos_x, double pos_y, void* user_data);
|
|||||||
void setup_dockspace();
|
void setup_dockspace();
|
||||||
void draw_panel_window(UserData& user_data);
|
void draw_panel_window(UserData& user_data);
|
||||||
void draw_viewport_window(FrameBuffer& framebuffer, UserData& user_data);
|
void draw_viewport_window(FrameBuffer& framebuffer, UserData& user_data);
|
||||||
|
void add_random_lights(Scene& scene, int point_light_count, int spot_light_count,
|
||||||
|
const glm::vec3& box_min, const glm::vec3& box_max,
|
||||||
|
unsigned int seed = std::random_device{}());
|
||||||
std::vector<Vertex> get_cube_vertices();
|
std::vector<Vertex> get_cube_vertices();
|
||||||
|
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
@@ -61,8 +65,9 @@ int main()
|
|||||||
|
|
||||||
Renderer::init();
|
Renderer::init();
|
||||||
|
|
||||||
Camera camera{{5.0f, 5.0f, 5.0f}};
|
Camera camera{{6.0f, 3.0f, 1.0f}};
|
||||||
camera.look_at({0.0f, 0.0f, 0.0f});
|
camera.fov = 60.0f;
|
||||||
|
camera.look_at({0.0f, 1.0f, 0.0f});
|
||||||
|
|
||||||
UserData user_data{*window, camera};
|
UserData user_data{*window, camera};
|
||||||
window->set_callback_user_data(&user_data);
|
window->set_callback_user_data(&user_data);
|
||||||
@@ -73,6 +78,8 @@ int main()
|
|||||||
auto shader = Shader::create("./src/shaders/default.vert", "./src/shaders/default.frag");
|
auto shader = Shader::create("./src/shaders/default.vert", "./src/shaders/default.frag");
|
||||||
auto debug_shader = Shader::create("./src/shaders/debug.vert", "./src/shaders/debug.frag", false);
|
auto debug_shader = Shader::create("./src/shaders/debug.vert", "./src/shaders/debug.frag", false);
|
||||||
|
|
||||||
|
auto sponza = load_obj("./assets/sponza/sponza.obj", shader);
|
||||||
|
|
||||||
auto car = load_obj("./assets/audi_r8/Audi_R8_2017.obj", shader);
|
auto car = load_obj("./assets/audi_r8/Audi_R8_2017.obj", shader);
|
||||||
|
|
||||||
auto backpack = load_obj("./assets/backpack/backpack.obj", shader);
|
auto backpack = load_obj("./assets/backpack/backpack.obj", shader);
|
||||||
@@ -95,18 +102,27 @@ int main()
|
|||||||
|
|
||||||
/******************** Scene construction ********************/
|
/******************** Scene construction ********************/
|
||||||
|
|
||||||
|
// Sponza scene
|
||||||
|
Rc<Scene> sponza_scene = make_rc<Scene>();
|
||||||
|
user_data.scenes.push_back(sponza_scene);
|
||||||
|
|
||||||
|
sponza->transform.position = {0.0f, -0.5f, 0.0f};
|
||||||
|
sponza->transform.scale = {0.008f, 0.008f, 0.008f};
|
||||||
|
sponza_scene->add_entity(*sponza);
|
||||||
|
|
||||||
|
add_random_lights(*sponza_scene, 4, 4,
|
||||||
|
glm::vec3(-10.0f, 1.0f, -3.0f), glm::vec3(10.0f, 5.0f, 3.0f),
|
||||||
|
69420);
|
||||||
|
|
||||||
// Car scene
|
// Car scene
|
||||||
Rc<Scene> car_scene = make_rc<Scene>();
|
Rc<Scene> car_scene = make_rc<Scene>();
|
||||||
user_data.scenes.push_back(car_scene);
|
user_data.scenes.push_back(car_scene);
|
||||||
|
|
||||||
car_scene->add_entity(*car);
|
car_scene->add_entity(*car);
|
||||||
|
|
||||||
PointLight light_white1;
|
add_random_lights(*car_scene, 4, 4,
|
||||||
light_white1.position = glm::vec3(0.0f, 3.0f, 3.0f);
|
glm::vec3(-10.0f, 1.0f, -3.0f), glm::vec3(10.0f, 5.0f, 3.0f),
|
||||||
light_white1.diffuse = glm::vec3(1.0f, 1.0f, 1.0f); // Bright white
|
42);
|
||||||
light_white1.specular = glm::vec3(1.0f, 1.0f, 1.0f); // White highlights
|
|
||||||
|
|
||||||
car_scene->light_environment.point_lights.push_back(light_white1);
|
|
||||||
|
|
||||||
// Backpack scene
|
// Backpack scene
|
||||||
Rc<Scene> backpack_scene = make_rc<Scene>();
|
Rc<Scene> backpack_scene = make_rc<Scene>();
|
||||||
@@ -122,12 +138,9 @@ int main()
|
|||||||
floor.transform.scale = {20.0f, 1.0f, 20.0f};
|
floor.transform.scale = {20.0f, 1.0f, 20.0f};
|
||||||
backpack_scene->add_entity(floor);
|
backpack_scene->add_entity(floor);
|
||||||
|
|
||||||
PointLight light_white2;
|
add_random_lights(*backpack_scene, 4, 4,
|
||||||
light_white2.position = glm::vec3(0.0f, 3.0f, 3.0f);
|
glm::vec3(-10.0f, 1.0f, -3.0f), glm::vec3(10.0f, 5.0f, 3.0f),
|
||||||
light_white2.diffuse = glm::vec3(2.0f, 2.0f, 2.0f); // Bright white
|
37);
|
||||||
light_white2.specular = glm::vec3(2.0f, 2.0f, 2.0f); // White highlights
|
|
||||||
|
|
||||||
backpack_scene->light_environment.point_lights.push_back(light_white2);
|
|
||||||
|
|
||||||
// Cubes scene
|
// Cubes scene
|
||||||
Rc<Scene> cubes_scene = make_rc<Scene>();
|
Rc<Scene> cubes_scene = make_rc<Scene>();
|
||||||
@@ -151,18 +164,9 @@ int main()
|
|||||||
cubes_scene->add_entity(entity);
|
cubes_scene->add_entity(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
PointLight light_warm;
|
add_random_lights(*cubes_scene, 4, 4,
|
||||||
light_warm.position = glm::vec3(0.0f, 2.0f, 2.0f);
|
glm::vec3(-10.0f, 1.0f, -3.0f), glm::vec3(10.0f, 5.0f, 3.0f),
|
||||||
light_warm.diffuse = glm::vec3(1.0f, 0.6f, 0.2f); // Orange
|
152533);
|
||||||
light_warm.specular = glm::vec3(1.0f, 0.8f, 0.5f);
|
|
||||||
|
|
||||||
PointLight light_cool;
|
|
||||||
light_cool.position = glm::vec3(-3.0f, 1.0f, -5.0f);
|
|
||||||
light_cool.diffuse = glm::vec3(0.2f, 0.5f, 1.0f); // Blue
|
|
||||||
light_cool.specular = glm::vec3(0.5f, 0.7f, 1.0f);
|
|
||||||
|
|
||||||
cubes_scene->light_environment.point_lights.push_back(light_warm);
|
|
||||||
cubes_scene->light_environment.point_lights.push_back(light_cool);
|
|
||||||
|
|
||||||
/******************** Main loop ********************/
|
/******************** Main loop ********************/
|
||||||
|
|
||||||
@@ -285,18 +289,16 @@ void draw_panel_window(UserData& user_data)
|
|||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + (50.0f - ImGui::GetTextLineHeight()) * 0.5f);
|
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + (50.0f - ImGui::GetTextLineHeight()) * 0.5f);
|
||||||
ImGui::Text("Fan Engine");
|
ImGui::Text("Fan Engine");
|
||||||
ImGui::Separator();
|
|
||||||
|
|
||||||
ImGui::Text("Press INSERT to toggle camera controls");
|
ImGui::SeparatorText("General Settings");
|
||||||
ImGui::Separator();
|
|
||||||
|
|
||||||
if (ImGui::Checkbox("VSync", &user_data.vsync)) {
|
if (ImGui::Checkbox("VSync", &user_data.vsync)) {
|
||||||
user_data.window.set_vsync(user_data.vsync);
|
user_data.window.set_vsync(user_data.vsync);
|
||||||
}
|
}
|
||||||
ImGui::Checkbox("Show Debug Wireframes", &user_data.show_debug);
|
ImGui::Checkbox("Debug Wireframes", &user_data.show_debug);
|
||||||
ImGui::Separator();
|
|
||||||
|
ImGui::SeparatorText("Scene Selector");
|
||||||
|
|
||||||
ImGui::Text("Scene Selector");
|
|
||||||
for (size_t i = 0; i < user_data.scenes.size(); ++i) {
|
for (size_t i = 0; i < user_data.scenes.size(); ++i) {
|
||||||
char label[64];
|
char label[64];
|
||||||
ImFormatString(label, IM_ARRAYSIZE(label), "Scene %zu", i);
|
ImFormatString(label, IM_ARRAYSIZE(label), "Scene %zu", i);
|
||||||
@@ -305,6 +307,19 @@ void draw_panel_window(UserData& user_data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGui::SeparatorText("Camera Settings");
|
||||||
|
|
||||||
|
ImGui::DragFloat3("Position", &user_data.camera.position.x, 0.1f, -20.0f, 20.0f, "%.1f");
|
||||||
|
ImGui::SliderFloat("FOV", &user_data.camera.fov, 30.0f, 100.0f, "%.1f");
|
||||||
|
|
||||||
|
ImGui::SeparatorText("Key Bindings");
|
||||||
|
|
||||||
|
ImGui::Text("ESCAPE: Quit application");
|
||||||
|
ImGui::Text("INSERT: Toggle camera input");
|
||||||
|
ImGui::Text("WASD: Camera movement");
|
||||||
|
ImGui::Text("F11: Toggle fullscreen");
|
||||||
|
ImGui::Text("H: Toggle renderer wireframe");
|
||||||
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -332,6 +347,77 @@ void draw_viewport_window(FrameBuffer& framebuffer, UserData& user_data)
|
|||||||
ImGui::PopStyleVar();
|
ImGui::PopStyleVar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void add_random_lights(Scene& scene, int point_light_count, int spot_light_count,
|
||||||
|
const glm::vec3& box_min, const glm::vec3& box_max,
|
||||||
|
unsigned int seed/* = std::random_device{}()*/)
|
||||||
|
{
|
||||||
|
std::mt19937 rng(seed);
|
||||||
|
|
||||||
|
std::uniform_real_distribution<float> random_x(box_min.x, box_max.x);
|
||||||
|
std::uniform_real_distribution<float> random_y(box_min.y, box_max.y);
|
||||||
|
std::uniform_real_distribution<float> random_z(box_min.z, box_max.z);
|
||||||
|
|
||||||
|
std::uniform_real_distribution<float> random_direction(-1.0f, 1.0f);
|
||||||
|
std::uniform_real_distribution<float> random_intensity(0.5f, 1.5f);
|
||||||
|
|
||||||
|
const glm::vec3 light_colors[] = {
|
||||||
|
glm::vec3(1.0f, 1.0f, 1.0f), // White
|
||||||
|
glm::vec3(1.0f, 0.6f, 0.2f), // Warm orange
|
||||||
|
glm::vec3(0.2f, 0.5f, 1.0f), // Cool blue
|
||||||
|
glm::vec3(1.0f, 0.2f, 0.2f), // Red
|
||||||
|
glm::vec3(0.3f, 1.0f, 0.4f), // Green
|
||||||
|
glm::vec3(0.8f, 0.3f, 1.0f) // Purple
|
||||||
|
};
|
||||||
|
|
||||||
|
std::uniform_int_distribution<size_t> randomColor(0, std::size(light_colors) - 1);
|
||||||
|
|
||||||
|
auto generateDirection = [&]() {
|
||||||
|
glm::vec3 direction;
|
||||||
|
|
||||||
|
// Avoid generating a vector that is too close to zero.
|
||||||
|
do {
|
||||||
|
direction = glm::vec3(random_direction(rng), random_direction(rng), random_direction(rng));
|
||||||
|
} while (glm::dot(direction, direction) < 0.001f);
|
||||||
|
|
||||||
|
return glm::normalize(direction);
|
||||||
|
};
|
||||||
|
|
||||||
|
auto generateColor = [&]() { return light_colors[randomColor(rng)]; };
|
||||||
|
|
||||||
|
// Generate point lights
|
||||||
|
for (int i = 0; i < point_light_count; ++i) {
|
||||||
|
PointLight light;
|
||||||
|
|
||||||
|
light.position = glm::vec3(random_x(rng), random_y(rng), random_z(rng));
|
||||||
|
glm::vec3 color = generateColor();
|
||||||
|
light.diffuse = color;
|
||||||
|
light.specular = glm::mix(color, glm::vec3(1.0f), 0.25f);
|
||||||
|
|
||||||
|
scene.light_environment.point_lights.push_back(light);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate spot lights
|
||||||
|
for (int i = 0; i < spot_light_count; ++i) {
|
||||||
|
SpotLight light;
|
||||||
|
|
||||||
|
light.position = glm::vec3(random_x(rng), random_y(rng), random_z(rng));
|
||||||
|
light.direction = generateDirection();
|
||||||
|
glm::vec3 color = generateColor();
|
||||||
|
light.ambient = glm::vec3(0.0f);
|
||||||
|
light.diffuse = color;
|
||||||
|
light.specular = glm::mix(color, glm::vec3(1.0f), 0.25f);
|
||||||
|
|
||||||
|
// Narrow inner cone and slightly wider soft outer cone
|
||||||
|
light.cut_off = glm::cos(glm::radians(12.5f));
|
||||||
|
light.outer_cut_off = glm::cos(glm::radians(17.5f));
|
||||||
|
light.constant = 1.0f;
|
||||||
|
light.linear = 0.09f;
|
||||||
|
light.quadratic = 0.032f;
|
||||||
|
|
||||||
|
scene.light_environment.spot_lights.push_back(light);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<Vertex> get_cube_vertices()
|
std::vector<Vertex> get_cube_vertices()
|
||||||
{
|
{
|
||||||
return {
|
return {
|
||||||
|
|||||||