Creating shaders for the skybox
As usual, we'll begin with creating our shaders. We'll initiate by duplicating our shader files, core.vs, and core.frag, and name those copied files as skybox.vs and skybox.frag. We'll now carry out some modification on these shader files; take a look at the following steps to understand the changes that will be made:
- We'll begin with making modifications to our
skybox.vsshader. Take a look at the following code and implement the following modification in your shader file:
#version 330 core
layout (location = 0) in vec3 position;
out vec3 TexCoords;
uniform mat4 projection;
uniform mat4 view;
void main()
{
vec4 pos = projection * view * vec4(position, 1.0);
gl_Position = pos.xyww;
TexCoords = position;
} Once you have made the changes, save the file.
- Next, we'll move on to
Skybox.fragand carry out the following highlighted changes to the code:
#version 330 core in vec3 TexCoords; out vec4 color; uniform samplerCube skybox; void main...