From: Luke Lau Date: Mon, 10 Feb 2020 16:02:23 +0000 (+0000) Subject: New skyboxes X-Git-Tag: cs7gv3-a3~2 X-Git-Url: https://git.lukelau.me/?p=opengl.git;a=commitdiff_plain;h=4b4ca69c7cb67e03931d089a27cefa23be0544ac New skyboxes --- diff --git a/main.cpp b/main.cpp index 325cd05..fd6159d 100644 --- a/main.cpp +++ b/main.cpp @@ -198,9 +198,9 @@ void init() { setupLightBuffers(plainProg->progId); plainProg->validate(); - skyboxes.push_back(Skybox(Image("skyboxes/loft/Newport_Loft_Ref.hdr"))); - skyboxes.push_back(Skybox(Image("skyboxes/monumentValley/Road_to_MonumentValley_Ref.hdr"))); - skyboxes.push_back(Skybox(Image("skyboxes/factory/Factory_Catwalk_2k.hdr"))); + skyboxes.push_back(Skybox(Image("skyboxes/wooden_lounge_8k.hdr"))); + skyboxes.push_back(Skybox(Image("skyboxes/machine_shop_02_8k.hdr"))); + skyboxes.push_back(Skybox(Image("skyboxes/pink_sunrise_8k.hdr"))); pbrProg = new Program("pbrvert.glsl", "pbrfrag.glsl"); glUseProgram(pbrProg->progId); diff --git a/skybox.cpp b/skybox.cpp index 3bf5f40..c0a9ff6 100644 --- a/skybox.cpp +++ b/skybox.cpp @@ -6,8 +6,8 @@ template GLuint setupVertices(GLuint progId, std::array vertices, bool reverse = false); // matrices used when capturing various environment maps -glm::mat4 captureProj = glm::perspective(glm::radians(90.f), 1.f, 0.1f, 10.f); -glm::mat4 captureViews[] = { +const glm::mat4 captureProj = glm::perspective(glm::radians(90.f), 1.f, 0.1f, 10.f); +const glm::mat4 captureViews[] = { glm::lookAt(glm::vec3(0, 0, 0), glm::vec3( 1, 0, 0), glm::vec3(0, -1, 0)), glm::lookAt(glm::vec3(0, 0, 0), glm::vec3(-1, 0, 0), glm::vec3(0, -1, 0)), glm::lookAt(glm::vec3(0, 0, 0), glm::vec3( 0, 1, 0), glm::vec3(0, 0, 1)), @@ -19,7 +19,7 @@ glm::mat4 captureViews[] = { void Skybox::generatePrefilterMap() const { glBindTexture(GL_TEXTURE_CUBE_MAP, prefilterTexId); for (GLuint i = 0; i < 6; i++) - glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0 , GL_RGB16F, 128, 128, 0, GL_RGB, GL_FLOAT, nullptr); + glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0 , GL_RGB16F, 128, 128, 0, GL_RGB, GL_HALF_FLOAT, nullptr); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); @@ -116,7 +116,7 @@ Skybox::Skybox(const Image img): program("skyboxvert.glsl", "skyboxfrag.glsl") { // setup cubemap texture glBindTexture(GL_TEXTURE_CUBE_MAP, cubemapTexId); for (GLuint i = 0; i < 6; i++) - glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGB16F, CUBEMAP_WIDTH, CUBEMAP_HEIGHT, 0, GL_RGB, GL_FLOAT, nullptr); + glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGB16F, CUBEMAP_WIDTH, CUBEMAP_HEIGHT, 0, GL_RGB, GL_HALF_FLOAT, nullptr); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); @@ -145,7 +145,7 @@ Skybox::Skybox(const Image img): program("skyboxvert.glsl", "skyboxfrag.glsl") { // setup irradiance map texture glBindTexture(GL_TEXTURE_CUBE_MAP, irradianceTexId); for (GLuint i = 0; i < 6; i++) - glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGB16F, 32, 32, 0, GL_RGB, GL_FLOAT, nullptr); + glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGB16F, 32, 32, 0, GL_RGB, GL_HALF_FLOAT, nullptr); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); diff --git a/skyboxes/machine_shop_02_8k.hdr b/skyboxes/machine_shop_02_8k.hdr new file mode 100644 index 0000000..8397124 Binary files /dev/null and b/skyboxes/machine_shop_02_8k.hdr differ diff --git a/skyboxes/pink_sunrise_8k.hdr b/skyboxes/pink_sunrise_8k.hdr new file mode 100644 index 0000000..f7ca6ae Binary files /dev/null and b/skyboxes/pink_sunrise_8k.hdr differ diff --git a/skyboxes/wooden_lounge_8k.hdr b/skyboxes/wooden_lounge_8k.hdr new file mode 100644 index 0000000..9550967 Binary files /dev/null and b/skyboxes/wooden_lounge_8k.hdr differ