May 2019
Intermediate to advanced
542 pages
13h 37m
English
The second shader we need to create is the fragment shader. Remember that this shader's primary job is to determine the color of each point (or fragment) on a primitive.
Create a new file called fragment_shader.glsl and add in this code:
#version 120varying lowp vec4 color;void main(void){ gl_FragColor = color;}
Just as with our vertex shader, we begin with a comment specifying the version of GLSL we're targeting. Then, we will declare a variable called color.
Because this is the fragment shader, specifying a variable as varying makes it an input variable. Using the name color, which was an output variable from our shader, means that we will receive from that shader the color value it assigned.
Within main(), we then ...
Read now
Unlock full access