Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learn OpenGL

You're reading from   Learn OpenGL Beginner's guide to 3D rendering and game development with OpenGL and C++

Arrow left icon
Product type Paperback
Published in Aug 2018
Publisher Packt
ISBN-13 9781789340365
Length 208 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Frahaan Hussain Frahaan Hussain
Author Profile Icon Frahaan Hussain
Frahaan Hussain
Arrow right icon
View More author details
Toc

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:

  1. We'll begin with making modifications to our skybox.vs shader. 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.

  1. Next, we'll move on to Skybox.frag and carry...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime