Skip to content

Commit 36a28cc

Browse files
committed
Added emission mapping and change camera location when pressing the 'F' button.
1 parent 1e54d6d commit 36a28cc

File tree

7 files changed

+51
-30
lines changed

7 files changed

+51
-30
lines changed

NeonEngine/imgui.ini

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ Collapsed=0
2626

2727
[Window][Viewport]
2828
Pos=0,36
29-
Size=1680,990
29+
Size=1796,1067
3030
Collapsed=0
3131
DockId=0x00000003,0
3232

3333
[Window][Details]
34-
Pos=1682,776
35-
Size=878,664
34+
Pos=1798,776
35+
Size=762,664
3636
Collapsed=0
3737
DockId=0x00000002,0
3838

@@ -43,8 +43,8 @@ Collapsed=0
4343
DockId=0x3BC79352,0
4444

4545
[Window][Content Browser]
46-
Pos=0,1028
47-
Size=1680,412
46+
Pos=0,1105
47+
Size=1796,335
4848
Collapsed=0
4949
DockId=0x00000001,0
5050

@@ -55,20 +55,20 @@ Size=1441,1038
5555
Collapsed=0
5656

5757
[Window][Outliner]
58-
Pos=1682,36
59-
Size=878,738
58+
Pos=1798,36
59+
Size=762,738
6060
Collapsed=0
6161
DockId=0x00000006,0
6262

6363
[Window][Logger]
64-
Pos=0,1028
65-
Size=1680,412
64+
Pos=0,1105
65+
Size=1796,335
6666
Collapsed=0
6767
DockId=0x00000001,1
6868

6969
[Window][World Settings]
70-
Pos=1682,776
71-
Size=878,664
70+
Pos=1798,776
71+
Size=762,664
7272
Collapsed=0
7373
DockId=0x00000002,1
7474

@@ -86,8 +86,8 @@ Column 0 Weight=0.5767
8686
Column 1 Weight=1.4233
8787

8888
[Table][0xFE3FDFD6,2]
89-
Column 0 Weight=0.6932
90-
Column 1 Weight=1.3068
89+
Column 0 Weight=0.7707
90+
Column 1 Weight=1.2293
9191

9292
[Table][0x7B1C85EA,2]
9393
Column 0 Weight=0.6747
@@ -119,11 +119,11 @@ Column 1 Weight=1.3204
119119

120120
[Docking][Data]
121121
DockSpace ID=0x3BC79352 Pos=49,119 Size=2560,1404 CentralNode=1 Selected=0x13926F0B
122-
DockSpace ID=0xD2411A5B Window=0x0FB73749 Pos=556,479 Size=2560,1404 Split=X Selected=0x13926F0B
123-
DockNode ID=0x00000004 Parent=0xD2411A5B SizeRef=1680,1404 Split=Y
124-
DockNode ID=0x00000003 Parent=0x00000004 SizeRef=2560,990 CentralNode=1 Selected=0x13926F0B
125-
DockNode ID=0x00000001 Parent=0x00000004 SizeRef=2560,412 Selected=0x0340EFE6
126-
DockNode ID=0x00000005 Parent=0xD2411A5B SizeRef=878,1404 Split=Y Selected=0x94263E27
122+
DockSpace ID=0xD2411A5B Window=0x0FB73749 Pos=734,401 Size=2560,1404 Split=X Selected=0x13926F0B
123+
DockNode ID=0x00000004 Parent=0xD2411A5B SizeRef=1796,1404 Split=Y
124+
DockNode ID=0x00000003 Parent=0x00000004 SizeRef=2560,1067 CentralNode=1 Selected=0x13926F0B
125+
DockNode ID=0x00000001 Parent=0x00000004 SizeRef=2560,335 Selected=0x0340EFE6
126+
DockNode ID=0x00000005 Parent=0xD2411A5B SizeRef=762,1404 Split=Y Selected=0x94263E27
127127
DockNode ID=0x00000006 Parent=0x00000005 SizeRef=721,738 Selected=0x94263E27
128128
DockNode ID=0x00000002 Parent=0x00000005 SizeRef=721,664 Selected=0xFC3EA205
129129

NeonEngine/log.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
2023-05-20 16:31:46 Loading model: knight
2-
2023-05-20 16:31:46 Model loaded in 0.354591 seconds
3-
2023-05-20 16:31:46 Loading model: mutant
4-
2023-05-20 16:31:47 Model loaded in 0.398365 seconds
5-
2023-05-20 16:31:47 Loading model: android
6-
2023-05-20 16:31:49 Model loaded in 2.193132 seconds
1+
2023-05-20 18:09:04 Loading model: knight
2+
2023-05-20 18:09:04 Model loaded in 0.354199 seconds
3+
2023-05-20 18:09:04 Loading model: mutant
4+
2023-05-20 18:09:04 Model loaded in 0.392867 seconds
5+
2023-05-20 18:09:04 Loading model: android
6+
2023-05-20 18:09:07 Model loaded in 2.226358 seconds

NeonEngine/shaders/PBR.frag

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ uniform float metalness_model;
2929
uniform float roughness_model;
3030
uniform vec3 emission_model;
3131

32+
uniform float emission_strength;
33+
3234
// IBL
3335
uniform samplerCube irradianceMap;
3436
uniform samplerCube prefilterMap;
@@ -160,7 +162,7 @@ void main() {
160162
}
161163
vec3 emission = emission_model;
162164
if (has_texture_emission == 1) {
163-
emission = texture(texture_emission, TexCoords).rgb;
165+
emission = pow(texture(texture_emission, TexCoords).rgb, vec3(2.2));
164166
}
165167
float ambient_occlusion = 1.0;
166168
if (has_texture_ambient_occlusion == 1) {
@@ -314,7 +316,7 @@ void main() {
314316

315317
vec3 color = ambient + Lo;
316318

317-
FragColor = vec4(color , 1.0);
319+
FragColor = vec4(color + emission_strength * emission , 1.0);
318320
}
319321

320322
float brightness = dot(FragColor.rgb, vec3(0.2126, 0.7152, 0.0722));

NeonEngine/src/input.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,12 @@ void Input::process_viewport_input() {
159159
firstMouse = true;
160160
}
161161
}
162+
163+
if (rendering->last_selected_object != nullptr && ImGui::IsKeyPressed(ImGuiKey_F, false)) {
164+
rendering->camera_viewport->Position += rendering->last_selected_object->position - rendering->camera_viewport->Position;
165+
rendering->camera_viewport->Position -= 10.0f * rendering->camera_viewport->Front;
166+
std::cout << "F pressed" << std::endl;
167+
}
162168
}
163169

164170
void Input::mouse_rotate_camera() {

NeonEngine/src/rendering.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ Rendering::Rendering() {
5656
bloom_filter_radius = 0.005f;
5757
bloom_strength = 0.04f;
5858
bloom_activated = true;
59+
emission_strength = 8.0f;
5960

6061
// PBR parameters
6162
ENVIRONMENT_MAP_WIDTH = 2048;
@@ -676,7 +677,7 @@ void Rendering::initialize_game_objects() {
676677
PointLight* point_light1 = new PointLight("point_light1", "sphere");
677678
point_light1->type = TypePointLight;
678679
point_light1->position = glm::vec3(-10.0f, 10.0f, 10.0f);
679-
point_light1->albedo = glm::vec3(1.0f, 0.0f, 0.0f);
680+
point_light1->albedo = glm::vec3(170.0f/255.0f, 0.0f/255.0f, 255.0f/255.0f);
680681
point_light1->intensity = 5.0f;
681682
point_light1->render_only_ambient = true;
682683
point_light1->render_one_color = true;
@@ -688,7 +689,7 @@ void Rendering::initialize_game_objects() {
688689
PointLight* point_light2 = new PointLight("point_light2", "sphere");
689690
point_light2->type = TypePointLight;
690691
point_light2->position = glm::vec3(10.0f, 10.0f, 10.0f);
691-
point_light2->albedo = glm::vec3(0.0f, 1.0f, 0.0f);
692+
point_light2->albedo = glm::vec3(76.0f/255.0f, 255.0f/255.0f, 0.0f/255.0f);
692693
point_light2->intensity = 5.0f;
693694
point_light2->render_only_ambient = true;
694695
point_light2->render_one_color = true;
@@ -700,7 +701,7 @@ void Rendering::initialize_game_objects() {
700701
PointLight* point_light3 = new PointLight("point_light3", "sphere");
701702
point_light3->type = TypePointLight;
702703
point_light3->position = glm::vec3(-10.0f, -10.0f, 10.0f);
703-
point_light3->albedo = glm::vec3(0.0f, 0.0f, 1.0f);
704+
point_light3->albedo = glm::vec3(255.0f/255.0f, 98.0f/255.0f, 0.0f/255.0f);
704705
point_light3->intensity = 25.0f;
705706
point_light3->render_only_ambient = true;
706707
point_light3->render_one_color = true;
@@ -712,7 +713,7 @@ void Rendering::initialize_game_objects() {
712713
PointLight* point_light4 = new PointLight("point_light4", "sphere");
713714
point_light4->type = TypePointLight;
714715
point_light4->position = glm::vec3(10.0f, -10.0f, 10.0f);
715-
point_light4->albedo = glm::vec3(1.0f, 1.0f, 1.0f);
716+
point_light4->albedo = glm::vec3(255.0f/255.0f, 255.0f/255.0f, 255.0f/255.0f);
716717
point_light4->intensity = 5.0f;
717718
point_light4->render_only_ambient = true;
718719
point_light4->render_one_color = true;
@@ -822,6 +823,8 @@ void Rendering::render_viewport() {
822823
lighting_shader->setInt("num_directional_lights", directional_lights.size());
823824
lighting_shader->setInt("num_spot_lights", spot_lights.size());
824825

826+
lighting_shader->setFloat("emission_strength", emission_strength);
827+
825828
int idx_point_light = 0;
826829
for (auto it = point_lights.begin(); it != point_lights.end(); it++, idx_point_light++) {
827830
lighting_shader->setVec3("pointLights[" + std::to_string(idx_point_light) + "].position", it->second->position);

NeonEngine/src/rendering.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ class Rendering {
8888
Shader* hdr_to_ldr_shader;
8989
Cubemap* cubemap;
9090
CubemapTextureType cubemap_texture_type;
91+
float emission_strength;
9192
float cubemap_texture_mipmap_level;
9293
unsigned int bloom_fbo;
9394
float bloom_filter_radius;

NeonEngine/src/user_interface.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,15 @@ void UserInterface::render_app() {
348348
ImGui::DragFloat("##BloomStrength", &(rendering->bloom_strength), 0.001f, 0.0f, std::numeric_limits<float>::max());
349349
}
350350

351+
// Row 4: Emission Strength
352+
ImGui::TableNextRow();
353+
354+
ImGui::TableSetColumnIndex(0);
355+
ImGui::Text("Emission strength");
356+
357+
ImGui::TableSetColumnIndex(1);
358+
ImGui::DragFloat("##EmissionStrength", &(rendering->emission_strength), 0.2f, 0.0f, std::numeric_limits<float>::max());
359+
351360
ImGui::PopItemWidth();
352361

353362
ImGui::EndTable();

0 commit comments

Comments
 (0)