Fragment Shader
Fragment Shader Variables
Fragment Shader Input
in vec3 fragPos;
in vec3 normal;
// added for LabA07
in vec2 texCoord;Fragment Shader Uniforms
We are adding the texture map as a uniform.
Uniforms of sampler types are used in GLSL to represent a texture of a particular kind. Therefore, sampler types represent textures.
This texture uniform corresponds to the texture unit used in glActiveTexture(GL_TEXTURE#).
For example, 0 is GL_TEXTURE0, 1 is GL_TEXTURE1.
uniform vec3 lightPos;
uniform vec3 viewPos;
// LabA07 texture map unit id
uniform sampler2D textureMap;Note: From OpenGL 4.3, we can use the following to directly refer to a texture unit without setting it with glUniform()
Fragment shader ouput unchanged
Fragment Shader main()
The only change in main is to read colour from the texture map.
Full Source Code fo the Fragment Shader
Last updated