fix: skybox seams
@ -115,5 +115,11 @@
|
||||
<None Include="shaders\part.vert">
|
||||
<Filter>Shader Files</Filter>
|
||||
</None>
|
||||
<None Include="shaders\shader_skybox.vert">
|
||||
<Filter>Shader Files</Filter>
|
||||
</None>
|
||||
<None Include="shaders\shader_skybox.frag">
|
||||
<Filter>Shader Files</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -111,18 +111,20 @@ void drawObjectPBR(Core::RenderContext& context, glm::mat4 modelMatrix, GLuint a
|
||||
|
||||
void processInput(GLFWwindow* window)
|
||||
{
|
||||
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
|
||||
glfwSetWindowShouldClose(window, true);
|
||||
if (!glfwJoystickPresent(GLFW_JOYSTICK_1)) {
|
||||
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
|
||||
glfwSetWindowShouldClose(window, true);
|
||||
|
||||
float cameraSpeed = 0.1f * deltaTime * 20;
|
||||
if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS)
|
||||
spaceshipPos += cameraSpeed * spaceshipDir;
|
||||
if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS)
|
||||
spaceshipPos -= cameraSpeed * spaceshipDir;
|
||||
if (glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS)
|
||||
spaceshipDir = glm::vec3(glm::eulerAngleY(cameraSpeed) * glm::vec4(spaceshipDir, 0));
|
||||
if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS)
|
||||
spaceshipDir = glm::vec3(glm::eulerAngleY(-cameraSpeed) * glm::vec4(spaceshipDir, 0));
|
||||
float cameraSpeed = 0.1f * deltaTime * 20;
|
||||
if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS)
|
||||
spaceshipPos += cameraSpeed * spaceshipDir;
|
||||
if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS)
|
||||
spaceshipPos -= cameraSpeed * spaceshipDir;
|
||||
if (glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS)
|
||||
spaceshipDir = glm::vec3(glm::eulerAngleY(cameraSpeed) * glm::vec4(spaceshipDir, 0));
|
||||
if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS)
|
||||
spaceshipDir = glm::vec3(glm::eulerAngleY(-cameraSpeed) * glm::vec4(spaceshipDir, 0));
|
||||
}
|
||||
|
||||
|
||||
cameraDir = spaceshipDir;
|
||||
@ -204,12 +206,22 @@ void drawSkybox(Core::RenderContext& context, glm::mat4 modelMatrix, GLuint text
|
||||
}
|
||||
|
||||
|
||||
unsigned int loadCubemap(std::vector<std::string> faces)
|
||||
unsigned int loadCubemap()
|
||||
{
|
||||
unsigned int textureID;
|
||||
glGenTextures(1, &textureID);
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP, textureID);
|
||||
|
||||
std::vector<std::string> faces = {
|
||||
"textures/skybox/space_rt.png",
|
||||
"textures/skybox/space_lf.png",
|
||||
"textures/skybox/space_up.png",
|
||||
"textures/skybox/space_dn.png",
|
||||
"textures/skybox/space_bk.png",
|
||||
"textures/skybox/space_ft.png"
|
||||
|
||||
};
|
||||
|
||||
int width, height, nrChannels;
|
||||
for (unsigned int i = 0; i < faces.size(); i++)
|
||||
{
|
||||
@ -217,7 +229,7 @@ unsigned int loadCubemap(std::vector<std::string> faces)
|
||||
if (data)
|
||||
{
|
||||
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i,
|
||||
0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data
|
||||
0, GL_RGB, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data
|
||||
);
|
||||
}
|
||||
else
|
||||
@ -245,8 +257,7 @@ void renderScene(GLFWwindow* window) {
|
||||
float time = glfwGetTime();
|
||||
updateDeltaTime(time);
|
||||
|
||||
//drawSkybox(cubeContext, glm::translate(cameraPos), texture::cube);
|
||||
|
||||
drawSkybox(cubeContext, glm::translate(cameraPos), texture::cube);
|
||||
//desired objects go here
|
||||
drawObjectSun(sunContext, glm::scale(glm::vec3(0.1f)));
|
||||
|
||||
@ -320,17 +331,7 @@ void init(GLFWwindow* window)
|
||||
|
||||
programSkybox = shaderLoader.CreateProgram("shaders/shader_skybox.vert", "shaders/shader_skybox.frag");
|
||||
|
||||
std::vector<std::string> x = {
|
||||
"textures/skybox/space_bk.png",
|
||||
"textures/skybox/space_dn.png",
|
||||
"textures/skybox/space_ft.png",
|
||||
"textures/skybox/space_lf.png",
|
||||
"textures/skybox/space_rt.png",
|
||||
"textures/skybox/space_up.png"
|
||||
|
||||
};
|
||||
|
||||
texture::cube = loadCubemap(x);
|
||||
texture::cube = loadCubemap();
|
||||
|
||||
//load textures here
|
||||
|
||||
|
Before Width: | Height: | Size: 299 KiB After Width: | Height: | Size: 385 KiB |
Before Width: | Height: | Size: 636 KiB After Width: | Height: | Size: 816 KiB |
Before Width: | Height: | Size: 545 KiB After Width: | Height: | Size: 711 KiB |
Before Width: | Height: | Size: 508 KiB After Width: | Height: | Size: 656 KiB |
Before Width: | Height: | Size: 326 KiB After Width: | Height: | Size: 421 KiB |
Before Width: | Height: | Size: 507 KiB After Width: | Height: | Size: 642 KiB |