Base scene running around 13 FPS with battery on in VS
This commit is contained in:
parent
0775c60b38
commit
81446dee6a
@ -121,13 +121,12 @@ void MyGlWindow::shaderSetup()
|
||||
|
||||
shaders["DSLightPass"] = new Shader("DSLightPass.vert", "DSLightPass.frag");
|
||||
shaders["DSLightPass"]->uniformFlags = LIGHTS_FLAG;
|
||||
|
||||
}
|
||||
|
||||
void MyGlWindow::lightSetup()
|
||||
{
|
||||
//Showcase lights
|
||||
_scnctx.lights.emplace("Spotlight1", Light(glm::vec3(0.8f), glm::vec4(10, 10, 10, 1)));
|
||||
//_scnctx.lights.emplace("Spotlight1", Light(glm::vec3(0.8f), glm::vec4(10, 10, 10, 1)));
|
||||
// 24, 12, 2, glm::vec4(0, 1, 0, 1)));
|
||||
|
||||
//Party lights
|
||||
@ -141,14 +140,14 @@ void MyGlWindow::lightSetup()
|
||||
void MyGlWindow::multipassSetup()
|
||||
{
|
||||
//_multipassManager.shader = shaders["ShadowLight"];
|
||||
_multipassManager.addTexture("render_tex", GL_NEAREST, GL_RGB, GL_RGB, false, _scnctx);
|
||||
_multipassManager.bindToFrameBuffer(GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, "render_tex");
|
||||
_multipassManager.addTexture("position_buffer", GL_NEAREST, GL_RGB, GL_FLOAT, false, _scnctx);
|
||||
_multipassManager.addTexture("normal_buffer", GL_NEAREST, GL_RGB, GL_RGB, false, _scnctx);
|
||||
_multipassManager.addTexture("color_buffer", GL_NEAREST, GL_RGB, GL_RGB, false, _scnctx);
|
||||
_multipassManager.bindToFrameBuffer(GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, "position_buffer");
|
||||
_multipassManager.bindToFrameBuffer(GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, "normal_buffer");
|
||||
_multipassManager.bindToFrameBuffer(GL_COLOR_ATTACHMENT2, GL_TEXTURE_2D, "color_buffer");
|
||||
|
||||
_multipassManager.addTexture("depth_tex", GL_LINEAR, GL_DEPTH_COMPONENT24,
|
||||
GL_DEPTH_COMPONENT, true, _scnctx, 1024, 1024);
|
||||
_multipassManager.bindToFrameBuffer(GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, "depth_tex");
|
||||
|
||||
_multipassManager.setDrawBuffers();
|
||||
//_multipassManager.setDrawBuffers();
|
||||
|
||||
_multipassManager.shader->addSubroutine(GL_FRAGMENT_SHADER, "depthing");
|
||||
_multipassManager.shader->addSubroutine(GL_FRAGMENT_SHADER, "blurring");
|
||||
@ -174,8 +173,7 @@ void MyGlWindow::setup()
|
||||
multipassSetup();
|
||||
|
||||
Dataset moddata;
|
||||
moddata.checkeredFloor(100, 100, glm::vec3(0.1, 0.1, 0.1), glm::vec3(0.7, 0.7, 0.7));
|
||||
//TODO : replace by specific light shader that supports color channel (and not just materials)
|
||||
moddata.checkeredFloor(100, 100, glm::vec3(0.1, 0.1, 0.1), glm::vec3(0.7, 0.7, 0.7));
|
||||
meshes.emplace("Floor", new Mesh(moddata, shaders["BaseLight"]));
|
||||
|
||||
moddata.simpleCube();
|
||||
@ -184,17 +182,27 @@ void MyGlWindow::setup()
|
||||
std::srand(18);
|
||||
|
||||
int zob = std::rand();
|
||||
for (int i = 0; i < 100; i++)
|
||||
for (int i = 0; i < 30; i++)
|
||||
{
|
||||
std::string cube_name = "Cube" + std::to_string(i);
|
||||
meshes.emplace(cube_name, new Mesh(moddata, shaders["Simple"]));
|
||||
meshes.emplace(cube_name, new Mesh(moddata, shaders["BaseLight"]));
|
||||
|
||||
float pos_x = std::rand() % 100 - 50;
|
||||
float pos_z = std::rand() % 100 - 50;
|
||||
|
||||
meshes[cube_name]->addStartTranslation(glm::vec4(0, 1, 0, 0));
|
||||
meshes[cube_name]->addStartTranslation(glm::vec4(std::rand() % 100 - 50, 0, 0, 0));
|
||||
meshes[cube_name]->addStartTranslation(glm::vec4(0, 0, std::rand() % 100 - 50, 0));
|
||||
meshes[cube_name]->addStartTranslation(glm::vec4(pos_x, 0, 0, 0));
|
||||
meshes[cube_name]->addStartTranslation(glm::vec4(0, 0, pos_z, 0));
|
||||
meshes[cube_name]->addStartRotation(glm::vec4(1, 0, 0, std::rand() % 360));
|
||||
meshes[cube_name]->addStartRotation(glm::vec4(0, 1, 0, std::rand() % 360));
|
||||
meshes[cube_name]->addStartRotation(glm::vec4(0, 0, 1, std::rand() % 360));
|
||||
|
||||
|
||||
float light_r = (40 + std::rand() % 60) / 100.f;
|
||||
float light_g = (40 + std::rand() % 60) / 100.f;
|
||||
float light_b = (40 + std::rand() % 60) / 100.f;
|
||||
|
||||
_scnctx.lights.emplace("RandLight" + i,
|
||||
Light(glm::vec3(light_r, light_g, light_b), glm::vec4(pos_x, 2, pos_z, 1)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -181,15 +181,7 @@ int loop(GLFWwindow *window)
|
||||
|
||||
static float bgColor[3] = { 0.6f, 0.6f, 0.9f };
|
||||
ImGui::ColorEdit3("Background", bgColor, 0);
|
||||
glWin.setBgColor(bgColor);
|
||||
|
||||
ImGui::SliderFloat("Light X", &(glWin._scnctx.lights["Spotlight1"].location.x), -20, 20);
|
||||
ImGui::SliderFloat("Light Y", &(glWin._scnctx.lights["Spotlight1"].location.y), -20, 20);
|
||||
ImGui::SliderFloat("Light Z", &(glWin._scnctx.lights["Spotlight1"].location.z), -20, 20);
|
||||
ImGui::SliderFloat("Light X Intensity", &(glWin._scnctx.lights["Spotlight1"].intensity.x), 0, 1);
|
||||
ImGui::SliderFloat("Light Y Intensity", &(glWin._scnctx.lights["Spotlight1"].intensity.y), 0, 1);
|
||||
ImGui::SliderFloat("Light Z Intensity", &(glWin._scnctx.lights["Spotlight1"].intensity.z), 0, 1);
|
||||
|
||||
glWin.setBgColor(bgColor);
|
||||
}
|
||||
ImGui::End();
|
||||
|
||||
|
||||
@ -45,7 +45,7 @@ Collapsed=0
|
||||
|
||||
[Window][First Window]
|
||||
Pos=20,20
|
||||
Size=357,188
|
||||
Size=330,60
|
||||
Collapsed=0
|
||||
|
||||
[Window][FPSCounter]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user