Added teapot Scene
This commit is contained in:
parent
3bbb233716
commit
93271a1113
@ -229,6 +229,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="brick1.jpg" />
|
||||
<Image Include="default.jpg" />
|
||||
<Image Include="earth.jpg" />
|
||||
<Image Include="moss.png" />
|
||||
</ItemGroup>
|
||||
|
||||
@ -226,5 +226,8 @@
|
||||
<Image Include="moss.png">
|
||||
<Filter>Resource Files</Filter>
|
||||
</Image>
|
||||
<Image Include="default.jpg">
|
||||
<Filter>Resource Files</Filter>
|
||||
</Image>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@ -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();
|
||||
}
|
||||
|
||||
|
||||
@ -104,8 +104,7 @@ void MyGlWindow::loadScene(SceneChoice scene)
|
||||
meshes.emplace_back(std::make_shared<Mesh>(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<Mesh>(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<Mesh>(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<Mesh>(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<Mesh>(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<Mesh>(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<Mesh>("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()
|
||||
|
||||
@ -16,7 +16,8 @@
|
||||
enum SceneChoice
|
||||
{
|
||||
MOUNTAIN,
|
||||
CUBES
|
||||
CUBES,
|
||||
TEAPOTS
|
||||
};
|
||||
|
||||
struct vertexAttr {
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 266 B After Width: | Height: | Size: 3.1 KiB |
@ -84,7 +84,7 @@ Size=32,32
|
||||
Collapsed=0
|
||||
|
||||
[Window][Light management]
|
||||
Pos=11,173
|
||||
Pos=-7,119
|
||||
Size=443,328
|
||||
Collapsed=0
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user