Adding new glTF shaders
Most of the glTF models contain a normal vector for every vertex, in addition to the color and the position we used for the textured box in the Loading and compiling shaders section of Chapter 2. The normal vector will be used to calculate the angle between every triangle and a light vector in the scene. We will then use a simple lighting model to make the final color brighter or darker, depending on the angle between the normal of the vertex and the light source.
To support the changed format for the vertex data, we must create a new pair of shaders. The first shader is the vertex shader. Create a new file, gltf.vert
, in the shaders
folder:
#version 460 core
layout (location = 0) in vec3 aPos;
layout (location = 1) in vec3 aNormal;
layout (location = 2) in vec2 aTexCoord;
The shader uses GLSL 4.6, like the other renderer shaders in the Loading and compiling shaders section of Chapter 2, and the Fitting the Vulkan nuts and bolts together section of...