I have a skybox and found out that it is impossible to move inside it ( only rotating, not moving closer to person inside it or so, this is not zoom, it is exactly movement) , as is written in this tutorial https://learnopengl.com/#!Advanced-OpenGL/Cubemaps. As soon as I enable translation for the camera, the skybox become rather ugly, with corners and all sides visible, so the idea to move camera and move the skybox at the same time is not really good. What is the appropriate solution? I think it is a rather obvious problem, but I can not find any solutions anywhere. Or maybe I need to use another construction, not skybox for this purpose.enter image description here

enter image description here

here are two states - the first one I get when translate is enabled. I want in the second image to move closer to mountains.

1

Best Answer


Even though this question a few years old, the solution to this problem is that you have to set the view matrix AFTER you "use" your shader for the the skybox. You can't just set the view matrix once in your loop and expect to work with all shaders that have a view uniform.

So the problem is that OP has something like this based on the tutorial within the main loop:

 glm::mat4 view = mCamera.GetViewMatrix(); glDepthFunc(GL_LEQUAL); mSkyboxShader.Use();mSkyboxShader.SetMat4("view", view);mSkyboxShader.SetMat4("projection", projection);mSkybox.Render(mSkyboxTexture);glDepthFunc(GL_LESS);

Regardless of code, this treats your skybox like any other object that you can move to. The solution is:

glm::mat4 view = mCamera.GetViewMatrix(); glDepthFunc(GL_LEQUAL); mSkyboxShader.Use();view = mCamera.GetViewMatrix(); <----SolutionmSkyboxShader.SetMat4("view", view);...

You have to update the view after you activate the shader before applying it to a uniform for each shader program that needs a view matrix.