diff --git a/BaseGLProject/BaseGLProject.vcxproj b/BaseGLProject/BaseGLProject.vcxproj
index 281918c..05df6d9 100644
--- a/BaseGLProject/BaseGLProject.vcxproj
+++ b/BaseGLProject/BaseGLProject.vcxproj
@@ -229,6 +229,7 @@
+
diff --git a/BaseGLProject/BaseGLProject.vcxproj.filters b/BaseGLProject/BaseGLProject.vcxproj.filters
index e846013..4c3345f 100644
--- a/BaseGLProject/BaseGLProject.vcxproj.filters
+++ b/BaseGLProject/BaseGLProject.vcxproj.filters
@@ -226,5 +226,8 @@
Resource Files
+
+ Resource Files
+
\ No newline at end of file
diff --git a/BaseGLProject/Dataset.cpp b/BaseGLProject/Dataset.cpp
index 226e27d..4aa6782 100644
--- a/BaseGLProject/Dataset.cpp
+++ b/BaseGLProject/Dataset.cpp
@@ -107,6 +107,12 @@ void Dataset::simpleFloor()
colors = { { 0.7, 0.7, 0.7 },{ 0.7, 0.7, 0.7 },{ 0.7, 0.7, 0.7 },
{ 0.7, 0.7, 0.7 },{ 0.7, 0.7, 0.7 },{ 0.7, 0.7, 0.7 } };
+
+ tex_mapping = {
+ { 0.0f, 0.0f },{ 1.0f, 0.0f },{ 1.0f, 1.0f }, // one triangle
+ { 1.0f, 1.0f },{ 0.0f, 1.0f },{ 0.0f, 0.0f } //the other triangle
+ };
+
genNormals();
}
diff --git a/BaseGLProject/MyGLWindow.cpp b/BaseGLProject/MyGLWindow.cpp
index 042016c..bc5d1f6 100644
--- a/BaseGLProject/MyGLWindow.cpp
+++ b/BaseGLProject/MyGLWindow.cpp
@@ -104,8 +104,7 @@ void MyGlWindow::loadScene(SceneChoice scene)
meshes.emplace_back(std::make_shared(moddata, "DSGeometryPass.vert", "DSGeometryPass.frag"));
meshes[meshes.size() - 1]->textures["0"] = scnctx.textures["BrickTex"];
- meshes[meshes.size() - 1]->addStartRotation(glm::vec4(1, -1, 1, 90));
- meshes[meshes.size() - 1]->addStartTranslation(glm::vec4(0, 1, 0, 0));
+ meshes[meshes.size() - 1]->addStartRotation(glm::vec4(1, 0, 0, 90));
meshes[meshes.size() - 1]->addStartTranslation(glm::vec4(pos_x, 0, 0, 0));
meshes[meshes.size() - 1]->addStartTranslation(glm::vec4(0, 0, pos_z, 0));
pos_x += 2;
@@ -125,7 +124,59 @@ void MyGlWindow::loadScene(SceneChoice scene)
scnctx.lights.emplace_back(glm::vec3(light_r, light_g, light_b),
glm::vec4(std::rand() % 40 - 20, std::rand() % 3 + 3, std::rand() % 40 - 20, 1));
}
+ break;
+ case TEAPOTS:
+ moddata.simpleFloor();
+ meshes.emplace_back(std::make_shared(moddata, "DSGeometryPass.vert", "DSGeometryPass.frag"));
+ meshes[meshes.size() - 1]->textures["0"] = scnctx.textures["BrickTex"];
+ meshes[meshes.size() - 1]->addStartScaling(glm::vec4(3, 1, 3, 0));
+ meshes[meshes.size() - 1]->addStartTranslation(glm::vec4(0, -1, 0, 0));
+ moddata.simpleCube();
+ meshes.emplace_back(std::make_shared(moddata, "DSGeometryPass.vert", "DSGeometryPass.frag"));
+ meshes[meshes.size() - 1]->addStartTranslation(glm::vec4(-30, 0, 0, 0));
+ meshes[meshes.size() - 1]->addStartScaling(glm::vec4(1, 5, 30, 0));
+
+ meshes.emplace_back(std::make_shared(moddata, "DSGeometryPass.vert", "DSGeometryPass.frag"));
+ meshes[meshes.size() - 1]->addStartTranslation(glm::vec4(30, 0, 0, 0));
+ meshes[meshes.size() - 1]->addStartScaling(glm::vec4(1, 5, 30, 0));
+
+ meshes.emplace_back(std::make_shared(moddata, "DSGeometryPass.vert", "DSGeometryPass.frag"));
+ meshes[meshes.size() - 1]->addStartTranslation(glm::vec4(0, 0, 30, 0));
+ meshes[meshes.size() - 1]->addStartScaling(glm::vec4(30, 5, 1, 0));
+
+ meshes.emplace_back(std::make_shared(moddata, "DSGeometryPass.vert", "DSGeometryPass.frag"));
+ meshes[meshes.size() - 1]->addStartTranslation(glm::vec4(0, 0, -30, 0));
+ meshes[meshes.size() - 1]->addStartScaling(glm::vec4(30, 5, 1, 0));
+
+ pos_x = -30 + 4.5;
+ pos_z = -30 + 4.5;
+
+ for (int i = 1; i < 141; i++)
+ {
+ meshes.emplace_back(std::make_shared("teapot.obj", "DSGeometryPass.vert", "DSGeometryPass.frag"));
+
+ meshes[meshes.size() - 1]->textures["0"] = scnctx.textures["DefaultTex"];
+ meshes[meshes.size() - 1]->addStartTranslation(glm::vec4(pos_x, 0, pos_z, 0));
+
+ pos_x += 5.9;
+
+ if (i % 10 == 0)
+ {
+ pos_x = -30 + 4.5;
+ pos_z += 4;
+ }
+ }
+
+ for (int i = 0; i < 64; i++)
+ {
+ float light_r = (std::rand() % 20) / 100.f;
+ float light_g = (std::rand() % 20) / 100.f;
+ float light_b = (std::rand() % 20) / 100.f;
+ scnctx.lights.emplace_back(glm::vec3(light_r, light_g, light_b),
+ glm::vec4(std::rand() % 60 - 30, std::rand() % 100 / 100, std::rand() % 60 - 30, 1));
+ }
+
break;
default:
break;
@@ -143,7 +194,8 @@ void MyGlWindow::textureSetup()
scnctx.textures.emplace("BrickTex", Texture("brick1.jpg"));
scnctx.textures.emplace("MossTex", Texture("moss.png"));
- scnctx.textures.emplace("EarthTex", Texture("earth.jpg"));
+ scnctx.textures.emplace("EarthTex", Texture("earth.jpg"));
+ scnctx.textures.emplace("DefaultTex", Texture("default.jpg"));
scnctx.textures.emplace("OgreTex", Texture("Models/ogre/ogre_diffuse.png"));
scnctx.textures["OgreTex"].mat.shininess = 3.0f;
scnctx.textures["OgreTex"].mat.ks = glm::vec3(0.1f, 0.1f, 0.1f);
@@ -187,7 +239,7 @@ void MyGlWindow::setup()
textureSetup();
multipassSetup();
- loadScene(MOUNTAIN);
+ loadScene(TEAPOTS);
}
void MyGlWindow::drawDeferredLight()
diff --git a/BaseGLProject/MyGLWindow.h b/BaseGLProject/MyGLWindow.h
index 5e349c1..4b16b1f 100644
--- a/BaseGLProject/MyGLWindow.h
+++ b/BaseGLProject/MyGLWindow.h
@@ -16,7 +16,8 @@
enum SceneChoice
{
MOUNTAIN,
- CUBES
+ CUBES,
+ TEAPOTS
};
struct vertexAttr {
diff --git a/BaseGLProject/Source.cpp b/BaseGLProject/Source.cpp
index e19a9a5..628063f 100644
--- a/BaseGLProject/Source.cpp
+++ b/BaseGLProject/Source.cpp
@@ -282,12 +282,15 @@ int loop(GLFWwindow *window)
}
if (ImGui::BeginCombo("Scene Choice",
- (glWin.scene == MOUNTAIN) ? "Mountain" : "Cubes"))
+ (glWin.scene == MOUNTAIN) ? "Mountain" :
+ (glWin.scene == CUBES) ? "Cubes" : "Teapots"))
{
if (ImGui::Selectable("Mountain", &is_selected, 0, ImVec2(100, 10)))
glWin.loadScene(SceneChoice::MOUNTAIN);
if (ImGui::Selectable("Cubes", &is_selected, 0, ImVec2(100, 10)))
glWin.loadScene(SceneChoice::CUBES);
+ if (ImGui::Selectable("Teapots", &is_selected, 0, ImVec2(100, 10)))
+ glWin.loadScene(SceneChoice::TEAPOTS);
ImGui::EndCombo();
}
@@ -315,26 +318,29 @@ int loop(GLFWwindow *window)
strings[i] = lights_strs[i].c_str();
ImGui::ListBox("Lights", ¤t_light, strings, lights_strs.size());
- if (ImGui::SliderFloat("Selected light X", &glWin.scnctx.lights[current_light].location.x, -10, 10)
- && glWin.scnctx.renderMode == DEFERRED_LIGHT)
- glWin.multipassManager.recomputeDeferredLights(glWin.scnctx);
- if (ImGui::SliderFloat("Selected light Y", &glWin.scnctx.lights[current_light].location.y, -10, 10)
- && glWin.scnctx.renderMode == DEFERRED_LIGHT)
- glWin.multipassManager.recomputeDeferredLights(glWin.scnctx);
- if (ImGui::SliderFloat("Selected light Z", &glWin.scnctx.lights[current_light].location.z, -10, 10)
- && glWin.scnctx.renderMode == DEFERRED_LIGHT)
- glWin.multipassManager.recomputeDeferredLights(glWin.scnctx);
+ if (glWin.scnctx.lights.size() > 0)
+ {
+ if (ImGui::SliderFloat("Selected light X", &glWin.scnctx.lights[current_light].location.x, -10, 10)
+ && glWin.scnctx.renderMode == DEFERRED_LIGHT)
+ glWin.multipassManager.recomputeDeferredLights(glWin.scnctx);
+ if (ImGui::SliderFloat("Selected light Y", &glWin.scnctx.lights[current_light].location.y, -10, 10)
+ && glWin.scnctx.renderMode == DEFERRED_LIGHT)
+ glWin.multipassManager.recomputeDeferredLights(glWin.scnctx);
+ if (ImGui::SliderFloat("Selected light Z", &glWin.scnctx.lights[current_light].location.z, -10, 10)
+ && glWin.scnctx.renderMode == DEFERRED_LIGHT)
+ glWin.multipassManager.recomputeDeferredLights(glWin.scnctx);
- if (ImGui::SliderFloat("Selected light R", &glWin.scnctx.lights[current_light].intensity.x, 0, 1)
- && glWin.scnctx.renderMode == DEFERRED_LIGHT)
- glWin.multipassManager.recomputeDeferredLights(glWin.scnctx);
- if (ImGui::SliderFloat("Selected light G", &glWin.scnctx.lights[current_light].intensity.y, 0, 1)
- && glWin.scnctx.renderMode == DEFERRED_LIGHT)
- glWin.multipassManager.recomputeDeferredLights(glWin.scnctx);
- if (ImGui::SliderFloat("Selected light B", &glWin.scnctx.lights[current_light].intensity.z, 0, 1)
- && glWin.scnctx.renderMode == DEFERRED_LIGHT)
- glWin.multipassManager.recomputeDeferredLights(glWin.scnctx);
+ if (ImGui::SliderFloat("Selected light R", &glWin.scnctx.lights[current_light].intensity.x, 0, 1)
+ && glWin.scnctx.renderMode == DEFERRED_LIGHT)
+ glWin.multipassManager.recomputeDeferredLights(glWin.scnctx);
+ if (ImGui::SliderFloat("Selected light G", &glWin.scnctx.lights[current_light].intensity.y, 0, 1)
+ && glWin.scnctx.renderMode == DEFERRED_LIGHT)
+ glWin.multipassManager.recomputeDeferredLights(glWin.scnctx);
+ if (ImGui::SliderFloat("Selected light B", &glWin.scnctx.lights[current_light].intensity.z, 0, 1)
+ && glWin.scnctx.renderMode == DEFERRED_LIGHT)
+ glWin.multipassManager.recomputeDeferredLights(glWin.scnctx);
+ }
ImGui::Checkbox("Orbit Lights", &orbiting_lights);
ImGui::SliderFloat("Orbit degrees / second", &light_speed, 0, 360);
}
diff --git a/BaseGLProject/default.jpg b/BaseGLProject/default.jpg
index de7f284..a7abae1 100644
Binary files a/BaseGLProject/default.jpg and b/BaseGLProject/default.jpg differ
diff --git a/BaseGLProject/imgui.ini b/BaseGLProject/imgui.ini
index 640d8fc..533d4f3 100644
--- a/BaseGLProject/imgui.ini
+++ b/BaseGLProject/imgui.ini
@@ -84,7 +84,7 @@ Size=32,32
Collapsed=0
[Window][Light management]
-Pos=11,173
+Pos=-7,119
Size=443,328
Collapsed=0